@@ -83,9 +83,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
8383
8484 }
8585
86- function textureNeedsGenerateMipmaps ( texture , isPowerOfTwo ) {
86+ function textureNeedsGenerateMipmaps ( texture , supportsMips ) {
8787
88- return texture . generateMipmaps && isPowerOfTwo &&
88+ return texture . generateMipmaps && supportsMips &&
8989 texture . minFilter !== NearestFilter && texture . minFilter !== LinearFilter ;
9090
9191 }
@@ -355,12 +355,12 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
355355 }
356356
357357 var image = cubeImage [ 0 ] ,
358- isPowerOfTwoImage = isPowerOfTwo ( image ) ,
358+ supportsMips = isPowerOfTwo ( image ) || capabilities . isWebGL2 ,
359359 glFormat = utils . convert ( texture . format ) ,
360360 glType = utils . convert ( texture . type ) ,
361361 glInternalFormat = getInternalFormat ( glFormat , glType ) ;
362362
363- setTextureParameters ( _gl . TEXTURE_CUBE_MAP , texture , isPowerOfTwoImage ) ;
363+ setTextureParameters ( _gl . TEXTURE_CUBE_MAP , texture , supportsMips ) ;
364364
365365 for ( var i = 0 ; i < 6 ; i ++ ) {
366366
@@ -418,7 +418,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
418418
419419 }
420420
421- if ( textureNeedsGenerateMipmaps ( texture , isPowerOfTwoImage ) ) {
421+ if ( textureNeedsGenerateMipmaps ( texture , supportsMips ) ) {
422422
423423 // We assume images for cube map have the same size.
424424 generateMipmap ( _gl . TEXTURE_CUBE_MAP , texture , image . width , image . height ) ;
@@ -447,11 +447,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
447447
448448 }
449449
450- function setTextureParameters ( textureType , texture , isPowerOfTwoImage ) {
450+ function setTextureParameters ( textureType , texture , supportsMips ) {
451451
452452 var extension ;
453453
454- if ( isPowerOfTwoImage ) {
454+ if ( supportsMips ) {
455455
456456 _gl . texParameteri ( textureType , _gl . TEXTURE_WRAP_S , utils . convert ( texture . wrapS ) ) ;
457457 _gl . texParameteri ( textureType , _gl . TEXTURE_WRAP_T , utils . convert ( texture . wrapT ) ) ;
@@ -539,12 +539,12 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
539539 var needsPowerOfTwo = textureNeedsPowerOfTwo ( texture ) && isPowerOfTwo ( texture . image ) === false ;
540540 var image = resizeImage ( texture . image , needsPowerOfTwo , false , capabilities . maxTextureSize ) ;
541541
542- var isPowerOfTwoImage = isPowerOfTwo ( image ) ,
542+ var supportsMips = isPowerOfTwo ( image ) || capabilities . isWebGL2 ,
543543 glFormat = utils . convert ( texture . format ) ,
544544 glType = utils . convert ( texture . type ) ,
545545 glInternalFormat = getInternalFormat ( glFormat , glType ) ;
546546
547- setTextureParameters ( textureType , texture , isPowerOfTwoImage ) ;
547+ setTextureParameters ( textureType , texture , supportsMips ) ;
548548
549549 var mipmap , mipmaps = texture . mipmaps ;
550550
@@ -610,7 +610,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
610610 // if there are no manual mipmaps
611611 // set 0 level mipmap and then use GL to generate other mipmap levels
612612
613- if ( mipmaps . length > 0 && isPowerOfTwoImage ) {
613+ if ( mipmaps . length > 0 && supportsMips ) {
614614
615615 for ( var i = 0 , il = mipmaps . length ; i < il ; i ++ ) {
616616
@@ -670,7 +670,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
670670 // if there are no manual mipmaps
671671 // set 0 level mipmap and then use GL to generate other mipmap levels
672672
673- if ( mipmaps . length > 0 && isPowerOfTwoImage ) {
673+ if ( mipmaps . length > 0 && supportsMips ) {
674674
675675 for ( var i = 0 , il = mipmaps . length ; i < il ; i ++ ) {
676676
@@ -691,7 +691,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
691691
692692 }
693693
694- if ( textureNeedsGenerateMipmaps ( texture , isPowerOfTwoImage ) ) {
694+ if ( textureNeedsGenerateMipmaps ( texture , supportsMips ) ) {
695695
696696 generateMipmap ( _gl . TEXTURE_2D , texture , image . width , image . height ) ;
697697
@@ -880,7 +880,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
880880
881881 var isCube = ( renderTarget . isWebGLRenderTargetCube === true ) ;
882882 var isMultisample = ( renderTarget . isWebGLMultisampleRenderTarget === true ) ;
883- var isTargetPowerOfTwo = isPowerOfTwo ( renderTarget ) ;
883+ var supportsMips = isPowerOfTwo ( renderTarget ) || capabilities . isWebGL2 ;
884884
885885 // Setup framebuffer
886886
@@ -941,15 +941,15 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
941941 if ( isCube ) {
942942
943943 state . bindTexture ( _gl . TEXTURE_CUBE_MAP , textureProperties . __webglTexture ) ;
944- setTextureParameters ( _gl . TEXTURE_CUBE_MAP , renderTarget . texture , isTargetPowerOfTwo ) ;
944+ setTextureParameters ( _gl . TEXTURE_CUBE_MAP , renderTarget . texture , supportsMips ) ;
945945
946946 for ( var i = 0 ; i < 6 ; i ++ ) {
947947
948948 setupFrameBufferTexture ( renderTargetProperties . __webglFramebuffer [ i ] , renderTarget , _gl . COLOR_ATTACHMENT0 , _gl . TEXTURE_CUBE_MAP_POSITIVE_X + i ) ;
949949
950950 }
951951
952- if ( textureNeedsGenerateMipmaps ( renderTarget . texture , isTargetPowerOfTwo ) ) {
952+ if ( textureNeedsGenerateMipmaps ( renderTarget . texture , supportsMips ) ) {
953953
954954 generateMipmap ( _gl . TEXTURE_CUBE_MAP , renderTarget . texture , renderTarget . width , renderTarget . height ) ;
955955
@@ -960,10 +960,10 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
960960 } else {
961961
962962 state . bindTexture ( _gl . TEXTURE_2D , textureProperties . __webglTexture ) ;
963- setTextureParameters ( _gl . TEXTURE_2D , renderTarget . texture , isTargetPowerOfTwo ) ;
963+ setTextureParameters ( _gl . TEXTURE_2D , renderTarget . texture , supportsMips ) ;
964964 setupFrameBufferTexture ( renderTargetProperties . __webglFramebuffer , renderTarget , _gl . COLOR_ATTACHMENT0 , _gl . TEXTURE_2D ) ;
965965
966- if ( textureNeedsGenerateMipmaps ( renderTarget . texture , isTargetPowerOfTwo ) ) {
966+ if ( textureNeedsGenerateMipmaps ( renderTarget . texture , supportsMips ) ) {
967967
968968 generateMipmap ( _gl . TEXTURE_2D , renderTarget . texture , renderTarget . width , renderTarget . height ) ;
969969
@@ -986,9 +986,9 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
986986 function updateRenderTargetMipmap ( renderTarget ) {
987987
988988 var texture = renderTarget . texture ;
989- var isTargetPowerOfTwo = isPowerOfTwo ( renderTarget ) ;
989+ var supportsMips = isPowerOfTwo ( renderTarget ) || capabilities . isWebGL2 ;
990990
991- if ( textureNeedsGenerateMipmaps ( texture , isTargetPowerOfTwo ) ) {
991+ if ( textureNeedsGenerateMipmaps ( texture , supportsMips ) ) {
992992
993993 var target = renderTarget . isWebGLRenderTargetCube ? _gl . TEXTURE_CUBE_MAP : _gl . TEXTURE_2D ;
994994 var webglTexture = properties . get ( texture ) . __webglTexture ;
0 commit comments