-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Casting a uniform bool to an integer or float breaks the renderer in GLSL shaders #72466
Comments
The issue here is that you are using a non-constant variable ( The Godot shader compiler should provide an error with line highlighting in this case though. It should not fall through to the GLSL compiler. |
I did think that but I thought it was weird for Godot to tell me off for it, I'll give it a try |
Marking as 4.x with cherrypick to 3.x as 4.x doesn't catch this error either, it falls through to the GLSL compiler as well. CC @Chaosus |
Thanks for your reply, I've tried removing the const keyword but I think Godot is refusing to compile my shader now as the shader param options are gone. Is there a way I can force Godot to compile it or is it a fatal error? Error log:
|
Not sure how relevant it is now, but I'd also like to add that I've just updated my GPU drivers to the latest version (528.24) and the issue still persists |
That is no longer a valid shader. To be in the global namespace it needs to be a constant or a uniform. For that to work the definition needs to be inside of |
Updating GPU drivers won't help here. You are writing invalid code and the compiler is rightfully failing to compile. On our end we need to make the compiler error easier to understand so that it helps you write correct code. |
Thank you for your help, this fixed my problem. Should I leave this issue open if you're intending to improve the error raised? |
Yes please |
Godot version
3.5.1.stable
System information
Windows 10 x64, GLES2, GTX 1660 (528.02)
Issue description
I have a shader that takes a boolean input with
uniform bool
. I want to cast this to a float and multiply it by -1 to avoid branching. When I add in a line to perform the cast, I get an internal error to do with GL and the entire editor preview turns white.Before:
After:
The full error (it's long as it has the contents of some internal files) is as follows:
Steps to reproduce
The lines that trigger the bug are:
I tried to take away the const keyword but the editor marks it as an error.
In the repro example, open the scene "bug_demo.tscn", then inspect the sprite called "slash", then check the ShaderMaterial and then the shader inside it. Uncomment the line below the comment saying it's the following line.
Minimal reproduction project
shader_bug_demo.zip
The text was updated successfully, but these errors were encountered: