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

Vulkan: BaseMaterial3D Proximity Fade exhibits a visible line regardless of distance if opaque surfaces are in front #60860

Closed
Calinou opened this issue May 7, 2022 · 4 comments · Fixed by #61070

Comments

@Calinou
Copy link
Member

Calinou commented May 7, 2022

Godot version

4.0.alpha7

System information

Fedora 34, GeForce GTX 1080 (NVIDIA 510.60.02)

Issue description

BaseMaterial3D Proximity Fade exhibits a visible line regardless of distance if opaque surfaces are in front.

This looks similar to #54978, but happens even if neither VoxelGI nor SDFGI are enabled.

Proximity Fade disabled

2022-05-07_18 15 26

Proximity Fade enabled

2022-05-07_18 15 31

This also occurs without any lights or environment (although the difference is more subtle). You can notice it by Ctrl + Tabbing between those images opened in new tabs:

Proximity Fade disabled

2022-05-07_18 14 42

Proximity Fade enabled

2022-05-07_18 15 01

In comparison, there is no such visible line in 3.5.beta4's GLES3 renderer:

2022-05-07_18 18 51

Steps to reproduce

  • Add a small mesh without any material override.
  • Add a large mesh with a material that has Proximity Fade enabled (any distance will do).
  • Place the large mesh behind the small mesh (relative to the camera).

Minimal reproduction project

@somnathsarkar
Copy link
Contributor

I took a look at the project in a frame debugger, and it seems like the issue lies in the computation of screen_uv.

Godot 3.x:
vec2 screen_uv = gl_FragCoord.xy * screen_pixel_size;

Godot 4.0:
vec2 screen_uv = (gl_FragCoord.xy * scene_data.screen_pixel_size) + (scene_data.screen_pixel_size * 0.5);

I don't believe we need to manually correct for the center of the pixel since gl_FragCoord returns the center by default anyway: https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/gl_FragCoord.xhtml

Using an incorrect value of screen_uv causes the wrong texel of the depth buffer to be sampled, which is most noticeable at the boundary of another object. When I change this computation of screen_uv back to the Godot 3.x version, the black border disappears:
godot_proximity_fade

This also appears to fix the related issue: #54978

image

@Calinou
Copy link
Member Author

Calinou commented May 14, 2022

@somnathsarkar Nice catch 🙂

I wonder the proposed fix also resolves #56792.

@somnathsarkar
Copy link
Contributor

The blur in #56792 is eliminated after applying the fix

Old screen_uv:
godot_sdfgi_blurred_1

New screen_uv:
godot_sdfgi_blurred_2

@Calinou
Copy link
Member Author

Calinou commented May 14, 2022

cc @clayjohn

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

Successfully merging a pull request may close this issue.

2 participants