You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[WebGPU-XR][Phase 3] Range-correct XR projection matrix for half-Z (WebGPU) engines
On a WebGPU engine (isNDCHalfZRange === true) the clip-space depth range is
[0, 1], while WebGL/OpenGL uses [-1, 1]. WebXRCamera copies the XR binding's
projection matrix verbatim and the rig cameras freeze their projection, so the
engine's range-aware projection builders are bypassed. If the binding returns a
[-1, 1]-convention matrix while the engine clips at [0, 1], every fragment with
NDC z in [-1, 0) is clipped and all world geometry disappears (clear color still
shows) - matching the in-headset "meshes flash a frame then vanish" symptom.
Fix (WebGPU-gated, WebGL2 byte-identical, zero net public API):
- Add @internal Matrix.convertProjectionToHalfZRangeInPlace(), reusing the
engine's existing mtxConvertNDCToHalfZRange remap (the same conversion the
perspective/orthographic builders apply when halfZRange is set).
- In WebXRCamera._updateFromXRSession, on a half-Z engine, empirically detect the
convention the binding used (project the view-space near point through the raw
matrix: NDC z ~= -1 => [-1, 1], ~= 0 => [0, 1]) and convert only a [-1, 1]
matrix, so a spec-compliant [0, 1] binding is never double-converted. Guards
minZ <= 0 (avoids divide-by-zero) and assumes non-reverse-Z. WebGL2
(isNDCHalfZRange === false) never enters the block.
Adds 6 unit tests: [-1,1]->[0,1] conversion, [0,1] left unchanged, WebGL2
byte-identical, asymmetric off-center frusta, minZ<=0 guard, and converter
equivalence to the engine's half-Z builder.
Refs #18639
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
0 commit comments