XRWebGLLayerInit.ignoreDepthValues - Web APIs 编辑
Secure context
This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
The XRWebGLLayerInit
dictionary's Boolean ignoreDepthValues
property can be provided in the options passed into the XRWebGLLayer()
constructor to indicate that the depth buffer, if it exists, should be ignored while composing the scene.
The depth buffer is typically used to assist in ordering vertices and, by extension, polygons while compositing, to ensure that the scene is correctly composited, with objects the correct distance away and with clipping and other distance-related computations performed as accurately as possible. Without the depth buffer, these computations must rely entirely on the coordinates of each pixel.
This property differs from depth
in that depth
requests a WebGL layer that does not have a depth buffer at all, while ignoreDepthValues
merely asks that the depth layer be ignored.
Syntax
let layerInit = { ignoreDepthValues: boolValue }; let glLayer = new XRWebGLLayer(xrSession, gl, layerInit); let glLayer = new XRWebGLLayer(xrSession, gl, { ignoreDepthValues: boolValue });
Value
A Boolean value which can be set to true
to disable the use of the depth buffer by the WebGL rendering layer created by the XRWebGLLayer()
constructor. The default value, false
, means the depth buffer will be used, if available.
Usage notes
If ignoreDepthValues
is true
, the WebXR compositor will ignore the contents of the depth buffer, if it exists, while compositing and rendering the scene. If false
, the depth buffer's contents are used, if one is present.
Using a depth buffer while compositing allows the XR compositor to help ensure the compositing is done as accurately as possible. Each entry in the depth buffer corresponds to the depth of the fragment whose color is at the same location in the color buffer, and must have a value between 0.0 and 1.0, where 0.0 corresponds to the distance specified in the XRSession
object's renderState
record's depthNear
and 1.0 represents the distance given by depthFar
.
Ignoring depth values causes the compositor to rely solely upon the relative position of objects to establish depth, and may result in less effective and less comfortable 3D effects. The default is false
(depth values are used by default).
Example
In this example, a new XRWebGLLayer
is created for a WebXR session, xrSession
. It's configured to ignore depth values or an alpha channel.
xrSession.updateRenderState({
baseLayer: new XRWebGLLayer(xrSession, gl, {
alpha: false,
ignoredepthValues: true
});
});
Specifications
Specification | Status | Comment |
---|---|---|
WebXR Device API The definition of 'XRWebGLLayerInit.ignoreDepthValues' in that specification. | Working Draft | Initial definition. |
Browser compatibility
BCD tables only load in the browser
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论