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
- "Shader warning in 'Hidden/Light2D': implicit truncation of vector type" is thrown when building Universal 2D template
- AI Assistant breaks compilation of packages using System.Runtime.CompilerServices.Unsafe via auto-referencing
- Unity Hub checks the "Documentation" module by default on the 6.4 and 6.5 streams despite that it was unchecked with the previous installs
- Shortcut that toggles between Dopesheet and Curves Views in the Animation Window's Timeline is mislabed
- Property List Items Overlap onto the Property List's top edge when scrolling through a long Property List
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.