From 927854810b93757786f4d6d4c271d7bd4e69482f Mon Sep 17 00:00:00 2001 From: Michael Herzog Date: Thu, 1 Jul 2021 21:06:51 +0200 Subject: [PATCH] WebGLTextures: Fix mips gen for 3D render targets. (#22072) --- src/renderers/webgl/WebGLTextures.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/renderers/webgl/WebGLTextures.js b/src/renderers/webgl/WebGLTextures.js index 3c609c2d03..4c2da6447b 100644 --- a/src/renderers/webgl/WebGLTextures.js +++ b/src/renderers/webgl/WebGLTextures.js @@ -122,13 +122,13 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, } - function generateMipmap( target, texture, width, height ) { + function generateMipmap( target, texture, width, height, depth = 1 ) { _gl.generateMipmap( target ); const textureProperties = properties.get( texture ); - textureProperties.__maxMipLevel = Math.log2( Math.max( width, height ) ); + textureProperties.__maxMipLevel = Math.log2( Math.max( width, height, depth ) ); } @@ -1230,11 +1230,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) { - generateMipmap( _gl.TEXTURE_2D, texture, renderTarget.width, renderTarget.height ); + generateMipmap( glTextureType, texture, renderTarget.width, renderTarget.height, renderTarget.depth ); } - state.bindTexture( _gl.TEXTURE_2D, null ); + state.bindTexture( glTextureType, null ); } -- GitLab