Skip to content

Add scene-color-map to pc-camera - #527

Merged
willeastcott merged 1 commit into
mainfrom
camera-scene-color-map
Oct 1, 2026
Merged

willeastcott merged 1 commit into
mainfrom
camera-scene-color-map

Conversation

@willeastcott

Copy link
Copy Markdown
Contributor

Description

Refractive materials sample the camera's scene color map: a copy of what the camera has drawn before its transparent objects. glTF materials with transmission are among them. Nothing in PWC could ask a camera to render that copy. Debug builds report this in the Car Configurator (the lights lens material) and Vehicle Physics (Warthog_Glass_Mat):

A uSceneColorMap texture is used by the shader but a scene color texture is not available. Use CameraComponent.requestSceneColorMap / enable Color Grabpass on the Camera Component / CameraFrame.rendering.sceneColorMap to enable it.

<pc-camera> now exposes it as the scene-color-map attribute and sceneColorMap property. Both are backed by CameraComponent#renderSceneColorMap, a camera component data property; the Editor's camera exposes it as its color grab pass. The engine's setter holds a single request per component however often it is written, so the element passes the value through like its other properties. It defaults to false, like the engine, because the copy costs a full-screen copy every frame. The name matches the cameraFrame script's rendering.sceneColorMap, which is what a camera rendered through that script uses instead.

<pc-camera scene-color-map></pc-camera>

The examples are unchanged

Turning the attribute on in the two examples removes the debug error, but I measured no visible difference. In same-frame captures with a virtual clock and seeded Math.random, where repeated runs matched pixel for pixel, the mean difference was:

View Mean difference
Car Configurator's default view 0.00
Vehicle Physics' chase view 0.00
Warthog windscreen, seen head-on 0.01

Behind each of these glass surfaces there is little for refraction to change. A per-frame copy with no visible effect is not worth adding to either page. The attribute is there now if a scene needs it.

Testing

  • A scene-color-map row joins the <pc-camera> attribute table. It checks the engine default, setting the attribute in markup, changing it live, and restoring the default on removal.
  • A new test checks the engine's request count: 1 at creation, still 1 after repeated writes, and 0 once the attribute is removed.
  • npm test, npm run lint, npm run type-check and npm run docs pass. After npm run build, custom-elements.json lists scene-color-map with default false.
  • With the attribute set locally on both examples, each camera held exactly one request and had its color grab pass, and the debug engine's uSceneColorMap error was gone.

🤖 Generated with Claude Code

Refractive materials - glTF materials with transmission among them -
sample the camera's scene color map, and nothing in PWC could ask a
camera to render one. Debug builds report "A uSceneColorMap texture
is used by the shader but a scene color texture is not available"
for them, as in the Car Configurator and Vehicle Physics examples.

pc-camera exposes it as the scene-color-map attribute and the
sceneColorMap property, backed by the engine's
CameraComponent#renderSceneColorMap, which holds one request per
component however often it is written. It defaults to false, like the
engine, because the copy costs a full-screen copy every frame.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@willeastcott
willeastcott merged commit 252f001 into main Oct 1, 2026
3 checks passed
@willeastcott
willeastcott deleted the camera-scene-color-map branch October 1, 2026 20:28
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