XRWebGLSubImage: depthStencilTexture 属性
XRWebGLSubImage
接口的只读 depthStencilTexture
属性表示要呈现的 XRCompositionLayer
的深度/模板 WebGLTexture
对象。
值
一个不透明的 WebGLTexture
。有关详细信息,请参阅 WebXR 不透明纹理。
使用 depthStencilTexture
depthStencilTexture
属性可以传递给 WebGL2RenderingContext.framebufferTextureLayer()
,以将深度纹理附加到帧缓冲区。
js
const xrGlBinding = new XRWebGLBinding(xrSession, gl);
const layer = xrGlBinding.createProjectionLayer({
textureType: "texture-array",
});
const framebuffer = gl.createFramebuffer();
xrSession.updateRenderState({ layers: [layer] });
xrSession.requestAnimationFrame(onXRFrame);
function onXRFrame(time, xrFrame) {
xrSession.requestAnimationFrame(onXRFrame);
gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
const viewport = xrGlBinding.getSubImage(layer, xrFrame).viewport;
gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);
for (const view in xrViewerPose.views) {
const subImage = xrGlBinding.getViewSubImage(layer, view);
gl.framebufferTextureLayer(
gl.FRAMEBUFFER,
gl.COLOR_ATTACHMENT0,
subImage.colorTexture,
0,
subImage.imageIndex,
);
gl.framebufferTextureLayer(
gl.FRAMEBUFFER,
gl.DEPTH_ATTACHMENT,
subImage.depthStencilTexture,
0,
subImage.imageIndex,
);
// Render from the viewpoint of xrView
}
}
规范
规范 |
---|
WebXR 层 API 级别 1 # dom-xrwebglsubimage-depthstenciltexture |
浏览器兼容性
BCD 表格仅在浏览器中加载