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
- Animator state transition preview clips are flickering when zooming in
- [Tile Palette] Sprites not rendering when brush tool "Paint a filled box with active brush" is used for the first time
- Adding available Nodes with longer names in Fragment Context window overflow Fragment Context window in Shader Graph
- "Layer Palette Profile" Asset is automatically applied to the second Terrain but doesn't load any layers
- "Terrain Tools" shortcut conflicts with the Overlays shortcut by default
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.