These fallback logic should be skipped in webgl2:
````javascript
// webgl2 skip this
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, _gl.CLAMP_TO_EDGE );
_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, _gl.CLAMP_TO_EDGE );
_gl.texParameteri( textureType, _gl.TEXTURE_MAG_FILTER, filterFallback( texture.magFilter ) );
_gl.texParameteri( textureType, _gl.TEXTURE_MIN_FILTER, filterFallback( texture.minFilter ) );
// isPowerOfTwo should be (isPowerOfTwo || webgl2)
function textureNeedsGenerateMipmaps( texture, isPowerOfTwo ) {
return texture.generateMipmaps && isPowerOfTwo &&
texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter;
}
````
Sounds good to me.
@Mugen87 Does this conflict with #15286?
Yes. I'm not sure so far what parts of WebGLTextures needs to be modified to implement this feature request but it's probably better to do this after #15286 is merged.
Ah, I missed when I made WebGL2 PR. Yeah we should fix. Perhaps replacing isPowerOfTwo in these two lines with ( isPowerOfTwo || capability.isWebGL2 ) may be easy to fix?
https://github.com/mrdoob/three.js/blob/dev/src/renderers/webgl/WebGLTextures.js#L88
https://github.com/mrdoob/three.js/blob/dev/src/renderers/webgl/WebGLTextures.js#L454
Yes, since textureNeedsPowerOfTwo() already returns false with a WebGL 2 rendering context. So textureNeedsGenerateMipmaps() needs a fix as well as setTextureParameters(). But I think the following two lines also need an enhancement:
https://github.com/mrdoob/three.js/blob/dev/src/renderers/webgl/WebGLTextures.js#L613
https://github.com/mrdoob/three.js/blob/dev/src/renderers/webgl/WebGLTextures.js#L673
OK, I'll make PR to fix.
I have difficulty naming variables in English. How var name var varname = ( isPowerOfTwo || capabilities.isWebGL2 ); should be? isValidSize?
Maybe needsPowerOfTwo? It's already used in the file but maybe not in your relevant scope.
How about this?
var supportsMips = ( isPowerOfTwo || capabilities.isWebGL2 );
Thanks for naming. I made PR #15574
Most helpful comment
How about this?