GodotThings icon indicating copy to clipboard operation
GodotThings copied to clipboard

How can I apply a shader to all nodes at once?

Open MyNameIsDabin opened this issue 6 years ago • 2 comments

Applying shaders to each node is somehow thought to be costly. Can't you use it like a Screen Filter with ColorRect?

MyNameIsDabin avatar Jan 02 '20 13:01 MyNameIsDabin

Applying shaders to each node is somehow thought to be costly.

It's not costly if you reuse the material, but the issue is that Godot won't support per-instance uniforms until 4.0. Per-instance uniforms let you specify different shader parameters for the same material without requiring you to duplicate it.

Calinou avatar Mar 15 '21 15:03 Calinou

I somehow totally missed this question, sorry for that. In addition to what @Calinou pointed out it also depends on what you want to filter (each object separately or the whole screen buffer at once).

For example, I think for pixel graphics it's great to render everything at the low "internal" resolution into a buffer and then upscale that in a single post processing step to the output resolution. In this case you would only need to use the shader once for the upscaling step. Additionally it can have performance benefits because almost the whole pipeline runs at a low resolution (graphics performance in these type of games is usually not an issue though). This also means that everything in the scene adheres to the pixel grid - which can be seen as both a good and a bad thing.

Otherwise you'd have to set the shader for each object as mentioned. I think it's also possible to use scenes or custom nodes in Godot to "inherit" the shader or set it internally so you don't have to do it manually for every single object you add.

CptPotato avatar Mar 15 '21 16:03 CptPotato