Merge pull request #99220 from Flarkk/fix_sss_reverse_z

Fix regression in SSS with reverse-z
This commit is contained in:
Thaddeus Crews 2024-11-27 10:46:56 -06:00
commit c58ae91efa
No known key found for this signature in database
GPG Key ID: 62181B86FE9E5D84

View File

@ -152,10 +152,10 @@ void main() {
float depth_scale;
if (params.orthogonal) {
depth = ((depth + (params.camera_z_far + params.camera_z_near) / (params.camera_z_far - params.camera_z_near)) * (params.camera_z_far - params.camera_z_near)) / 2.0;
depth = -(depth * (params.camera_z_far - params.camera_z_near) - (params.camera_z_far + params.camera_z_near)) / 2.0;
depth_scale = params.unit_size; //remember depth is negative by default in OpenGL
} else {
depth = 2.0 * params.camera_z_near * params.camera_z_far / (params.camera_z_far + params.camera_z_near - depth * (params.camera_z_far - params.camera_z_near));
depth = 2.0 * params.camera_z_near * params.camera_z_far / (params.camera_z_far + params.camera_z_near + depth * (params.camera_z_far - params.camera_z_near));
depth_scale = params.unit_size / depth; //remember depth is negative by default in OpenGL
}