Search Issue Tracker

By Design

Votes

0

Found in

2017.4.0f1

2018.3.0a1

2018.3.1f1

2019.1.0a1

2019.2.0a1

Issue ID

1117801

Regression

No

Shader that uses "AutoLight.cginc" draws shadow on fully illuminated GameObjects when using No Shadow Cascades option

Shaders

-

How to reproduce:
1. Open the minirepro project attached by QA in comment
2. Open the scene "ShadowBug"
3. Make sure that Project settings > Quality > Shadow Cascades are set to "No Cascades"
4. Double click on the "Main Camera" GameObject
5. Try to zoom in and out to the Plane direction in the Scene View

Expected Behavior: No shadows on the Plane appear, because the light illuminates it fully
Actual Behavior: The shadow appears and moves along with the Camera

Reproducible with: 2017.4.18f1, 2018.3.2f1, 2019.1.0a14, 2019.2.0a1

Note: The issue is reproduced only at a specific distance from the object. Setting Shadow Cascades to two or four eliminates the shadow.

  1. Resolution Note:

    User's shader needs to take Shadow Distance value into account so that the shadow will not render when the pixel is outside of Shadow Distance (distance from camera). To do this, do these in fragment shader instead of just doing SHADOW_ATTENUATION:

    float zDist = dot(_WorldSpaceCameraPos - i.worldPos, UNITY_MATRIX_V[2].xyz);
    float fadeDist = UnityComputeShadowFadeDistance(i.worldPos, zDist);
    half shadowFade = UnityComputeShadowFade(fadeDist);
    float shadow = saturate (lerp (SHADOW_ATTENUATION(i), 1.0, shadowFade ) );

    You can also find the code in AutoLight.cginc.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.