Skip to content
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

Using Reflection Probe near a screen-reading material causes the probe to turn white #101336

Closed
tzwel opened this issue Jan 9, 2025 · 4 comments

Comments

@tzwel
Copy link

tzwel commented Jan 9, 2025

Tested versions

  • Reproducible in: v4.4.dev7.official [46c8f8c]
  • I could not reproduce it in: v4.3.beta1.official [a4f2ea9] as well as in v4.3.rc2.mono.official [3978628] which means it's a very recent regression

System information

Godot v4.4.dev7 - Windows 10 Vulkan (Forward+) - dedicated AMD Radeon RX 6600 XT (Advanced Micro Devices, Inc.; 32.0.12011.1036)

Issue description

I was writing a shader that reads from the depth texture. At first I experienced some mild problems like specular reflections being blown out but fiddling with the probe's placement mostly fixed the problem. Then I added a VoxelGI node, baked the lighting and the bug you see below happened.

Image
Image

From my testing this is irreversible, and only goes away once I disable the material that reads from the screen texture or just delete that part from the shader. I left some comments in the shader to shed more light on the problem

This issue was hard to find and I'm still unsure if the title is right. That's the best description I could think of.

Steps to reproduce

Enable the reflection probe - everything goes white.
Disable the node "river" that reads from screen texture (and reenable the reflection probe to refresh it) and everything goes back to normal

Minimal reproduction project (MRP)

probe MRP.zip

Everything can be found in the MRP. The shader is assigned to the "river" mesh

@matheusmdx
Copy link
Contributor

Bisected to #96431, @viksl

Image


An observation, probably not related to this issue per se, was in my pc the mrp didn't rendered like in the image posted in the issue, when i opened in my pc that was the first result:

Image


I had to delete the .godot folder to fix the editor, but the river wasn't rendered like the image:

Image

Image

@akien-mga
Copy link
Member

CC @clayjohn - #96431 was cherry-picked for 4.3.1 so if this is confirmed to be a bug, we should probably either fix it in priority or revert the cherry-pick to avoid publishing it with 4.3.1 (once I do get back to working on it...).

@clayjohn
Copy link
Member

clayjohn commented Jan 9, 2025

I just tested this locally. There isn't a regression. In fact, the correct behaviour is in 4.4.

The shader for the river is outputting an alpha value of approximately -10,000. This causes the color value to explode when blending to the screen. The issue is fixed by clamping the ALPHA value in the last line of the shader:

ALPHA = clamp(1. - (depth*.7), 0.0, 1.0); // this line makes everything white

The issue appears to go away in 4.3 because 4.3 had a bug where transparent objects did not appear in reflections:

4.3-stable
Image

#96431 fixed the bug, so now the river appears in the reflection, and since the post-blend color value ends up exploding, it washes out the entire reflection probe

Image Image

In summary, the bug is in the shader, not with Godot.

There are three main problems with this shader that the user needs to address:

  1. It doesn't do any clamping or bounds checking. Remember, "garbage in, garbage out". If you feed your GPU garbage, it will spit out garbage
  2. It uses the clip space depth directly which is almost always a bad idea. And definitely is not proper for a water effect. (you definitely can't add the clip space depth to the View space depth and expect to get any reasonable results)
  3. It uses depth to camera and ignores the fact that ReflectionProbes have their own camera. This is why the result looks different to the main camera and to the reflection probe.

@clayjohn clayjohn closed this as not planned Won't fix, can't repro, duplicate, stale Jan 9, 2025
@github-project-automation github-project-automation bot moved this from For team assessment to Done in Rendering Issue Triage Jan 9, 2025
@clayjohn clayjohn removed this from the 4.4 milestone Jan 9, 2025
@tzwel
Copy link
Author

tzwel commented Jan 10, 2025

Bisected to #96431, @viksl

Image

An observation, probably not related to this issue per se, was in my pc the mrp didn't rendered like in the image posted in the issue, when i opened in my pc that was the first result:

Image

I had to delete the .godot folder to fix the editor, but the river wasn't rendered like the image:

Image

Image

From my observations it automatically turns on the wireframe render for some reason. Might be a bug of its own, no idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants