Skip to content

Commit 29c41b6

Browse files
authored
WebGLRenderer: Correctly generate mipmaps for 3D & Array RenderTargets (#29678)
* Enable generating mipmaps for 3d textures * Update WebGLTextures.js * Update WebGLTextures.js
1 parent 1360b24 commit 29c41b6

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/renderers/webgl/WebGLTextures.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,15 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
117117

118118
}
119119

120+
function getTargetType( texture ) {
121+
122+
if ( texture.isWebGLCubeRenderTarget ) return _gl.TEXTURE_CUBE_MAP;
123+
if ( texture.isWebGL3DRenderTarget ) return _gl.TEXTURE_3D;
124+
if ( texture.isWebGLArrayRenderTarget || texture.isCompressedArrayTexture ) return _gl.TEXTURE_2D_ARRAY;
125+
return _gl.TEXTURE_2D;
126+
127+
}
128+
120129
function getInternalFormat( internalFormatName, glFormat, glType, colorSpace, forceLinearTransfer = false ) {
121130

122131
if ( internalFormatName !== null ) {
@@ -1927,11 +1936,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
19271936

19281937
if ( textureNeedsGenerateMipmaps( texture ) ) {
19291938

1930-
const target = renderTarget.isWebGLCubeRenderTarget ? _gl.TEXTURE_CUBE_MAP : _gl.TEXTURE_2D;
1939+
const targetType = getTargetType( renderTarget );
19311940
const webglTexture = properties.get( texture ).__webglTexture;
19321941

1933-
state.bindTexture( target, webglTexture );
1934-
generateMipmap( target );
1942+
state.bindTexture( targetType, webglTexture );
1943+
generateMipmap( targetType );
19351944
state.unbindTexture();
19361945

19371946
}

0 commit comments

Comments
 (0)