Skip to content

fix(core): keep shadow maps bound in passes without the LightingEffect (4/5) - #10903

Closed
charlieforward9 wants to merge 18 commits into
masterfrom
fix/shadow-module-keep-bindings
Closed

charlieforward9 wants to merge 18 commits into
masterfrom
fix/shadow-module-keep-bindings

Conversation

@charlieforward9

@charlieforward9 charlieforward9 commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Closes #10902. Part 4 of 5 of the shadow fixes; parts 1–3 (#10892, #10891, #10893) have merged, and #10913 follows. Introduced by #10187.

Since #10187, passes give every default shader module empty props when their effects don't supply any. LightingEffect sits out of picking, so under a _shadow light the shadow module returns undefined shadow-map bindings during picking. luma.gl then skips every pick draw, and no layer can be picked.

Change List

  • createShadowUniforms: return no bindings when there is no dummy shadow map
    • Passes without the LightingEffect keep the maps already bound; useShadowMap is false there, so nothing samples them
  • Unit tests
    • Deck#picking under a shadow light fails on master

This also keeps layers drawing when a shadow light is switched off (#10888's path); #10891 releases the shadow resources in that case. Verified with the core shaderlib/shadow, effects, passes, deck, deck-picker and pick-layers tests, test/modules/extensions, and the effects and terrain-layer render tests.

charlieforward9 and others added 7 commits October 22, 2026 07:02
… off

EffectManager reuses the existing LightingEffect and calls setProps when
a new one is passed. Turning the last `_shadow` light off kept the
shadow module registered as a default module, but getShaderModuleProps
stopped passing the dummy shadow map, so shadow_uShadowMap0/1 were
unbound and every layer skipped drawing. Call cleanup() from setProps
when no light casts shadows, so layers are rebuilt without the module.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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 <[email protected]>
getViewProjectionMatrices fitted the light frustum to the points where the
viewport corner rays hit the ground. With the default fov, the top corners
reach the horizon at pitch ~71.6. Just below it the hits are far beyond the
camera's far plane (light frustum 20 x 28 km at pitch 72, 63 m texels).
Above it they are behind the camera, so the shadow map no longer covers the
visible scene. Shadows disappear, and fragments past the light frustum's far
plane are always shadowed (black areas).

Fit the light frustum to the view frustum clipped to z >= 0 instead: the
frustum corners above the ground plus the points where frustum edges cross
the ground. When every corner ray hits the ground before the far plane, this
gives the same points as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
#10187 gives every default shader module empty props in passes whose
effects don't supply them, so that their getUniforms always runs. The
LightingEffect sits out of picking, so with a `_shadow` light the shadow
module's getUniforms({}) returned `shadow_uShadowMap0/1: undefined` there.
luma.gl merged that over the bound shadow maps and skipped every draw with
a missing texture binding: nothing could be picked, for any layer.

createShadowUniforms now returns the dummy-map bindings only when it has a
dummy map, so a pass without the effect keeps the maps already bound
(`useShadowMap` is false, so nothing samples them).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@greptile-apps

greptile-apps Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues remain.

Summary

Keeps shadow-map bindings unchanged when a pass leaves out LightingEffect, while turning shadow drawing and sampling off.

  • Picking still works when a shadow light is on.

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

Comment thread test/modules/core/lib/deck.spec.ts Resolved
@coveralls

coveralls commented Oct 23, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 84.377% (+0.02%) from 84.362% — fix/shadow-module-keep-bindings into master

charlieforward9 and others added 6 commits October 23, 2026 10:24
# Conflicts:
#	test/modules/core/passes/shadow-pass.spec.ts
#	test/render/test-cases/effects.spec.ts
…-high-pitch

# Conflicts:
#	test/render/test-cases/effects.spec.ts
…eep-bindings

# Conflicts:
#	test/modules/core/shaderlib/shadow/shadow.spec.ts
If pickObject throws or the assertion fails, the test rejected without
finalizing the Deck, leaving its animation loop and GPU resources alive on
the shared device for later tests.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@charlieforward9 charlieforward9 changed the title fix(core): keep shadow maps bound in passes without the LightingEffect fix(core): keep shadow maps bound in passes without the LightingEffect (4/5) Oct 26, 2026
@charlieforward9
charlieforward9 changed the base branch from master to fix/shadow-frustum-high-pitch October 26, 2026 04:00
Base automatically changed from fix/shadow-frustum-high-pitch to master October 26, 2026 04:55
# Conflicts:
#	test/modules/core/shaderlib/shadow/shadow.spec.ts

@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 current head. CI passes and the existing review thread is resolved. I found no remaining blocker; this looks ready for approval.

@charlieforward9

Copy link
Copy Markdown
Member Author

Closing as superseded by #11109, which fixes #10902 at its source: LightingEffect now supplies its shadow props in picking, and the terrain passes forward the effects, so the shadow maps stay bound in those draws.

@chrisgervang chrisgervang mentioned this pull request Nov 24, 2026
29 tasks
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] A _shadow light makes every layer unpickable

4 participants