summaryrefslogtreecommitdiffstats
path: root/servers
diff options
context:
space:
mode:
authorFlorent Guiocheau <florent.guiocheau@gmail.com>2024-11-13 13:57:41 +0100
committerFlorent Guiocheau <florent.guiocheau@gmail.com>2024-11-26 10:51:22 +0100
commit3376b9166baa238309d0f30a59b45677296ab27e (patch)
tree1f439c1161c68b4c2a135d71f0f3e47a07b77a5e /servers
parent3dbef70d17377b5364802554a2ee4d791c9d5b74 (diff)
downloadredot-engine-3376b9166baa238309d0f30a59b45677296ab27e.tar.gz
Fix 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
}