viewer: expose snapshot render channels - #644
Conversation
|
Thanks for this, and welcome — the MRT reuse here is the right instinct. Sampling I'm going to close this one, for reasons that are about the shape of the change rather than your execution. The main one: nothing in the codebase consumes these channels. The only callers of the snapshot pipeline are The cost side is what makes it a close rather than a hold: the diff moves 124 lines of the existing capture path into Three specific things, in case this comes back:
Also worth saying: this and #646 are two independent takes on overlapping scope, from the same base, with different API shapes and opposite depth encodings (linear near-black here, inverted near-white there). Only one could ever land. I'll reply on #646 with where I'd go if we do this. Genuinely glad you're poking at the render pipeline — it's the least-explored corner of the viewer. If you want a channel export that lands, the path is a consumer first. |
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.capture()calls pay no extra resource cost.capture()API and output behavior unchanged.How to test
bun check.bun run check-types.bun run test.bun devand 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
bun devbun checkto verify)mainbranchNote
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 unchangedcapture()(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 inreadCapture, reused by both APIs. Albedo and depth use lazy extra render pipelines/targets;capture()alone does not allocate them untilcaptureChannels()runs.Reviewed by Cursor Bugbot for commit b72d31c. Bugbot is set up for automated code reviews on this repo. Configure here.