XRWebGLDepthInformation: texture 属性
只读 texture 属性是 XRWebGLDepthInformation 接口的一个属性,它是一个 WebGLTexture,包含作为不透明纹理的深度缓冲区信息。
值
一个 WebGLTexture。
示例
使用 XRWebGLBinding.getDepthInformation() 来获取 GPU 深度信息。返回的 XRWebGLDepthInformation 对象将包含 texture 缓冲区,然后可以将其绑定到纹理,并将深度缓冲区信息提供给 WebGL 片段着色器。
js
const depthInfo = glBinding.getDepthInformation(view);
const uvTransform = depthInfo.normDepthBufferFromNormView.matrix;
const u_DepthTextureLocation = gl.getUniformLocation(program, "u_DepthTexture");
const u_UVTransformLocation = gl.getUniformLocation(program, "u_UVTransform");
const u_RawValueToMeters = gl.getUniformLocation(program, "u_RawValueToMeters");
gl.bindTexture(gl.TEXTURE_2D, depthInfo.texture);
gl.activeTexture(gl.TEXTURE0);
gl.uniform1i(u_DepthTextureLocation, 0);
// UV transform to correctly index into the depth map
gl.uniformMatrix4fv(u_UVTransformLocation, false, uvTransform);
// scaling factor to convert from the raw number to meters
gl.uniform1f(u_RawValueToMeters, depthInfo.rawValueToMeters);
规范
| 规范 |
|---|
| WebXR Depth Sensing 模块 # dom-xrwebgldepthinformation-texture |
浏览器兼容性
加载中…