Fix proximity fade in Compatibility renderer#100220
Fix proximity fade in Compatibility renderer#100220tetrapod00 wants to merge 1 commit intogodotengine:masterfrom
Conversation
| // Proximity Fade: Enabled | ||
| float proximity_depth_tex = textureLod(depth_texture, SCREEN_UV, 0.0).r; | ||
| #if CURRENT_RENDERER == RENDERER_COMPATIBILITY | ||
| vec4 proximity_view_pos = INV_PROJECTION_MATRIX * vec4(SCREEN_UV * 2.0 - 1.0, proximity_depth_tex * 2.0 - 1.0, 1.0); |
There was a problem hiding this comment.
Alternately:
| vec4 proximity_view_pos = INV_PROJECTION_MATRIX * vec4(SCREEN_UV * 2.0 - 1.0, proximity_depth_tex * 2.0 - 1.0, 1.0); | |
| vec4 proximity_view_pos = INV_PROJECTION_MATRIX * vec4(vec3(SCREEN_UV, proximity_depth_tex) * 2.0 - 1.0, 1.0); |
We could also do something more like this, leaving the "default" case of Forward+/Mobile implicit:
float proximity_depth_tex = textureLod(depth_texture, SCREEN_UV, 0.0).r;
#if CURRENT_RENDERER == RENDERER_COMPATIBILITY
proximity_depth_tex = proximity_depth_tex * 2.0 - 1.0;
#endif
vec4 proximity_view_pos = INV_PROJECTION_MATRIX * vec4(SCREEN_UV * 2.0 - 1.0, proximity_depth_tex, 1.0);But I think the current form is the most explicit and clear about exactly what changes between the renderers.
|
Looks like this runs into the same problem as #97646 (comment) - the preprocessor is not available in BaseMaterial3D. Either that's an engine bug that can be fixed, or this PR is not actually the right approach, and something more like #89966 is right. |
|
Instead of using the preprocessor, you can do the |
Yeah, the hope was to avoid that, so that the material is correct in multiple renderers even after being converted to a ShaderMaterial. The superseded PR already takes a similar approach with conditionally added C++, and was apparently deferred for a while in the hope that we could use the preprocessor somehow instead. |
|
@tetrapod00 You can use |
|
Superseded by #111437 |
Fixes #89942.
Supersedes #89966.
Uses the correct NDC for the Compatibility renderer.
Uses the preprocessor defines for the current renderer introduced in 4.4 in #98549. We also document a nearly identical reconstruction of world space using NDC in this tutorial, which now uses the preprocessor defines to be renderer-independent.