Skip to content

fix(shadows): don't apply hardware depth bias to PCSS shadows#8942

Merged
mvaligursky merged 1 commit into
mainfrom
mv-pcss-shadow-bias-fix
Jun 22, 2026
Merged

fix(shadows): don't apply hardware depth bias to PCSS shadows#8942
mvaligursky merged 1 commit into
mainfrom
mv-pcss-shadow-bias-fix

Conversation

@mvaligursky

Copy link
Copy Markdown
Contributor

PCSS shadows store depth in a color buffer and apply their bias in the shader, so the hardware polygon-offset depth bias is a no-op for PCSS on WebGL2 but is applied inconsistently on WebGPU (the backends use different shadow depth-buffer formats). On WebGPU this over-biased PCSS shadows, peter-panning valid self-shadows away (e.g. a large terrain casting onto itself).

Changes:

  • _updateShadowBias now skips the hardware depth bias for PCSS shadows of any light type (in addition to the existing non-clustered omni case). The bias is still applied for hardware-compare PCF shadows.
  • The bias is refreshed when the shadow type changes, so switching to/from PCSS updates it.

Behavior:

  • PCSS shadows now render consistently between WebGL2 and WebGPU. PCF and VSM are unchanged.

PCSS shadows store depth in a color buffer and bias in the shader, so the hardware polygon-offset bias is a no-op for PCSS on WebGL2 but is applied inconsistently on WebGPU (the backends use different shadow depth-buffer formats), over-biasing and peter-panning valid self-shadows. Skip the hardware depth bias for PCSS of any light type (PCF still uses it), and refresh it when the shadow type changes.
@github-actions

Copy link
Copy Markdown

Build size report

This PR changes the size of the minified bundles.

Bundle Minified Gzip Brotli
playcanvas.min.js 2282.7 KB (+0.0 KB, +0.00%) 585.5 KB (+0.0 KB, +0.00%) 455.2 KB (−0.1 KB, −0.02%)
playcanvas.min.mjs 2280.1 KB (+0.0 KB, +0.00%) 584.7 KB (+0.0 KB, +0.00%) 454.6 KB (−0.0 KB, −0.00%)

@mvaligursky mvaligursky merged commit bed51d7 into main Jun 22, 2026
10 checks passed
@mvaligursky mvaligursky deleted the mv-pcss-shadow-bias-fix branch June 22, 2026 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant