|
|
@@ -264,6 +264,7 @@ class WebGLBackend extends Backend {
|
|
|
this.extensions.get( 'WEBGL_multisampled_render_to_texture' );
|
|
|
this.extensions.get( 'WEBGL_render_shared_exponent' );
|
|
|
this.extensions.get( 'WEBGL_multi_draw' );
|
|
|
+ this.extensions.get( 'OVR_multiview2' );
|
|
|
|
|
|
this.disjoint = this.extensions.get( 'EXT_disjoint_timer_query_webgl2' );
|
|
|
this.parallel = this.extensions.get( 'KHR_parallel_shader_compile' );
|
|
|
@@ -360,7 +361,7 @@ class WebGLBackend extends Backend {
|
|
|
|
|
|
// The multisample_render_to_texture extension doesn't work properly if there
|
|
|
// are midframe flushes and an external depth texture.
|
|
|
- if ( ( this.extensions.has( 'WEBGL_multisampled_render_to_texture' ) === true ) && renderTarget.autoAllocateDepthBuffer ) {
|
|
|
+ if ( ( this.extensions.has( 'WEBGL_multisampled_render_to_texture' ) === true ) && renderTarget.autoAllocateDepthBuffer === true && renderTarget.multiview === false ) {
|
|
|
|
|
|
console.warn( 'THREE.WebGLBackend: Render-to-texture extension was disabled because an external texture was provided' );
|
|
|
|
|
|
@@ -547,7 +548,7 @@ class WebGLBackend extends Backend {
|
|
|
|
|
|
const { samples } = renderContext.renderTarget;
|
|
|
|
|
|
- if ( samples > 0 && this._useMultisampledRTT( renderContext.renderTarget ) === false ) {
|
|
|
+ if ( samples > 0 && this._useMultisampledExtension( renderContext.renderTarget ) === false ) {
|
|
|
|
|
|
const fb = renderTargetContextData.framebuffers[ renderContext.getCacheKey() ];
|
|
|
|
|
|
@@ -1142,7 +1143,7 @@ class WebGLBackend extends Backend {
|
|
|
|
|
|
};
|
|
|
|
|
|
- if ( renderObject.camera.isArrayCamera && renderObject.camera.cameras.length > 0 ) {
|
|
|
+ if ( renderObject.camera.isArrayCamera === true && renderObject.camera.cameras.length > 0 && renderObject.camera.isMultiViewCamera === false ) {
|
|
|
|
|
|
const cameraData = this.get( renderObject.camera );
|
|
|
const cameras = renderObject.camera.cameras;
|
|
|
@@ -1998,8 +1999,8 @@ class WebGLBackend extends Backend {
|
|
|
let msaaFb = renderTargetContextData.msaaFrameBuffer;
|
|
|
let depthRenderbuffer = renderTargetContextData.depthRenderbuffer;
|
|
|
const multisampledRTTExt = this.extensions.get( 'WEBGL_multisampled_render_to_texture' );
|
|
|
- const useMultisampledRTT = this._useMultisampledRTT( renderTarget );
|
|
|
-
|
|
|
+ const multiviewExt = this.extensions.get( 'OVR_multiview2' );
|
|
|
+ const useMultisampledRTT = this._useMultisampledExtension( renderTarget );
|
|
|
const cacheKey = getCacheKey( descriptor );
|
|
|
|
|
|
let fb;
|
|
|
@@ -2061,7 +2062,11 @@ class WebGLBackend extends Backend {
|
|
|
|
|
|
} else {
|
|
|
|
|
|
- if ( hasExternalTextures && useMultisampledRTT ) {
|
|
|
+ if ( renderTarget.multiview ) {
|
|
|
+
|
|
|
+ multiviewExt.framebufferTextureMultisampleMultiviewOVR( gl.FRAMEBUFFER, attachment, textureData.textureGPU, 0, samples, 0, 2 );
|
|
|
+
|
|
|
+ } else if ( hasExternalTextures && useMultisampledRTT ) {
|
|
|
|
|
|
multisampledRTTExt.framebufferTexture2DMultisampleEXT( gl.FRAMEBUFFER, attachment, gl.TEXTURE_2D, textureData.textureGPU, 0, samples );
|
|
|
|
|
|
@@ -2094,7 +2099,11 @@ class WebGLBackend extends Backend {
|
|
|
textureData.renderTarget = descriptor.renderTarget;
|
|
|
textureData.cacheKey = cacheKey; // required for copyTextureToTexture()
|
|
|
|
|
|
- if ( hasExternalTextures && useMultisampledRTT ) {
|
|
|
+ if ( renderTarget.multiview ) {
|
|
|
+
|
|
|
+ multiviewExt.framebufferTextureMultisampleMultiviewOVR( gl.FRAMEBUFFER, depthStyle, textureData.textureGPU, 0, samples, 0, 2 );
|
|
|
+
|
|
|
+ } else if ( hasExternalTextures && useMultisampledRTT ) {
|
|
|
|
|
|
multisampledRTTExt.framebufferTexture2DMultisampleEXT( gl.FRAMEBUFFER, depthStyle, gl.TEXTURE_2D, textureData.textureGPU, 0, samples );
|
|
|
|
|
|
@@ -2106,7 +2115,6 @@ class WebGLBackend extends Backend {
|
|
|
|
|
|
gl.framebufferTextureLayer( gl.FRAMEBUFFER, depthStyle, textureData.textureGPU, 0, layer );
|
|
|
|
|
|
-
|
|
|
} else {
|
|
|
|
|
|
gl.framebufferTexture2D( gl.FRAMEBUFFER, depthStyle, gl.TEXTURE_2D, textureData.textureGPU, 0 );
|
|
|
@@ -2143,7 +2151,7 @@ class WebGLBackend extends Backend {
|
|
|
|
|
|
// rebind external XR textures
|
|
|
|
|
|
- if ( isXRRenderTarget && hasExternalTextures ) {
|
|
|
+ if ( ( isXRRenderTarget && hasExternalTextures ) || renderTarget.multiview ) {
|
|
|
|
|
|
state.bindFramebuffer( gl.FRAMEBUFFER, fb );
|
|
|
|
|
|
@@ -2151,7 +2159,11 @@ class WebGLBackend extends Backend {
|
|
|
|
|
|
const textureData = this.get( descriptor.textures[ 0 ] );
|
|
|
|
|
|
- if ( useMultisampledRTT ) {
|
|
|
+ if ( renderTarget.multiview ) {
|
|
|
+
|
|
|
+ multiviewExt.framebufferTextureMultisampleMultiviewOVR( gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, textureData.textureGPU, 0, samples, 0, 2 );
|
|
|
+
|
|
|
+ } else if ( useMultisampledRTT ) {
|
|
|
|
|
|
multisampledRTTExt.framebufferTexture2DMultisampleEXT( gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, textureData.textureGPU, 0, samples );
|
|
|
|
|
|
@@ -2175,7 +2187,11 @@ class WebGLBackend extends Backend {
|
|
|
|
|
|
const textureData = this.get( descriptor.depthTexture );
|
|
|
|
|
|
- if ( useMultisampledRTT ) {
|
|
|
+ if ( renderTarget.multiview ) {
|
|
|
+
|
|
|
+ multiviewExt.framebufferTextureMultisampleMultiviewOVR( gl.FRAMEBUFFER, depthStyle, textureData.textureGPU, 0, samples, 0, 2 );
|
|
|
+
|
|
|
+ } else if ( useMultisampledRTT ) {
|
|
|
|
|
|
multisampledRTTExt.framebufferTexture2DMultisampleEXT( gl.FRAMEBUFFER, depthStyle, gl.TEXTURE_2D, textureData.textureGPU, 0, samples );
|
|
|
|
|
|
@@ -2191,7 +2207,7 @@ class WebGLBackend extends Backend {
|
|
|
|
|
|
}
|
|
|
|
|
|
- if ( samples > 0 && useMultisampledRTT === false ) {
|
|
|
+ if ( samples > 0 && useMultisampledRTT === false && ! renderTarget.multiview ) {
|
|
|
|
|
|
if ( msaaFb === undefined ) {
|
|
|
|
|
|
@@ -2484,7 +2500,13 @@ class WebGLBackend extends Backend {
|
|
|
* @param {RenderTarget} renderTarget - The render target that should be multisampled.
|
|
|
* @return {boolean} Whether to use the `WEBGL_multisampled_render_to_texture` extension for MSAA or not.
|
|
|
*/
|
|
|
- _useMultisampledRTT( renderTarget ) {
|
|
|
+ _useMultisampledExtension( renderTarget ) {
|
|
|
+
|
|
|
+ if ( renderTarget.multiview === true ) {
|
|
|
+
|
|
|
+ return true;
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
return renderTarget.samples > 0 && this.extensions.has( 'WEBGL_multisampled_render_to_texture' ) === true && renderTarget.autoAllocateDepthBuffer !== false;
|
|
|
|