Search Issue Tracker
By Design
Votes
0
Found in
2018.4
Issue ID
1178172
Regression
No
Shadow map size calculation is broken
The documentation says that, for directional lights, the calculated resolution is clamped to 2K and then scaled in function of the Quality settings. The problem is that those operations are not done in this order, the scale is done before the clamping.
Code from Runtime/Camera/Shadows.cpp, in function CalculateShadowMapSize:
{
int viewSize = int(std::max(cullData.viewWidth, cullData.viewHeight));
mapSize = NextPowerOfTwo(int(viewSize * kMultDir));
mapSize >>= qualityShift;
}
const int maxShadowSize = GetMaxShadowMapSize(kLightDirectional, customResolution, qualityShift);
mapSize = clamp<int>(mapSize, 32, maxShadowSize);
On iPhone Xs, for example, the resolution is high and the mapSize is 16384. The qualityShift is 3 when shadow resolution is set to low, so the mapSize end up being 2048 and the maxShadowSize is also 2048. The clamp does nothing and the size is always 2K!
Also note that even if the clamping was done before the shift, the end result would be wrong because the shift is 3 and that means a division by 8. The documentation says that resolution on low is a quarter of maxShadowSize so the shift should be 2.
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
- Articulation Body with 'Revolute' Joint Type has erratic behavior when Upper Limit is set to above 360
- WebGL Player fails to render Scene when Terrain with Detail Mesh is added and WebGPU Graphics API is used
- Inconsistent errors are logged when different types are passed into the Query "Q<>" method in UIToolkit and the ancestor VisualElement is null
- Crash on GetMaterialPropertyByIndex when opening a specific Scene
- Discrepancies in the styling are present when using a TSS file instead of a USS file in custom EditorWindow
Resolution Note:
This issue has been identified as having low priority and has been closed without a fix. If the bug has no workaround and is blocking your production please feel free to reopen it with any additional information you might have. Sorry for the inconvenience this might cause.