diff options
author | Jeroen Bakker <jeroen@blender.org> | 2020-02-24 12:46:45 +0300 |
---|---|---|
committer | Jeroen Bakker <jeroen@blender.org> | 2020-02-27 17:57:58 +0300 |
commit | 403bb357ae2b1d2561a0d77c96035ba54c197cbd (patch) | |
tree | 140f9338c9a662467969e186145019f52df9a549 /source/blender/draw/engines | |
parent | f2b95b9eae2ee913c99cff7595527b18d8b49d0a (diff) |
Fix T74110: EEVEE Shadow Pass
Shadow could penetrate occluded geometry. This patch adds a check to see
if the light is in the right location to light the pixel.
Reviewed By: fclem
Differential Revision: https://developer.blender.org/D6918
Diffstat (limited to 'source/blender/draw/engines')
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/shadow_accum_frag.glsl | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/shadow_accum_frag.glsl b/source/blender/draw/engines/eevee/shaders/shadow_accum_frag.glsl index fa02bee45b7..fe6a828f369 100644 --- a/source/blender/draw/engines/eevee/shaders/shadow_accum_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/shadow_accum_frag.glsl @@ -19,7 +19,7 @@ void main() float depth = texelFetch(depthBuffer, texel, 0).r; if (depth == 1.0f) { /* Early exit background does not receive shadows */ - fragColor.r = 1.0; + fragColor.r = 0.0; return; } @@ -40,6 +40,7 @@ void main() vec3 worldPosition = transform_point(ViewMatrixInverse, viewPosition); vec3 true_normal = normalize(cross(dFdx(viewPosition), dFdy(viewPosition))); + vec3 N = normal_view_to_world(true_normal); for (int i = 0; i < MAX_LIGHT && i < laNumLight; i++) { LightData ld = lights_data[i]; @@ -48,8 +49,9 @@ void main() l_vector.xyz = ld.l_position - worldPosition; l_vector.w = length(l_vector.xyz); + float light_input = smoothstep(0.2, -0.2, -dot(N, normalize(l_vector.xyz))); float l_vis = light_shadowing( - ld, worldPosition, viewPosition, tracing_depth, true_normal, rand.x, true, 1.0); + ld, worldPosition, viewPosition, tracing_depth, true_normal, rand.x, true, light_input); accum_light += l_vis; } |