Use correct ndc equation in Compatibility refraction

This commit is contained in:
Kaleb Reid 2025-10-04 02:03:31 -07:00
parent 06827c91c6
commit 96ca7a205d

View file

@ -1813,7 +1813,8 @@ void fragment() {)";
float ref_amount = 1.0 - albedo.a * albedo_tex.a;
float refraction_depth_tex = textureLod(depth_texture, ref_ofs, 0.0).r;
vec4 refraction_view_pos = INV_PROJECTION_MATRIX * vec4(SCREEN_UV * 2.0 - 1.0, refraction_depth_tex, 1.0);
vec4 ndc = OUTPUT_IS_SRGB ? vec4(vec3(SCREEN_UV, refraction_depth_tex) * 2.0 - 1.0, 1.0) : vec4(SCREEN_UV * 2.0 - 1.0, refraction_depth_tex, 1.0);
vec4 refraction_view_pos = INV_PROJECTION_MATRIX * ndc;
refraction_view_pos.xyz /= refraction_view_pos.w;
// If the depth buffer is lower then the model's Z position, use the refracted UV, otherwise use the normal screen UV.