-
-
Notifications
You must be signed in to change notification settings - Fork 21.2k
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
FOG writing in shaders fails with Compatibility renderer unless enabled via WorldEnvironment #94183
Comments
The problem here is we use a pre-processor macro godot/drivers/gles3/rasterizer_scene_gles3.cpp Lines 2571 to 2573 in ff8a278
What makes this complicated is that there is also a We need to go through the shader and clean up places where godot/drivers/gles3/shaders/scene.glsl Lines 1919 to 1928 in ff8a278
|
Going to take a crack at this. Edit: Writing my debug notes below since I'm new to contributing here. If any of the more experienced contributors want to tell me I am barking up the wrong tree, please do so. Started trying to debug and ended up using grep -r and commenting out every instance of Changed the shader script to: shader_type spatial;
void fragment() {
ALBEDO = vec3(0.0, 1.0, 0.0);
} and verified this was green across all three modes, so it appeared to not like Using Adding the WorldEnvironment node back in flipped it, where Compatibility is red but the other two don't work. Not sure at which point this started. Commenting out the |
OK I've drilled it down further, current code works in all modes, with and without the world node, aside from these changes: From #ifndef FOG_DISABLED
fog.xy = unpackHalf2x16(fog_rg);
fog.zw = unpackHalf2x16(fog_ba);
//#ifndef DISABLE_FOG // debug - this breaks compatibility mode w no World node
//if (scene_data.fog_enabled) { // debug - same issue as above
frag_color.rgb = mix(frag_color.rgb, fog.rgb, fog.a);
//}
//#endif // !DISABLE_FOG
#endif // !FOG_DISABLED // Commenting out FOG_DISABLED and leaving the if statement in does not fix.
#ifndef FOG_DISABLED
fog.xy = unpackHalf2x16(fog_rg);
fog.zw = unpackHalf2x16(fog_ba);
//#ifndef DISABLE_FOG // debug - uncommenting this makes compatibility mode have 3 red sides, 3 white sides
//if (scene_data.fog_enabled) { // debug - same issue here
additive_light_color *= (1.0 - fog.a);
//}
//#endif // !DISABLE_FOG
#endif // !FOG_DISABLED // same issue if you uncomment scene_data but comment this. DISABLE_FOG remains commented out. So Additionally, there is no way it is letting me leave |
Tested versions
4.2.2, 4.3.beta3
System information
Windows 11, Compatibility
Issue description
Writing to
FOG
in a shader works fine in Forward+ and Mobile, regardless of whether there is a WorldEnvironment node with fog enabled in the scene. This leads me to believe writing toFOG
is intended to entirely override fog from any WorldEnvironment node. However, with the Compatibility renderer, writing toFOG
only works if there is a WorldEnvironment node with fog enabled.Steps to reproduce
Add a node, like a MeshInstance3D, to a scene. Add a ShaderMaterial to it and give that a shader which writes to
FOG
in thefragment
function. If you're using the Forward+ or Mobile renderers, you should see the fog color of the node change. However, with the Compatibility renderer, you'll need to add a WorldEnvironment node, give it an Environment resource, and enable fog; only then will you see the fog color change to what you instructed it to in the shader.Minimal reproduction project (MRP)
Fog Shader Compatibility Issue MRP.zip
The text was updated successfully, but these errors were encountered: