+1 vote

I have a CanvasLayer singleton that I am using for transition effects between scenes in my game. This CavasLayer contains a screen-sized ColorRect child with a shader (canvas_type unshaded) that does various screen wipes when its uniforms are animated using an AnimationPlayer. This shader changes the COLOR of the screen depending on the values of its uniforms.

I also have a CRT shader (canvas_Type unshaded) that I want to use in my game, at
the same time that these screen transition effects are taking place.

I tried to add another ColorRect to my CanvasLayer, this time with the CRT shader on it, higher in the heierarchy than the other ColorRect I am using for the screen transitions.

Unfortunately, because both shaders change COLOR, the shader lower in the hierarchy always cancels out the shader higher up. Basically, only one shader can work at a time.

Is there a way to stack shaders using ColorRects similar to the way I've been trying?

If not, what's an alternative solution? I really like the idea of keeping my shaders separate depending on what they do. I don't want to combine them into a single shader if it can be avoided.

in Engine by (1,599 points)

1 Answer

+1 vote

If you open your material in the inspector one option should be Next Pass. You can then specify the next shader/material to apply on top of the current material. If your second shader is still canceling out the first then maybe you need to adjust the alpha of your second shader so as to let some of the color from the first pass through.

by (251 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.