Closed
Description
Description
- Directional light shadow maps have quality pretty heavily bound by the ratio of shadow map texels to screen fragments.
- If the relative resolution of the directional light shadow map is low, then its texels cover multiple screen fragments when they are viewed using the light's projection. This means that multiple screen fragments read from the same shadow map texel which results in aliasing.
- Using a large shadow map texture is both expensive to process and uses a lot of VRAM
- In order to have a ratio of shadow map texels to screen fragments approaching 1:1 to get good visual quality when fragments are close to the camera, the ratio then becomes very large for fragments further away from the camera which means that a lot of VRAM has to be wasted to achieve good visual quality close to the camera.
Solution
- Cascaded shadow maps - split the depth range over which shadows are visible into overlapping slices (cascades) with orthographic projections fit to cover the depth slice, with a far plane at least behind all visible geometry and a near plane ideally slightly closer to the light than the geometry that is closest to the light. When sampling fragments that fall in regions covered by two cascades, use a weighted blend of shadow samples from both cascades to transition smoothly from one to the next in order to minimise visible artifacts as the ratio of shadow map texels to screen fragments changes.
- https://github.com/superdump/bevy/tree/cascade-shadow-maps
- An implementation of the above that fits the cascade projections only to the visible geometry, and not also the near plane to the geometry that is not visible, but that is closer to the light source than the visible geometry.
Next Steps
- Rebase the branch
- Implement proper shadow projection fitting as documented in Foundations of Game Engine Development 2: Rendering by Eric Lengyel, which is a reference book I have been using for much of the frustum culling and some of the shadow mapping that I've implemented so far.
- Make a PR
Metadata
Metadata
Assignees
Type
Projects
Status
Done