I want to use the clip children function on CanvasItem, and I want to use a shader generated shape as mask, so I can achieve some dynamic effect.
The problem is: when I apply a shader to the Parent node(a ColorRect node), the clip children function doesn’t seem to work. All my children ColorRect nodes are not clipped.
So, what’s the proper way to use shader generated mask to cilp children?
You could probably start with a basic minimal shader to get clipping working at all at first. It’s hard to tell what you have there going on and if any part of it is wrong.
As far as I can tell, clip children should just take the color from the screen but replace alpha taking it from your clipping node. It however involves reading the screen texture and is probably affected by a bunch other things in the engine. Look into screen reading shaders and if there are any related requirements.
It seems that the canvas item first creates the clip mask without applying a material and then draws itself using the material. Not sure if this should be considered a bug or a limitation but you’d probably open an issue in the issue tracker
Thanks a lot! That’s a great workaround even without adding any script.
Since a workaround simple as this exists, I don’t think this would worth to be discussed as an issue. And to fix this, it requires a change in the render pipeline, which usually cause many other issues.