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
This commit is contained in:
2020-02-24 10:46:45 +01:00
parent f2b95b9eae
commit 403bb357ae
2 changed files with 5 additions and 2 deletions

View File

@@ -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;
}

View File

@@ -164,6 +164,7 @@ uniform mat4 ModelMatrixInverse;
#define normal_object_to_world(n) (transpose(mat3(ModelMatrixInverse)) * n)
#define normal_world_to_object(n) (transpose(mat3(ModelMatrix)) * n)
#define normal_world_to_view(n) (mat3(ViewMatrix) * n)
#define normal_view_to_world(n) (mat3(ViewMatrixInverse) * n)
#define point_object_to_ndc(p) (ViewProjectionMatrix * vec4((ModelMatrix * vec4(p, 1.0)).xyz, 1.0))
#define point_object_to_view(p) ((ViewMatrix * vec4((ModelMatrix * vec4(p, 1.0)).xyz, 1.0)).xyz)