Repository navigation
Add scene-color-map to pc-camera - #527
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
lightslens material) and Vehicle Physics (Warthog_Glass_Mat):<pc-camera>now exposes it as thescene-color-mapattribute andsceneColorMapproperty. Both are backed byCameraComponent#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 tofalse, like the engine, because the copy costs a full-screen copy every frame. The name matches thecameraFramescript'srendering.sceneColorMap, which is what a camera rendered through that script uses instead.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: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
scene-color-maprow 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.npm test,npm run lint,npm run type-checkandnpm run docspass. Afternpm run build,custom-elements.jsonlistsscene-color-mapwith defaultfalse.uSceneColorMaperror was gone.🤖 Generated with Claude Code