From b708ed3a116b46666bec92170194ca117a95e16e Mon Sep 17 00:00:00 2001 From: sunag Date: Thu, 13 Nov 2025 16:05:25 -0300 Subject: [PATCH 1/2] set opaque blend mode for secondary MRT targets --- .../webgpu/utils/WebGPUPipelineUtils.js | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/renderers/webgpu/utils/WebGPUPipelineUtils.js b/src/renderers/webgpu/utils/WebGPUPipelineUtils.js index e7569d51123652..330d48cfb15545 100644 --- a/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +++ b/src/renderers/webgpu/utils/WebGPUPipelineUtils.js @@ -152,11 +152,22 @@ class WebGPUPipelineUtils { const colorFormat = utils.getTextureFormatGPU( textures[ i ] ); - targets.push( { - format: colorFormat, - blend: blending, - writeMask: colorWriteMask - } ); + if ( i === 0 ) { + + targets.push( { + format: colorFormat, + blend: blending, + writeMask: colorWriteMask + } ); + + } else { + + targets.push( { + format: colorFormat, + writeMask: colorWriteMask + } ); + + } } From 2664d980df41ee6e5e587bc40c63fc11d4e98399 Mon Sep 17 00:00:00 2001 From: sunag Date: Thu, 13 Nov 2025 16:56:13 -0300 Subject: [PATCH 2/2] add webgl2 fallback --- src/renderers/webgl-fallback/WebGLBackend.js | 7 +++++++ .../webgl-fallback/utils/WebGLState.js | 17 ++++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/renderers/webgl-fallback/WebGLBackend.js b/src/renderers/webgl-fallback/WebGLBackend.js index 9d12ee6f5d15b6..03bf06d182bfd9 100644 --- a/src/renderers/webgl-fallback/WebGLBackend.js +++ b/src/renderers/webgl-fallback/WebGLBackend.js @@ -268,6 +268,7 @@ class WebGLBackend extends Backend { this.disjoint = this.extensions.get( 'EXT_disjoint_timer_query_webgl2' ); this.parallel = this.extensions.get( 'KHR_parallel_shader_compile' ); + this.drawBuffersIndexedExt = this.extensions.get( 'OES_draw_buffers_indexed' ); } @@ -957,6 +958,12 @@ class WebGLBackend extends Backend { state.setMaterial( material, frontFaceCW, hardwareClippingPlanes ); + if ( context.textures !== null && context.textures.length > 1 ) { + + state.setMRTBlending( context.textures ); + + } + state.useProgram( programGPU ); // vertex state diff --git a/src/renderers/webgl-fallback/utils/WebGLState.js b/src/renderers/webgl-fallback/utils/WebGLState.js index 7ac0bf040d1c34..556a6ef763c00d 100644 --- a/src/renderers/webgl-fallback/utils/WebGLState.js +++ b/src/renderers/webgl-fallback/utils/WebGLState.js @@ -85,7 +85,6 @@ class WebGLState { this.currentBoundTextures = {}; this.currentBoundBufferBases = {}; - this._init(); } @@ -271,6 +270,22 @@ class WebGLState { } + setMRTBlending( textures ) { + + const gl = this.gl; + const drawBuffersIndexedExt = this.backend.drawBuffersIndexedExt; + + if ( ! drawBuffersIndexedExt ) return; + + for ( let i = 1; i < textures.length; i ++ ) { + + // use opaque blending for additional render targets + drawBuffersIndexedExt.blendFuncSeparateiOES( i, gl.ONE, gl.ZERO, gl.ONE, gl.ZERO ); + + } + + } + /** * Defines the blending. *