Skip to content

WebGPU lightmapper support for shadow casting local lights and omni shadow shader cleanup#8338

Merged
mvaligursky merged 1 commit intomainfrom
mv-lightmapper-webgpu-local-lights
Jan 7, 2026
Merged

WebGPU lightmapper support for shadow casting local lights and omni shadow shader cleanup#8338
mvaligursky merged 1 commit intomainfrom
mv-lightmapper-webgpu-local-lights

Conversation

@mvaligursky
Copy link
Contributor

@mvaligursky mvaligursky commented Jan 6, 2026

Summary

Enables lightmapper to work correctly on WebGPU with shadow casting omni/spot lights and cleans up shadow shader handling for omni lights by properly separating shadow coordinate calculation based on light type.

Changes

Lightmapper WebGPU Support

  • Unified WebGL and WebGPU rendering paths to both use render passes, and this adds support for local lights on WebGPU
  • Non-clustered shadow rendering now uses RenderPassShadowLocalNonClustered instead of deprecated shadowRenderer.render()

Dead Code Removal

renderer.js

  • Removed setCamera() and clearView() methods (only used by old lightmapper path)

shadow-renderer.js

  • Removed render() method (replaced by render passes)
  • Removed insideRenderPass parameter from renderFace() - now always assumes inside render pass

Shader Cleanup - Omni Shadow Matrix

Omni lights use cubemap shadows that sample by direction, not matrix transformation. The shadowMatrix uniform was incorrectly handled.

lightFunctionShadow.js (GLSL & WGSL)

  • Added getShadowSampleCoordOmni{i}() - dedicated function for omni lights without shadowMatrix parameter
  • getShadowSampleCoord{i}() now only handles directional/spot lights
  • getShadow{i}() dispatches to appropriate function based on light type

lightDeclaration.js (GLSL & WGSL)

  • Shadow section: Skip declaring shadowMatrix for omni lights (not used)
  • Cookie section (GLSL only): Always declare shadowMatrix for omni cookies (needed for cube orientation)

Example Updates

lights-baked.example.mjs

  • Update to be easily tell if something does not work, which was not possible with the original random positioning
  • Added orbit camera with controls
  • Added visual representations for lights (emissive sphere/cone/cylinder)
  • Added UI controls for toggling lights and soft shadows
  • Objects arranged in deterministic 8x8 grid
Screenshot 2026-01-06 at 11 39 40

@mvaligursky mvaligursky self-assigned this Jan 6, 2026
@mvaligursky mvaligursky added enhancement Request for a new feature area: graphics Graphics related issue area: examples labels Jan 6, 2026
@mvaligursky mvaligursky requested a review from a team January 6, 2026 11:41
),
jsx(
LabelGroup,
{ text: ' 🟡 Soft' },
Copy link
Contributor

Choose a reason for hiding this comment

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

What're the additional spaces at the start of the label for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it was supposed to be indented .. as it applies to directional light only, but it didn't work :)

window.focus();

const assets = {
script: new pc.Asset('script', 'script', { url: `${rootPath}/static/scripts/camera/orbit-camera.js` })
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you use camera-controls.mjs (as I do in the new annotations example)?

Copy link
Contributor

@willeastcott willeastcott left a comment

Choose a reason for hiding this comment

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

Nice!

@mvaligursky mvaligursky merged commit d7eda36 into main Jan 7, 2026
7 checks passed
@mvaligursky mvaligursky deleted the mv-lightmapper-webgpu-local-lights branch January 7, 2026 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: examples area: graphics Graphics related issue enhancement Request for a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants