Fix directional shadow alignment across backends
This commit is contained in:
@@ -41,15 +41,15 @@ float ComputeShadowAttenuation(vec3 positionWS) {
|
||||
vec3 shadowNdc = shadowClip.xyz / shadowClip.w;
|
||||
vec2 shadowUv = vec2(
|
||||
shadowNdc.x * 0.5 + 0.5,
|
||||
shadowNdc.y * -0.5 + 0.5);
|
||||
shadowNdc.y * 0.5 + 0.5);
|
||||
if (shadowUv.x < 0.0 || shadowUv.x > 1.0 ||
|
||||
shadowUv.y < 0.0 || shadowUv.y > 1.0 ||
|
||||
shadowNdc.z < 0.0 || shadowNdc.z > 1.0) {
|
||||
shadowNdc.z < -1.0 || shadowNdc.z > 1.0) {
|
||||
return 1.0;
|
||||
}
|
||||
|
||||
float shadowDepth = texture(uShadowMapTexture, shadowUv).r;
|
||||
float receiverDepth = shadowNdc.z - gShadowBiasAndTexelSize.x;
|
||||
float receiverDepth = shadowNdc.z * 0.5 + 0.5 - gShadowBiasAndTexelSize.x;
|
||||
float shadowStrength = clamp(gShadowBiasAndTexelSize.w, 0.0, 1.0);
|
||||
return receiverDepth <= shadowDepth ? 1.0 : (1.0 - shadowStrength);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user