@@ -276,20 +276,28 @@ SHADOW_TYPE EvaluateShadow_Directional( LightLoopContext lightLoopContext, Posit
276
276
}
277
277
else if (shadowSplitIndex == int (_CascadeShadowCount) - 1 )
278
278
{
279
- // float fade = lightLoopContext.shadowContext.fade;
280
- float3 camToPixel = posInput.positionWS - GetPrimaryCameraPosition ();
281
- float distanceCamToPixel2 = dot (camToPixel, camToPixel);
282
-
283
- HDDirectionalShadowData dsd = lightLoopContext.shadowContext.directionalShadowData;
284
- float fade = saturate (distanceCamToPixel2 * dsd.fadeScale + dsd.fadeBias);
279
+ float fade = lightLoopContext.shadowContext.fade;
285
280
// In the transition code (both dithering and blend) we use shadow = lerp( shadow, 1.0, fade ) for last transition
286
281
// mean if we expend the code we have (shadow * (1 - fade) + fade). Here to make transition with shadow mask
287
282
// we will remove fade and add fade * shadowMask which mean we do a lerp with shadow mask
288
283
shadow = shadow - fade + fade * shadowMask;
289
284
}
290
285
291
286
// See comment in EvaluateBSDF_Punctual
292
- shadow = light.nonLightMappedOnly ? min (shadowMask, shadow) : shadow;
287
+ if (light.nonLightMappedOnly)
288
+ {
289
+ shadow = min (shadowMask, shadow);
290
+ }
291
+ else
292
+ {
293
+ // Use shadowmask when shadow value cannot be retrieved due to shadow caster culling.
294
+ float3 camToPixel = posInput.positionWS - GetPrimaryCameraPosition ();
295
+ float distanceCamToPixel2 = dot (camToPixel, camToPixel);
296
+
297
+ HDDirectionalShadowData dsd = lightLoopContext.shadowContext.directionalShadowData;
298
+ float alpha = saturate (distanceCamToPixel2 * dsd.fadeScale + dsd.fadeBias);
299
+ shadow = min (shadow, lerp (1.0 , shadowMask, alpha * alpha));
300
+ }
293
301
#endif
294
302
295
303
shadow = lerp (shadowMask.SHADOW_TYPE_REPLICATE, shadow, light.shadowDimmer);
0 commit comments