Visitar URL original
fix(core): draw the shadow map without per-layer polygon offset (1/5) by charlieforward9 · Pull Request #10892 · visgl/deck.gl · GitHub
Skip to content

fix(core): draw the shadow map without per-layer polygon offset (1/5) - #10892

Merged
charlieforward9 merged 3 commits into
masterfrom
fix/shadow-pass-polygon-offset
Oct 26, 2026
Merged

charlieforward9 merged 3 commits into
masterfrom
fix/shadow-pass-polygon-offset

Conversation

@charlieforward9

@charlieforward9 charlieforward9 commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

Closes #10889. Part 1 of 5 of the shadow fixes; #10890 has merged.

The per-layer polygon offset (getPolygonOffset) is also applied when drawing the shadow map. Each later layer stores a depth closer to the light and shadows itself. ShadowPass now draws the shadow map without the offset.

Change List

  • ShadowPass.getLayerParameters: set depthBias: 0
  • Unit tests
  • Render test shadow-effect-layer-index with new golden image

Eight flat layers. Left: master. Middle: master with getPolygonOffset: null. Right: this PR.

shadow-polygon-offset-before-after

The new tests fail on master.

Shadow fixes

Each part touches the shadow module, LightingEffect, or the effects render tests, so they merge in this order:

  1. fix(core): draw the shadow map without per-layer polygon offset (1/5) #10892 Draw the shadow map without per-layer polygon offset
  2. fix(core): release shadow resources when LightingEffect turns shadows off (2/5) #10891 Release shadow resources when shadows turn off
  3. fix(core): fit the shadow map to the visible frustum at high pitch (3/5) #10893 Fit the shadow map to the visible view at high pitch
  4. fix(core): keep shadow maps bound in passes without the LightingEffect (4/5) #10903 Keep shadow maps bound during picking
  5. feat(core): fit shadow maps to DirectionalLight _shadowBounds (5/5) #10913 Fit shadow maps to DirectionalLight _shadowBounds

Layer._drawLayer applies `getPolygonOffset` (default [0, -layerIndex * 100])
in every pass. The shadow map stores gl_FragCoord.z, which includes the
offset, so the k-th layer drawn in the shadow pass stored a depth
k * 100 * 2^-16 closer to the light. From the third layer on, layers fell
partly or fully into their own shadow. ShadowPass now sets depthBias: 0
so the shadow map is drawn without the offset.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking issues were found.

Summary

ShadowPass now sets depthBias to zero when drawing the shadow map.

  • Shadow maps draw layers without their polygon offset.

No actionable issues were found. Tests were not run. The golden image could not be visually inspected because image input is unavailable.

Reviews (3) · Last reviewed commit: "Merge branch 'master' into fix/shadow-pa..." · Reviewed by Greptile

@coveralls

coveralls commented Oct 22, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 84.151% (-0.006%) from 84.157% — fix/shadow-pass-polygon-offset into master

@ibgreen ibgreen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed; the per-layer depth-bias fix is ready to approve.

# Conflicts:
#	test/modules/core/passes/shadow-pass.spec.ts
#	test/render/test-cases/effects.spec.ts
@charlieforward9 charlieforward9 changed the title fix(core): draw the shadow map without per-layer polygon offset fix(core): draw the shadow map without per-layer polygon offset (1/5) Oct 26, 2026
@charlieforward9
charlieforward9 merged commit 324350c into master Oct 26, 2026
8 checks passed
@charlieforward9
charlieforward9 deleted the fix/shadow-pass-polygon-offset branch October 26, 2026 04:26
chrisgervang pushed a commit that referenced this pull request Oct 26, 2026
Layer._drawLayer applies `getPolygonOffset` (default [0, -layerIndex * 100])
in every pass. The shadow map stores gl_FragCoord.z, which includes the
offset, so the k-th layer drawn in the shadow pass stored a depth
k * 100 * 2^-16 closer to the light. From the third layer on, layers fell
partly or fully into their own shadow. ShadowPass now sets depthBias: 0
so the shadow map is drawn without the offset.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 324350c)
@chrisgervang

Copy link
Copy Markdown
Collaborator

Released in deck.gl 9.4.1. Thanks @charlieforward9!

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.

[Bug] Shadows get darker with each additional layer (getPolygonOffset applies in the shadow pass)

4 participants