Skip to content

viewer: expose snapshot render channels - #644

Open
thomas-yanxin wants to merge 1 commit into
pascalorg:mainfrom
thomas-yanxin:codex/snapshot-capture-channels
Open

viewer: expose snapshot render channels#644
thomas-yanxin wants to merge 1 commit into
pascalorg:mainfrom
thomas-yanxin:codex/snapshot-capture-channels

Conversation

@thomas-yanxin

@thomas-yanxin thomas-yanxin commented Aug 13, 2026

Copy link
Copy Markdown

What does this PR do?

Adds a backward-compatible captureChannels() API to the viewer snapshot pipeline. It returns same-camera color, albedo, view-normal, and linear camera-range depth captures for visual evidence and diagnostic consumers.

  • Reuses the existing scene MRT; the scene geometry is still rendered once.
  • Creates albedo/depth conversion pipelines and targets lazily, so existing capture() calls pay no extra resource cost.
  • Keeps display color as WebP and encodes the three data views losslessly as PNG.
  • Leaves the existing capture() API and output behavior unchanged.

How to test

  1. Run bun check.
  2. Run bun run check-types.
  3. Run bun run test.
  4. Start bun dev and confirm the editor and IFC routes load.

Additional browser smoke coverage rendered a lit box and floor through the WebGL fallback, then verified all four captures share dimensions, have the declared MIME types, and contain non-empty, visually distinct color/albedo/normal/depth data.

Screenshots / screen recording

No UI changes. The browser smoke test visually verified aligned color, unlit albedo, packed view-normal, and linear depth outputs.

Checklist

  • I've tested this locally with bun dev
  • My code follows the existing code style (run bun check to verify)
  • I've documented the public channel semantics inline
  • This PR targets the main branch

Note

Medium Risk
Touches GPU render targets, MRT readback, and WebGPU/WebGL pixel paths, but existing capture() callers are unchanged and new resources are lazy.

Overview
Adds captureChannels() on the snapshot pipeline so consumers can get color, albedo, view-normal, and linear depth from the same camera in one call, alongside unchanged capture() (still WebP display color only).

Channel metadata is exported (SNAPSHOT_CHANNELS, per-channel MIME: WebP for color, PNG for data buffers). Pixel readback, crop/resize, and WebGPU vs WebGL2 row handling are centralized in readCapture, reused by both APIs. Albedo and depth use lazy extra render pipelines/targets; capture() alone does not allocate them until captureChannels() runs.

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

@thomas-yanxin
thomas-yanxin marked this pull request as ready for review August 13, 2026 22:36
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