OVR_multiview2
扩展属于
WebGL API
and adds support for rendering into multiple views simultaneously. This especially useful for virtual reality (VR) and WebXR.
For more information, see also:
WebGL extensions are available using the
WebGLRenderingContext.getExtension()
method. For more information, see also
使用扩展
在
WebGL 教程
.
可用性: Support depends on the system's graphics driver (Windows+ANGLE and Android are supported; Windows+GL, Mac, Linux are not supported).
This extension is only available to
WebGL 2
contexts as it needs GLSL 3.00 and texture arrays.
Currently, there is no way to use multiview to render to a multisampled backbuffer, so you should create contexts with
antialias: false
. However, the Oculus browser (6+) also supports multisampling using the
OCULUS_multiview
extension. See also
this WebGL issue
.
This extension exposes 4 constants that can be used in
getParameter()
or
getFramebufferAttachmentParameter()
.
FRAMEBUFFER_ATTACHMENT_TEXTURE_NUM_VIEWS_OVR
Number of views of the framebuffer object attachment.
FRAMEBUFFER_ATTACHMENT_TEXTURE_BASE_VIEW_INDEX_OVR
Base view index of the framebuffer object attachment.
MAX_VIEWS_OVR
The maximum number of views. Most VR headsets have two views, but there are prototypes of headset with ultra-wide FOV using 4 views which is currently the maximum number of views supported by multiview.
FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR
FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE
不是
NONE
, the framebuffer is considered incomplete. Calling
checkFramebufferStatus
for a framebuffer in this state returns
FRAMEBUFFER_INCOMPLETE_VIEW_TARGETS_OVR
.
framebufferTextureMultiviewOVR()
Simultaneously renders to multiple elements of a 2D texture array.
This example is taken from the specification . See also this three.js demo for a live multiview example.
const gl = document.createElement('canvas').getContext( 'webgl2', { antialias: false } );
const ext = gl.getExtension('OVR_multiview2');
const fb = gl.createFramebuffer();
gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, fb);
const colorTex = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D_ARRAY, colorTex);
gl.texStorage3D(gl.TEXTURE_2D_ARRAY, 1, gl.RGBA8, 512, 512, 2);
ext.framebufferTextureMultiviewOVR(gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, colorTex, 0, 0, 2);
const depthStencilTex = gl.createTexture();
gl.bindTexture(gl.TEXTURE_2D_ARRAY, depthStencilTex);
gl.texStorage3D(gl.TEXTURE_2D_ARRAY, 1, gl.DEPTH32F_STENCIL8, 512, 512, 2);
ext.framebufferTextureMultiviewOVR(gl.DRAW_FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, depthStencilTex, 0, 0, 2);
gl.drawElements(...); // draw will be broadcasted to the layers of colorTex and depthStencilTex.
Shader code
#version 300 es
#extension GL_OVR_multiview2 : require
precision mediump float;
layout (num_views = 2) in;
in vec4 inPos;
uniform mat4 u_viewMatrices[2];
void main() {
gl_Position = u_viewMatrices[gl_ViewID_OVR] * inPos;
}
| 规范 | 状态 |
|---|---|
| OVR_multiview2 | Community Approved |
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
更新 GitHub 上的兼容性数据| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
OVR_multiview2
|
Chrome
75
Alternate Name
|
Edge
79
Alternate Name
|
Firefox 71 | IE No | Opera No | Safari No |
WebView Android
75
Alternate Name
|
Chrome Android
75
Alternate Name
|
Firefox Android No | Opera Android No | Safari iOS No |
Samsung Internet Android
11.0
Alternate Name
|
framebufferTextureMultiviewOVR
|
Chrome
75
|
Edge 79 | Firefox 71 | IE No | Opera No | Safari No |
WebView Android
75
|
Chrome Android
75
|
Firefox Android No | Opera Android No | Safari iOS No |
Samsung Internet Android
11.0
|
完整支持
不支持
使用非标名称。
WebGLRenderingContext.getExtension()
WebGLRenderingContext.getParameter()
OVR_multiview2
ANGLE_instanced_arrays
EXT_blend_minmax
EXT_color_buffer_half_float
EXT_disjoint_timer_query
EXT_frag_depth
EXT_sRGB
EXT_shader_texture_lod
EXT_texture_filter_anisotropic
OES_element_index_uint
OES_standard_derivatives
OES_texture_float
OES_texture_float_linear
OES_texture_half_float
OES_texture_half_float_linear
OES_vertex_array_object
WEBGL_color_buffer_float
WEBGL_compressed_texture_atc
WEBGL_compressed_texture_etc1
WEBGL_compressed_texture_pvrtc
WEBGL_compressed_texture_s3tc
WEBGL_compressed_texture_s3tc_srgb
WEBGL_debug_renderer_info
WEBGL_debug_shaders
WEBGL_depth_texture
WEBGL_draw_buffers
WEBGL_lose_context
WebGL2RenderingContext
WebGLActiveInfo
WebGLBuffer
WebGLContextEvent
WebGLFramebuffer
WebGLObject
WebGLProgram
WebGLQuery
WebGLRenderbuffer
WebGLRenderingContext
WebGLSampler
WebGLShader
WebGLShaderPrecisionFormat
WebGLSync
WebGLTexture
WebGLTransformFeedback
WebGLUniformLocation
WebGLVertexArrayObject