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

Avoid flipping normal based on facing direction when calculating SDF #102105

Merged
merged 1 commit into from
Jan 28, 2025

Conversation

clayjohn
Copy link
Member

Fixes: #101746
Regression from: #100441

This reverts us back to the state prior to #100441. By switching to geo_normal we were implicitly adding the following lines of code which flip the normal based on the direction that the surface is viewed from:

vec3 normal = normal_interp;
#if defined(DO_SIDE_CHECK)
if (!gl_FrontFacing) {
normal = -normal;
}
#endif // DO_SIDE_CHECK
#endif // NORMAL_USED

Normally this code is desirable as it allows users to get acceptable normals when viewing backfaces. However, for rendering the SDF, we are viewing the surface from multiple sides and we do not want the normal to flip based on view direction.

… This shader runs for multiple directions, so the flip direction won't be accurate and just creates bad normals
@clayjohn clayjohn added this to the 4.4 milestone Jan 28, 2025
@clayjohn clayjohn requested a review from a team as a code owner January 28, 2025 00:52
Copy link
Contributor

@stuartcarnie stuartcarnie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@Repiteo Repiteo merged commit 5ac6bce into godotengine:master Jan 28, 2025
19 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Jan 28, 2025

Thanks!

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

Successfully merging this pull request may close these issues.

SDFGI visual banding / Regression in Godot 4.4 beta RC1
3 participants