Need help with masking a texturerect with a 2d animation

Godot Version

godot 4.2.1

Question

So right now I have this cool animation of what is meant to be a part of a card fading away. This is meant to be used as a mask that goes over the textures for the card art and card background.

However i have no clue how i could implement this as a mask

Screenshot 2024-03-19 170527

This bottom screenshot shows the current tree set-up i have the mask parenting the two textures i want to have masked

I’m not sure how to do this via animation/nodes, but in a shader it’s “trivial”. You feed the sprite_sheet to the shader as a parameter using .set_shader_paramter() and then you update the frame number which is used to determine the relevant UV.x and UV.y of the sprite.

After that you assign the ALPHA channel based on the given sprite frame.

UV was the hardest thing for me to figure out, let me know if you have a problem and I’ll dig up some code I was using for animation re: UV.

Edit: Essentially your card runs through a “shader” which is in a different language. This shader has much more manual controls and is ran in parallel for each pixel. In the shader you want to add additional info about the ALPHA channel based upon the sprite images you have. You essentially say “here’s my normal card, now delete anywhere that this image has a 1.0 value”

That would be great actually! Thanks btw im much less familiar with shaders so I guess now’s a time to learn them.

Set the Mask node CanvasItem.clip_children property to Clip Only

1 Like

oh wow thats actually really simple and easy compared to coding a shader! Thanks for telling me about this!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.