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
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.
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Out-of-bounds memory access with multiple CanvasRenderers under a Canvas when using Mesh API
- Inspector tries to access file after it was deleted when the file was locked in Inspector window
- Changing Transform values in Search window Inspector loses focus while dragging and stopping mouse without releasing dragging action
- Saving changes on the dirty VFX Graph during the Play mode throws "The referenced script (Unknown) on this Behaviour is missing!" warnings
- VFX Graph Debug Info overlaps the "Initialize" block debug info by default
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.