summaryrefslogtreecommitdiffstats
path: root/servers
diff options
context:
space:
mode:
authorThaddeus Crews <repiteo@outlook.com>2024-11-27 10:46:56 -0600
committerThaddeus Crews <repiteo@outlook.com>2024-11-27 10:46:56 -0600
commitc58ae91efaaf593f1cfa38e9ee557203a8531c48 (patch)
treeb827a9cffeeae2eda046a7fc1aa6b23491881ad7 /servers
parent2a147f3ce12ee44d783c7a17a70c184e86c205b7 (diff)
parent3376b9166baa238309d0f30a59b45677296ab27e (diff)
downloadredot-engine-c58ae91efaaf593f1cfa38e9ee557203a8531c48.tar.gz
Merge pull request #99220 from Flarkk/fix_sss_reverse_z
Fix regression in SSS with reverse-z
Diffstat (limited to 'servers')
-rw-r--r--servers/rendering/renderer_rd/shaders/effects/subsurface_scattering.glsl4
1 files changed, 2 insertions, 2 deletions
diff --git a/servers/rendering/renderer_rd/shaders/effects/subsurface_scattering.glsl b/servers/rendering/renderer_rd/shaders/effects/subsurface_scattering.glsl
index fb35d3cde6..553637dc4f 100644
--- a/servers/rendering/renderer_rd/shaders/effects/subsurface_scattering.glsl
+++ b/servers/rendering/renderer_rd/shaders/effects/subsurface_scattering.glsl
@@ -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
}