Can a shader affect other elements

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By vetu11

So, I’m trying to do an interface animation with shaders, and I need to modify the appearence of mutiple nodes as if they were one. How can I achive this?

The effect I’m trying to get is a mask-like, but using light2D is a little bit expensive.

How can I modify the previously rendered objects alpha? Is there any render_modethat can do it?

:bust_in_silhouette: Reply From: Zylann

At the moment, a ShaderMaterial can only affect an object on which it is applied. If you want the same material to be applied on more than one object, re-use the same material on them and it will affect them all individually.

modify the appearence of mutiple nodes as if they were one

Can you better explain what you mean by this?

As for modifying previously rendered objects alpha, this is not possible in the current API. What is drawn is drawn, you can only get the resulting pixel color on screen. There is no individual alpha information you can get from it. The only way would be to use a render-to-texture to compose into the final render, which can only be done with a Viewport, which in turn might be quite overkill for a UI.
There might be a GPU driver feature to do what you want (at least maybe stencil buffer) but it’s not exposed by the engine.

By “modify the appearence of mutiple nodes as if they were one”, I’d like the effect to affect all the children of a node, so with one ShaderMaterial on the parent, modify the appearence of the whole.

But with what I understand and what you answered, I think that I will have to take other way to solve this problem.

vetu11 | 2019-07-16 14:57

Yeah if you want all nodes to have that shader, you basically need to assign the same material to all of them.

Zylann | 2019-07-16 18:43