Skip to content

Commit 2664d98

Browse files
committed
add webgl2 fallback
1 parent b708ed3 commit 2664d98

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/renderers/webgl-fallback/WebGLBackend.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ class WebGLBackend extends Backend {
268268

269269
this.disjoint = this.extensions.get( 'EXT_disjoint_timer_query_webgl2' );
270270
this.parallel = this.extensions.get( 'KHR_parallel_shader_compile' );
271+
this.drawBuffersIndexedExt = this.extensions.get( 'OES_draw_buffers_indexed' );
271272

272273
}
273274

@@ -957,6 +958,12 @@ class WebGLBackend extends Backend {
957958

958959
state.setMaterial( material, frontFaceCW, hardwareClippingPlanes );
959960

961+
if ( context.textures !== null && context.textures.length > 1 ) {
962+
963+
state.setMRTBlending( context.textures );
964+
965+
}
966+
960967
state.useProgram( programGPU );
961968

962969
// vertex state

src/renderers/webgl-fallback/utils/WebGLState.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ class WebGLState {
8585
this.currentBoundTextures = {};
8686
this.currentBoundBufferBases = {};
8787

88-
8988
this._init();
9089

9190
}
@@ -271,6 +270,22 @@ class WebGLState {
271270

272271
}
273272

273+
setMRTBlending( textures ) {
274+
275+
const gl = this.gl;
276+
const drawBuffersIndexedExt = this.backend.drawBuffersIndexedExt;
277+
278+
if ( ! drawBuffersIndexedExt ) return;
279+
280+
for ( let i = 1; i < textures.length; i ++ ) {
281+
282+
// use opaque blending for additional render targets
283+
drawBuffersIndexedExt.blendFuncSeparateiOES( i, gl.ONE, gl.ZERO, gl.ONE, gl.ZERO );
284+
285+
}
286+
287+
}
288+
274289
/**
275290
* Defines the blending.
276291
*

0 commit comments

Comments
 (0)