Details
-
User Story
-
Resolution: Unresolved
-
P1: Critical
-
None
-
6.8
-
None
-
3400bd701 (dev)
Description
There are several areas that could use some modernization in the shadow mapping in Qt Quick 3D: Certain artifacts due to the optimized but imperfect algorithm + missing support for things like cascading shadow maps, which makes directional lights work poorly for larger scenes.
It would be sensible to go through this topic from the ground up and refactor, implement new techniques, and raise the quality of the shadow mapping everywhere we can.
The plan is to change the current shadow-mapping approach using a texture or cubemap per light to instead use texture arrays. One for directional lights and one for point lights and spot lights. This should increase performance and make it easier to implement cascading shadow maps for directional lights which is also a part of this task. Fix the "soft shadow" bug where objects further apart have darker shadow than objects closer. We will also improve our soft shadow edges by implementing VSM (Variance shadow maps) or similar. While doing this we should also improve our shadow mapping debug tools.
Below is an outline of what should be done and an approximate order of doing it.
□ Debugging:
- Add manual test scene for adding lights
- DebugView: draw directional light bounding box in scene
- DebugView: add drawing of shadowmap
□ Fix "soft shadow" bug (QTBUG-119622) while also adding VSM or similar PCF.
□ Texture arrays for all lights:
- Rework DirectionalLight to use texture array. https://codereview.qt-project.org/c/qt/qtquick3d/+/547094
- Rework Point-light to use texture array and polar coordinates. Low prio.
- Rework Spotlight to not use cube map https://codereview.qt-project.org/c/qt/qtquick3d/+/547462
□ Improve documentation. We should have a "shadows" topic in QQ3D describing how our shadow mapping works covering positives/negatives, depth bias, vsm, light bleed etc.
□ Make DirectionalLight use Cascading shadow maps https://codereview.qt-project.org/c/qt/qtquick3d/+/557566
□ Make all new exposed required properties work in QDS
Optional/nice to have:
* Add soft/hard shadows property
* DebugView: overlay boundingbox on shadowmap
* Shadow draw distance property
* default/dynamic shadow bias values (as described in learnopengl/shadowmapping shadow acne issue)
Attachments
Issue Links
- covers
-
QTBUG-124796 QT quick 3d physics- Cannon example- shadow flickering
- Reported
- relates to
-
QTBUG-119622 Shadows are not working correctly
- In Progress
-
QTBUG-112846 Shadow artifacts
- Closed
-
QTBUG-82333 Support Cascading Shadow Maps for Directional Lights
- In Progress
Gerrit Reviews
For Gerrit Dashboard: QTBUG-116885 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
547094,16 | Use texture arrays for directional lights | dev | qt/qtquick3d | Status: NEW | 0 | 0 |
547462,11 | Rework spotlight to use single depth map instead of cubemap | dev | qt/qtquick3d | Status: NEW | 0 | 0 |
557566,11 | Implement Cascading Shadow Maps (CSM) | dev | qt/qtquick3d | Status: NEW | 0 | 0 |
558887,5 | Refactor shadow shader data | dev | qt/qtquick3d | Status: NEW | 0 | -1 |