|
|
@@ -34554,13 +34554,6 @@ class PassNode extends TempNode {
|
|
|
|
|
|
this.renderTarget.samples = this.options.samples === undefined ? renderer.samples : this.options.samples;
|
|
|
|
|
|
- // TODO: Disable MSAA for WebGL backend for now
|
|
|
- if ( renderer.backend.isWebGLBackend === true ) {
|
|
|
-
|
|
|
- this.renderTarget.samples = 0;
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
this.renderTarget.texture.type = renderer.getColorBufferType();
|
|
|
|
|
|
return this.scope === PassNode.COLOR ? this.getTextureNode() : this.getLinearDepthNode();
|
|
|
@@ -59760,6 +59753,8 @@ class WebGLTextureUtils {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ gl.bindRenderbuffer( gl.RENDERBUFFER, null );
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -61199,15 +61194,40 @@ class WebGLBackend extends Backend {
|
|
|
}
|
|
|
|
|
|
const msaaFrameBuffer = renderTargetContextData.msaaFrameBuffer;
|
|
|
+ const msaaRenderbuffers = renderTargetContextData.msaaRenderbuffers;
|
|
|
|
|
|
const textures = renderContext.textures;
|
|
|
+ const isMRT = textures.length > 1;
|
|
|
|
|
|
state.bindFramebuffer( gl.READ_FRAMEBUFFER, msaaFrameBuffer );
|
|
|
state.bindFramebuffer( gl.DRAW_FRAMEBUFFER, fb );
|
|
|
|
|
|
+ if ( isMRT ) {
|
|
|
+
|
|
|
+ // blitFramebuffer() can only copy/resolve the first color attachment of a framebuffer. When using MRT,
|
|
|
+ // the engine temporarily removes all attachments and then configures each attachment for the resolve.
|
|
|
+
|
|
|
+ for ( let i = 0; i < textures.length; i ++ ) {
|
|
|
+
|
|
|
+ gl.framebufferRenderbuffer( gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT0 + i, gl.RENDERBUFFER, null );
|
|
|
+ gl.framebufferTexture2D( gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0 + i, gl.TEXTURE_2D, null, 0 );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
for ( let i = 0; i < textures.length; i ++ ) {
|
|
|
|
|
|
- // TODO Add support for MRT
|
|
|
+ if ( isMRT ) {
|
|
|
+
|
|
|
+ // configure attachment for resolve
|
|
|
+
|
|
|
+ const { textureGPU } = this.get( textures[ i ] );
|
|
|
+
|
|
|
+ gl.framebufferRenderbuffer( gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, msaaRenderbuffers[ i ] );
|
|
|
+ gl.framebufferTexture2D( gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, textureGPU, 0 );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
if ( renderContext.scissor ) {
|
|
|
|
|
|
@@ -61237,6 +61257,21 @@ class WebGLBackend extends Backend {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ if ( isMRT ) {
|
|
|
+
|
|
|
+ // restore attachments
|
|
|
+
|
|
|
+ for ( let i = 0; i < textures.length; i ++ ) {
|
|
|
+
|
|
|
+ const { textureGPU } = this.get( textures[ i ] );
|
|
|
+
|
|
|
+ gl.framebufferRenderbuffer( gl.READ_FRAMEBUFFER, gl.COLOR_ATTACHMENT0 + i, gl.RENDERBUFFER, msaaRenderbuffers[ i ] );
|
|
|
+ gl.framebufferTexture2D( gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0 + i, gl.TEXTURE_2D, textureGPU, 0 );
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
} else if ( renderTarget.resolveDepthBuffer === false && renderTargetContextData.framebuffers ) {
|
|
|
|
|
|
const fb = renderTargetContextData.framebuffers[ renderContext.getCacheKey() ];
|
|
|
@@ -62731,8 +62766,6 @@ class WebGLBackend extends Backend {
|
|
|
|
|
|
}
|
|
|
|
|
|
- state.drawBuffers( descriptor, fb );
|
|
|
-
|
|
|
}
|
|
|
|
|
|
const depthStyle = stencilBuffer ? gl.DEPTH_STENCIL_ATTACHMENT : gl.DEPTH_ATTACHMENT;
|
|
|
@@ -62907,6 +62940,8 @@ class WebGLBackend extends Backend {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ gl.bindRenderbuffer( gl.RENDERBUFFER, null );
|
|
|
+
|
|
|
renderTargetContextData.msaaFrameBuffer = msaaFb;
|
|
|
renderTargetContextData.msaaRenderbuffers = msaaRenderbuffers;
|
|
|
|
|
|
@@ -62934,6 +62969,8 @@ class WebGLBackend extends Backend {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ state.drawBuffers( descriptor, fb );
|
|
|
+
|
|
|
}
|
|
|
|
|
|
state.bindFramebuffer( gl.FRAMEBUFFER, currentFrameBuffer );
|