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

SpecificationStatusComment
WebXR Device API
The definition of 'XRWebGLLayerInit.ignoreDepthValues' in that specification.
Working DraftInitial definition.

Browser compatibility

BCD tables only load in the browser

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:46 次

字数:5078

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文