Skip to content

fix: bind shadow resources in picking and terrain passes - #11109

Open
charlieforward9 wants to merge 3 commits into
masterfrom
codex/shadow-auxiliary-passes
Open

charlieforward9 wants to merge 3 commits into
masterfrom
codex/shadow-auxiliary-passes

Conversation

@charlieforward9

@charlieforward9 charlieforward9 commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Background

A shadow light installs a shader plugin used by every draw. Picking, label collision, and terrain height-map passes can leave its samplers unbound, causing missing draws.

Change List

  • Provide shadow bindings during picking without rerendering shadow maps
  • Report shadow pre-render stats for collision filtering
  • Forward other effects to the terrain height-map pass
  • Verified with lint and 16 focused WebGL tests

Note

Low Risk
Low risk fix ensuring existing shadow map bindings are supplied to auxiliary render passes without modifying core rendering behavior.

Overview
Ensures LightingEffect supplies required shadow map texture bindings during picking, collision, and terrain height-map passes.

LightingEffect now marks itself active for picking passes (useInPicking = true) without redundantly re-rendering shadow maps, and returns its render status from preRender. In addition, TerrainEffect and TerrainPass now forward active effects to the height-map pass instead of clearing them, preventing unbound shadow samplers during terrain draws.

Reviewed by Cursor Bugbot for commit bb09a44. Bugbot is set up for automated code reviews on this repo. Configure here.

@coveralls

coveralls commented Nov 13, 2026 •

Copy link
Copy Markdown

Coverage Status

coverage: 83.362% (+0.03%) from 83.328% — codex/shadow-auxiliary-passes into master

@charlieforward9
charlieforward9 marked this pull request as ready for review November 13, 2026 22:42
@greptile-apps

greptile-apps Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

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

Summary

Supplies shadow textures to picking, collision, and terrain height-map draws.

  • Picking and collision draws keep their shadow-map bindings.
  • Terrain height-map draws keep bindings from other effects.

The previous, unnumbered test-coverage finding is addressed. No new actionable issues were found.

Reviews (4) · Last reviewed commit: "test: release the shadow test WebGL cont..." · Reviewed by Greptile

@athomct athomct left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Reviewed at bb09a44.

This PR makes a shadow light safe for the passes that do not render shadows. LightingEffect now sets useInPicking, skips the shadow-map render when isPicking is true, and returns {didRender: true} so that CollisionFilterEffect forwards it to the collision pass. TerrainPass.renderHeightMap now keeps the other effects instead of effects: []. The fix works. I reproduced the bug on current master (0741d21) with a small user-facing probe: with a shadow DirectionalLight, pickObject on a plain ScatterplotLayer returns null. Without the shadow, or with this PR, it returns the layer. I ran the two PR test files in headless Chromium on WebGL at the PR head (8 passed). Then I merged the PR into master and ran them with the nearby tests (core effects, collision filter, terrain, pick-layers). All pass: 52 passed and 31 skipped on WebGL, and 62 passed and 2 skipped for the terrain tests on WebGPU. The new terrain test fails on master source (terrain height map draws with both samplers: expected false to be true). The shadow shader module has GLSL only, so I tested the shadow paths on WebGL only. I also did a mutation check. These mutations each make the PR tests fail: remove useInPicking, remove return {didRender: true}, put back effects: [] in renderHeightMap, or remove the isPicking guard. Thank you for the focused test.

Findings

  1. should-fix — test/modules/core/effects/lighting-effect.spec.ts:5-6
    The branch does not merge with current master. Master added an AmbientLight import on the same lines (#11171). The conflict is only in the imports.
    Suggested change: rebase and keep both imports:

    import {test, expect, vi} from 'vitest';
    import {AmbientLight, LightingEffect} from '@deck.gl/core';

    With this change, all the tests above pass on the merged tree.

  2. nit — modules/extensions/src/terrain/terrain-effect.ts:164
    No test covers the effect !== this filter. When I removed it, the full suite stayed green. Today it is harmless, because the shader module binds the dummy height map in WRITE_HEIGHT_MAP mode. But a reader cannot see why the filter is there.
    Suggested change: add a one-line comment, like the one in preRender for the cover pass. For example: "Do not bind the height map while this pass writes it."

Verdict

Approve, after the rebase in finding 1. The fix is small and correct, and the tests guard each part of it.

Probe test
import {expect, test} from 'vitest';
import {Deck, DirectionalLight, LightingEffect} from '@deck.gl/core';
import {ScatterplotLayer} from '@deck.gl/layers';

async function pickCenter(shadow: boolean) {
  let resolveFrame: () => void;
  const frame = new Promise<void>(resolve => (resolveFrame = resolve));
  let gl: WebGL2RenderingContext | undefined;
  const deck = new Deck({
    width: 128,
    height: 128,
    useDevicePixels: false,
    initialViewState: {longitude: 0, latitude: 0, zoom: 12},
    layers: [
      new ScatterplotLayer({
        id: 'point',
        data: [[0, 0]],
        getPosition: p => p,
        radiusUnits: 'pixels',
        getRadius: 10,
        pickable: true
      })
    ],
    effects: [
      new LightingEffect({light: new DirectionalLight({direction: [1, 1, -1], _shadow: shadow})})
    ],
    onAfterRender: ({gl: context}) => {
      gl = context;
      resolveFrame();
    }
  });
  try {
    await frame;
    return deck.pickObject({x: 64, y: 64})?.layer?.id ?? null;
  } finally {
    deck.finalize();
    gl?.getExtension('WEBGL_lose_context')?.loseContext();
  }
}

// master: withoutShadow=point, withShadow=null. This PR: both are 'point'.
test('a shadow light does not break picking', async () => {
  expect(await pickCenter(false)).toBe('point');
  expect(await pickCenter(true)).toBe('point');
});

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants