Use correct ndc for proximity fade in Compatibility#111437
Merged
Repiteo merged 1 commit intogodotengine:masterfrom Oct 22, 2025
Merged
Use correct ndc for proximity fade in Compatibility#111437Repiteo merged 1 commit intogodotengine:masterfrom
Repiteo merged 1 commit intogodotengine:masterfrom
Conversation
clayjohn
approved these changes
Oct 22, 2025
Calinou
reviewed
Oct 22, 2025
Comment on lines
+1845
to
+1846
| vec4 ndc = OUTPUT_IS_SRGB ? vec4(vec3(SCREEN_UV, proximity_depth_tex) * 2.0 - 1.0, 1.0) : vec4(SCREEN_UV * 2.0 - 1.0, proximity_depth_tex, 1.0); | ||
| vec4 proximity_view_pos = INV_PROJECTION_MATRIX * ndc; |
Member
There was a problem hiding this comment.
Add a comment to explain why this is done:
Suggested change
| vec4 ndc = OUTPUT_IS_SRGB ? vec4(vec3(SCREEN_UV, proximity_depth_tex) * 2.0 - 1.0, 1.0) : vec4(SCREEN_UV * 2.0 - 1.0, proximity_depth_tex, 1.0); | |
| vec4 proximity_view_pos = INV_PROJECTION_MATRIX * ndc; | |
| // Use correct normalized device coordinates on Compatibility. | |
| vec4 ndc = OUTPUT_IS_SRGB ? vec4(vec3(SCREEN_UV, proximity_depth_tex) * 2.0 - 1.0, 1.0) : vec4(SCREEN_UV * 2.0 - 1.0, proximity_depth_tex, 1.0); | |
| vec4 proximity_view_pos = INV_PROJECTION_MATRIX * ndc; |
Calinou
approved these changes
Oct 22, 2025
Member
Calinou
left a comment
There was a problem hiding this comment.
Looks good to me.
Ideally, we'd use the shader preprocessor to avoid (static) branching, but this is better than the status quo.
Member
This code will get optimized at compile time since |
Contributor
|
Thanks! |
Member
|
Cherry-picked for 4.5.2. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I believe this is the only other place in BaseMaterial where the depth texture is used aside from refraction, which requires different math between the RD renderers and Compatibility. The other prs either fail shader compilation or output sub-optimal shader code when converting to ShaderMaterial in the editor.
Fixes #89942
Supersedes #100220