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
- GC.Alloc called by HDRenderPipeline.LensFlareMergeOcclusionDataDrivenPass() when playing the default HDRP Sample Template project
- Automatic LOD fails and SRP Batcher incompatibility occurs when using spline-based quad-topology meshes
- Editor crashes on D3D12GetInterface when repeatedly enabling and disabling 256 text components
- Flickering bright white dots in the Scene when the Android Platform is selected and DX11 Graphics API is used with Iris(R) Xe Graphics GPU
- Inconsistent capitalization and misaligned text in multiple query blocks in Search window
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.