playcanvas / playcanvas/engine
Improvements to PCSS shadow sampling
Open
@mvaligursky is already working on this.
Since Dec 23, 2024.
area: graphics
enhancement
- Dominant language
- JavaScript
- Stars
- 16.8k
- Forks
- 2k
- Avg merge
- 4h 32m
- Merged PRs (30d)
- 222
Description
Related to PCSS implementation: https://github.com/playcanvas/engine/pull/5483
- consider what needs to be done with the hardcoded constant here: https://github.com/playcanvas/engine/pull/5483#discussion_r1264179036 DONE https://github.com/playcanvas/engine/pull/7258
- the implementation uses hardcoded 16 samples
#define PCSS_SAMPLE_COUNT 16- perhaps add some control over this DONE https://github.com/playcanvas/engine/pull/7258 - Make compatible with WebGPU, at least for directional lights. WebGPU only supports clustered lights currently, so other lights won't work unless PCSS is supported by clustered lights. DONE https://github.com/playcanvas/engine/pull/7258
- R32F texture is used to store shadow depth map. We need a fallback for platforms that do not support it, perhaps the same as RenderPassPrepass uses, which stores the depth float bits in RGBA8, which then SSAO decodes back to float. DONE - added F32->F16->PCF3 fallback here: https://github.com/playcanvas/engine/pull/7258/commits/3b1e69f7ab283cb1d21eaaca6c9a09f94a9069fb
- adjust omni and spot PCSS code to work as well as directional updated in #7258
- add sample randomization to allow smaller number of samples when TAA is enabled
- We currently render to F32 texture + depth buffer, but only use the F32 texture. For directional lights (and eventually for all types) we store non-linear depth, meaning the color buffer contains the same data as depth buffer. On WebGPU, we should be able to avoid using color buffer entirely, and simply use depth buffer only - as long as we can load a single sample from it.
- WebGPU supports textureGather - we could try and use this, maybe for blocker search, bug definitely for PCF filtering part of PCSS, to get more samples for "free". We could add this to current GLSL shader and confirm the transpilation handles this, or wait for time when internal shaders are written in WGSL directly, and add it then.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.