ReadonlycpuCamera.fillShaderParams of that same camera.
x is 1 / far, y is far, z is near, w is 1 for an orthographic
camera and 0 for perspective. Same lifetime as cpuViewProjection.
ReadonlycpuView-space Z of the published capture, in metres.
Length is width × height. A publish writes a tightly packed
map of cpuWidth × cpuHeight into the front of the array
and leaves texels past that prefix untouched. Row 0 is the bottom of the screen.
Construct and a packed-size rebuild allocate a new array filled with 1e10.
ReadonlycpuHeight of the published map. See cpuWidth.
When false, capture does not pack or start a readback. frameUpdate still publishes a readback already in flight. Defaults to true.
ReadonlycpuTrue after frameUpdate has published a capture.
False before the first publish, after resize changes the packed
pixel count (maxWidth * maxHeight), and on WebGL after context loss.
A resize that keeps that count leaves a published map ready.
ReadonlycpuBumped when frameUpdate publishes a capture, and when resize
changes the packed pixel count. Changing readbackSlots does not bump it.
The tester recopies cpuDepth when this differs from the copy it
last applied and cpuReady is set.
ReadonlycpuReadonlycpuReadonlydeviceDevice that owns the pack and the readback ring.
When false, capture does nothing. Defaults to true.
ReadonlyheightCap on the packed map height, in texels. The published footprint is cpuHeight.
ReadonlysourceStored HZB level selected by the last capture that took a readback slot.
Stays 0 until then. Level 0 is also a real mip.
ReadonlywidthCap on the packed map width, in texels. The published footprint is cpuWidth.
Select a mip of an already-built pyramid, pack it into the CPU map, and start
an async readback. The selected level is written to sourceMip.
Device Z is linearized in the pack.
No-op when this buffer or the pyramid is disabled, when cpuReadback
is off, or without a pyramid texture. Also no-op when no readback slot is
free, when a readback was already submitted this frame, or on a WebGL tick
that readbackPeriod skips.
Call after hzb.update / hzb.updateSceneDepth, once opaque depth is in the pyramid.
Release GPU resources, readback slots, and device event handlers.
Harvest the newest finished readback whose lag has elapsed into cpuDepth, cpuViewProjection, and cpuCameraParams, then bump cpuVersion. Captures older than that one are dropped unread. Call every frame before tests. Does not start a capture.
Frame delta in seconds. Unused by the harvest itself; kept for the frame callback.
Set the packed-map cap. Omitted sizes keep the current cap.
The readback ring holds maxWidth * maxHeight pixels and is rebuilt only
when that count changes. A same-count change keeps in-flight captures and
the published map. A rebuild drops them: cpuReady becomes false,
cpuVersion increments, and cpuDepth is filled with 1e10.
Screen size belongs to the HZB. A window resize does not call this, so in-flight captures and the published map stay.
OptionalmaxWidth: numberOptionalmaxHeight: number
Packed CPU view-space Z (metres) taken from one mip of a hierarchical Z-buffer. Shared by WebGL (transform feedback / PBO) and WebGPU (compute / mapAsync).
Build the pyramid first (
update/updateSceneDepth), then capture. Each axis picks the stored mip nearest to the buffer's max resolution; the coarser of the two is packed. If that mip's screen footprint, clamped to the max, would still cover three or more source texels per packed pixel, the next coarser mip is used. The CPU map is that footprint rounded to whole texels. Pixelicovers screen UV[i / cpuWidth, (i + 1) / cpuWidth](the same on Y) and reads the HZB texels under that slice. Each packed texel is that device Z, linearized to metres.