feat(rendering)!: expose a render target's depth as a sampleable texture - #749
Conversation
…n and device loss
…aspect it now carries
… every frame and on a multi-attachment target
Bundle ReportChanges will decrease total bundle size by 19.65MB (-37.57%) ⬇️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: exo-full-iife-Exo-iifeAssets Changed:
Files in
view changes for bundle: exo-esm-esmAssets Changed:
Files in
view changes for bundle: exo-full-iife-min-Exo-iifeAssets Changed:
Files in
view changes for bundle: site-server-esmAssets Changed:
App Routes Affected:
view changes for bundle: exo-esm-modules-esmAssets Changed:
Files in
Files in
Files in
Files in
Files in
Files in
Files in
Files in
Files in
Files in
Files in
Files in
Files in
Files in
view changes for bundle: exo-iife-min-Exo-iifeAssets Changed:
Files in
view changes for bundle: exo-iife-Exo-iifeAssets Changed:
Files in
|
Depth as a data source, without a depth test: a render target can keep the depth its draws produce and hand it to a later pass as a texture, for fog, depth of field or a screen-space occlusion term. Visibility keeps coming from draw order.
RenderTextureandMultiRenderTargettakedepth: trueand then own one sampleable depth attachment, resized and destroyed with the target and exposed astarget.depthTexture(DepthTexture, fixed nearest and clamp-to-edge,nullon the root target and on any target without the opt-in; aMultiRenderTargetowns exactly one, not one per attachment). Writing is opt-in per material:MeshMaterialconstructed withwritesDepth: truewrites the clip-space z its vertex stage produces, with depth compare fixed to always. A depth texture binds as a named texture of a customMeshMaterialorSpriteMaterialonly; a drawable's own texture, a filter input and the built-in renderers expect a colour format, which the JSDoc and the guide state.Both backends share one combined depth-stencil attachment with the stencil clipper, so a clipped target pays nothing extra. WebGL2 attaches a
DEPTH24_STENCIL8texture in place of the renderbuffer and raises the depth mask only around a depth-writing mesh draw. WebGPU owns a per-target attachment with a depth-only view for sampling; a depth-writing batch runs in its own render pass, the depth aspect is cleared whenever the target's colour is cleared, and a throw between begin and end of the depth scope restores the coordinator throughtry/finally. Pipelines gained a depth-mode cache dimension so a target with and without depth never share one. The stored value is each backend's window-space mapping; ordering is the portable contract and both docs say so.Tests: unit coverage of the option plumbing, resize, destroy and the pipeline key; browser readback in both lanes (two quads at different z, the depth sampled into a colour target: near below far below untouched); a conformance-kit scenario that fails when a binding leaves depth writes on; the coordinator's two-frame clear behaviour. API reference regenerated, guide section added. Marked breaking because the pass-coordinator contract a third-party backend implements gains members.