diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2019-10-16 19:53:19 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2019-10-16 19:58:20 +0300 |
commit | 131ac2ec82b9e810dd6e0153009a71276b6d6f13 (patch) | |
tree | d96401e740a40d9caab5baa3b61092c2a908ea78 /source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl | |
parent | 4ddf3215a7df3ac4a0cfceccb283414510078ba5 (diff) |
Fix T70249 EEVEE: Light bleeding on SSS translucency
This was caused by 2 things: Shadow map bias and aliasing.
It made the expected depth of the shadowmap further than the surface
itself in some cases. In normal time this leads to light leaking on normal
shadow mapping but here we need to always have the shadowmap depth above
the shading point.
To fix this, we use a 5 tap inflate filter using the minimum depth of all
5 samples. Using these 5 taps, we can deduce entrance surface derivatives
and there orientation towards the light ray. We use these derivatives to
bias the depth to avoid wrong depth at depth discontinuity in the shadowmap.
This bias can lead to some shadowleaks that are less distracting than the
lightleaks it fixes.
We also add a small bias to counteract the shadowmap depth precision.
Diffstat (limited to 'source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl')
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl index 1f68935403c..511c243b474 100644 --- a/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl @@ -140,6 +140,10 @@ float min_v3(vec3 v) { return min(v.x, min(v.y, v.z)); } +float min_v4(vec4 v) +{ + return min(min(v.x, v.y), min(v.z, v.w)); +} float max_v2(vec2 v) { return max(v.x, v.y); @@ -148,6 +152,10 @@ float max_v3(vec3 v) { return max(v.x, max(v.y, v.z)); } +float max_v4(vec4 v) +{ + return max(max(v.x, v.y), max(v.z, v.w)); +} float sum(vec2 v) { |