Three.js: [WebGL2] NPOT Texture should not fallback in webgl2

Created on 9 Jan 2019  路  9Comments  路  Source: mrdoob/three.js

Description of the problem

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;
}
````

Three.js version
  • [x] Dev
  • [ ] r100
  • [ ] ...
Browser
  • [x] All of them
  • [ ] Chrome
  • [ ] Firefox
  • [ ] Internet Explorer
OS
  • [x] All of them
  • [ ] Windows
  • [ ] macOS
  • [ ] Linux
  • [ ] Android
  • [ ] iOS
Enhancement WebGL2

Most helpful comment

How about this?

var supportsMips = ( isPowerOfTwo || capabilities.isWebGL2 );

All 9 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

seep picture seep  路  3Comments

alexprut picture alexprut  路  3Comments

boyravikumar picture boyravikumar  路  3Comments

clawconduce picture clawconduce  路  3Comments

fuzihaofzh picture fuzihaofzh  路  3Comments