Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/renderers/WebGLRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1652,6 +1652,7 @@ class WebGLRenderer {
currentRenderState = renderStates.get( scene, renderStateStack.length );
currentRenderState.init( camera );

currentRenderState.state.textureUnits = textures.getTextureUnits();
renderStateStack.push( currentRenderState );

_projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );
Expand Down Expand Up @@ -1797,6 +1798,8 @@ class WebGLRenderer {

currentRenderState = renderStateStack[ renderStateStack.length - 1 ];

textures.setTextureUnits( currentRenderState.state.textureUnits );

if ( _clippingEnabled === true ) clipping.setGlobalState( _this.clippingPlanes, currentRenderState.state.camera );

} else {
Expand Down
3 changes: 2 additions & 1 deletion src/renderers/webgl/WebGLRenderStates.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ function WebGLRenderState( extensions ) {

lights: lights,

transmissionRenderTarget: {}
transmissionRenderTarget: {},
textureUnits: 0
};

return {
Expand Down
14 changes: 14 additions & 0 deletions src/renderers/webgl/WebGLTextures.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,18 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,

}

function getTextureUnits() {

return textureUnits;

}

function setTextureUnits( value ) {

textureUnits = value;

}

function allocateTextureUnit() {

const textureUnit = textureUnits;
Expand Down Expand Up @@ -2386,6 +2398,8 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,

this.allocateTextureUnit = allocateTextureUnit;
this.resetTextureUnits = resetTextureUnits;
this.getTextureUnits = getTextureUnits;
this.setTextureUnits = setTextureUnits;

this.setTexture2D = setTexture2D;
this.setTexture2DArray = setTexture2DArray;
Expand Down