Godot Version
3.5.2
Question
Hi, I’m trying to implement a custom post-processing fog shader, since i want to add some screen space gradients to the fog. I’m using the OpenGL ES 2.0 renderer.
When running the game in the browser, the whole shader breaks down.
The problem
(white fog in editor)
(white fog in browser)
The fog is rendered as an post-processing effect on a MeshInstance quad in front of the camera. (since access to the depth buffer is only possible in the spatial shader_type)
The problematic line
I nailed the error down to this line in the shader:
float non_linear_depth = texture(DEPTH_TEXTURE, SCREEN_UV).r;
The non_linear_depth is then linearised and used like this:
float depth = linearize_depth(non_linear_depth, cam_near, cam_far) / cam_far;
ALPHA = depth;
Testing the problem
Setting the ALPHA to some constant value (from 0.0 to 1.0), also does not change anything. (expected result should be a slightly tinted screen)
Only when i remove the texture(DEPTH_TEXTURE, SCREEN_UV).r I’m able to get the slightly tinted result.
expected result when ALPHA is set to 0.5
So im pretty sure it is in the texture(DEPTH_TEXTURE, SCREEN_UV).r function.
I’ve also tried the lod variant and still no changes.
float non_linear_depth = textureLod(DEPTH_TEXTURE, SCREEN_UV, 0.0).r;
The Question
Is there any alternative to texture(DEPTH_TEXTURE, SCREEN_UV).r, or some secret export setting I’ve missed? Please let me know!


