Create Webgl hierarchical z buffer
The device
The parameter sets the maximum pixel size of the hzb with mipmaps.
One texture per stored mip. WebGL keeps the finest levels outside a single mip chain. WebGPU stores every level on texture and leaves this unset.
When false, update and updateSceneDepth do nothing and testers skip the pyramid.
When false, update and updateSceneDepth do nothing and testers skip the pyramid.
Height of the first stored mip.
Number of stored mips, including the first.
Height of the depth source the pyramid was built from.
Width of the depth source the pyramid was built from.
Pyramid texture: WebGL's first ping-pong target, or the WebGPU mip chain. Null before the first resize.
Scale from screen UV to the first stored mip. Testers multiply the screen rectangle by this before sampling.
Width of the first stored mip.
Pyramid is a color texture.
The packed RGBA8 path stores device Z and is decoded with uint2float.
A depth attachment would return false.
Pyramid texels are R16F. Sampling reads .r.
Pyramid texels are R32F. Sampling reads .r.
Max-downsample the hardware depth grab (requestSceneDepthMap / renderPassDepthGrab)
into the pyramid. Device Z is stored as-is. No-op without a grab texture, or when disabled.
Call after opaque depth.
Same pyramid as update, from camera.sceneDepthMap.
camera.shaderParams selects metres, packed RGBA8, or 1 / viewZ.
The first pass point-samples that encoding into device Z. No-op until the map is published.
Device-Z pyramid built from the camera depth. Testers compare an AABB's closest device Z with the mip that covers its screen rectangle.