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

Screen-Space reflections (SSR) are semi-transparent. #79549

Closed
WrobotGames opened this issue Jul 16, 2023 · 9 comments
Closed

Screen-Space reflections (SSR) are semi-transparent. #79549

WrobotGames opened this issue Jul 16, 2023 · 9 comments

Comments

@WrobotGames
Copy link

Godot version

v4.1.stable.official [9704596]

System information

Godot v4.1.stable - Windows 10.0.22621 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1060 6GB (NVIDIA; 31.0.15.3640) - Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz (8 Threads)

Issue description

The screen space reflections are semi-transparent.

The problem occurs on any reflective surface (any material with a low roughness). The reflection seems to be more transparent the darker the color of the reflected object.
afbeelding
The sky should not shine through the reflection of the 2 cubes.

Here are a few examples of what the reflections should look like

(Blender Eevee)
afbeelding
(Blender Eevee, with the mirror is tinted red to show whats reflection and whats not)
afbeelding
(Blender cycles)
afbeelding

Steps to reproduce

  1. Create a mirror like object by setting the roughness to 0 and the metallic to 1 on the material.
    (The issue shows up in every single material with a low roughness, but it becomes really clear with this material.)
  2. Enable SSR and the issue should be visible. If not, set max steps to the highest possible and set fade in/out to 0.

Minimal reproduction project

N/A

@Calinou
Copy link
Member

Calinou commented Jul 16, 2023

@WrobotGames Please upload a minimal reproduction project to make this easier to troubleshoot. (While you're at it, please also upload the equivalent Blender project 🙂)

Also, can you reproduce this in 3.5.2?

@WrobotGames
Copy link
Author

Reproduction projects including Godot 3 / extra examples.

The following screenshots came from Godot 4, Godot 3, Blender Eevee and Blender Cycles. I took a screenshot from 2 sides because the issue is more visible from one side in Godot 4. The issue does not show up in Godot 3.5.2.

Godot 4:
afbeelding
afbeelding
Godot 3:
Godot 3s screen space reflections don't show color when the reflecting surface isn't metallic. It also doesn't work well with roughness, this is visible in the 'puddles'.
afbeelding
afbeelding
Blender Eevee:
Semi-real time screen space reflections.
afbeelding
afbeelding
Blender Cycles:
Path traced reflections.
afbeelding
afbeelding

Projects download:

Godot3.zip
Godot4.zip
Blender.zip

mandryskowski added a commit to mandryskowski/godot that referenced this issue Jul 18, 2023
…o metallic and SSR

Commit 2c000cb changed the interpolation limits from (0.04, 1.0) to (0.04, 0.37). This is incorrect, as we want to have an F0 of 0.04 for dielectrics (materials with metalness of 0.0) and an F0 of 1.0 for metals.
The Schlick approximation uses an F0 of 0.04 for all dielectrics and it's good enough.
Having it lower than 1.0 leads to an incorrect application of the Fresnel effect for metals and leads to bugs like godotengine#79549
@mandryskowski
Copy link
Contributor

mandryskowski commented Jul 18, 2023

First, note that the sky reflections on the three horizontal quads are not due to SSR (from what I gathered they come from IBL on the cubemap).
The following screenshot has been taken with SSR off:

image

SSR is a post-processing effect so it is applied on top of what is seen here. The SSR shader has an output alpha value responsible for the reflections' opacity.
In this example the Fresnel term affects the alpha value the most. I disabled the effect by commenting out a line at the end of the SSR shader like this:

	//final_color.a *= f0 + (1.0 - f0) * m; // Fresnel Schlick term.

And got this:

image

This gives us more plausible results but we do not want to erase the Fresnel effect completely. In the real world, surfaces are more reflective when we look at them at small grazing angles which is exactly what this effect represents.
Looking at the code I discovered a bug with setting the F0 value in the shader (see PR #79624). This PR keeps the Fresnel but fixes it for metallic surfaces (the middle one):

image
image

Note that the non-metallic quad (on the right in all pictures except the last one where it is on the left) still shows a semi-transparent reflection. I guess you could hack it and tweak the F0 value based on roughness but it would not be physically correct.

@WrobotGames
Copy link
Author

The alpha values coming from the SSR shader are indeed correct, with the Fresnel effect.

This transparency is not the problem, its the blending with the background reflection.
In this video is visible that the screen space reflections look right unless the HDRI reflections are enabled.
Gif showing the effect
The background reflection should never shine trough another reflection.

So... the reflection godot should show is only the screen space reflection when there is one and otherwise the sky.
afbeelding
Taking the ssr from the 2nd image and everything else from the 1st image would result in something like the 3rd image.

The only time the reflections should be blended is when the reflective surface doesn't have a roughness of 0, of course.

@YuriSizov
Copy link
Contributor

Fixed by #79624.

@YuriSizov YuriSizov added this to the 4.2 milestone Jul 21, 2023
@WrobotGames
Copy link
Author

The PR has really improved the look of the reflections in the metallic 'mirror', but the issue of the sky leaking isn't completely solved.
For example the brightest parts of the hdri show up in the metallic mirror. (Captured in 4.2 dev, with PR)
afbeelding

I'm not sure if this issue should be reopened. (Or if this is a new issue).

@Calinou
Copy link
Member

Calinou commented Jul 24, 2023

I can confirm the sky reflection is still visible through on 4.2.dev 6588a4a, even at very low background energy:


The only way to get rid of it is to set Reflected Light to Disabled, but this disables all sky reflections.

@Calinou Calinou reopened this Jul 24, 2023
IntangibleMatter pushed a commit to IntangibleMatter/godot that referenced this issue Aug 13, 2023
…o metallic and SSR

Commit 2c000cb changed the interpolation limits from (0.04, 1.0) to (0.04, 0.37). This is incorrect, as we want to have an F0 of 0.04 for dielectrics (materials with metalness of 0.0) and an F0 of 1.0 for metals.
The Schlick approximation uses an F0 of 0.04 for all dielectrics and it's good enough.
Having it lower than 1.0 leads to an incorrect application of the Fresnel effect for metals and leads to bugs like godotengine#79549
@WrobotGames
Copy link
Author

WrobotGames commented Oct 11, 2023

This issue is a lot less apparent now with the pr. (The issue is gone when setting fade in/out to 0) But its kinda still there with the default settings. (I think this is the expected behavior though) Should the issue be closed?

@Calinou
Copy link
Member

Calinou commented Oct 11, 2023

But its kinda still there with the default settings.

That's expected, as SSR isn't fully opaque with the default settings due to fade in/out.

I think this has been resolved to the best of our abilities given the default settings (which we can't change to preserve existing projects' artistic intention).

@Calinou Calinou closed this as completed Oct 11, 2023
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

4 participants