Search Issue Tracker

By Design

Votes

0

Found in

2018.4

Issue ID

1178172

Regression

No

Shadow map size calculation is broken

Graphics - General

-

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.

  1. 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.

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.