Cubemap possibly ignored in PR17151

@Evgeni_Popov After recent update I’ve noticed strange black flickering of DDS-loaded cubemaps (environment and reflection textures which I load using custom extension to glTF loader), and also multiple WebGL errors in console: “glTexStorage2D: No texture is bound to the specified target”.

After investigation I’ve found this PR WebGL: Fix empty mipmaps for compressed textures by Popov72 · Pull Request #17151 · BabylonJS/Babylon.js · GitHub
which introduces line

gl.texStorage2D(gl.TEXTURE_2D, Math.floor(Math.log2(Math.max(width, height))) + 1, internalFormat, texture.width, texture.height);

in _uploadCompressedDataToTextureDirectly function which is called both for 2D textures and cubemaps.

I don’t have a minimal example right now, but after changing target to use gl.TEXTURE_2D or gl.TEXTURE_CUBE_MAP for corresponding textures, the problem disappeared.

Was this specific gl.TEXTURE_2D just an oversight, or I am missing something and it’s actually intentional?

It’s a bug, thanks for reporting! Here’s the fix:

2 Likes

I may be wrong, but would this fix work correctly considering target is either gl.TEXTURE_2D or gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex when by docs target is gl.TEXTURE_2D and gl.TEXTURE_CUBE_MAP ?

Manually used this fix. Can confirm that target being gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndexdoesn’t resolve the problem. Need to specify gl.TEXTURE_CUBE_MAP specifically.

1 Like

My bad, I updated the fix! Let me know if it works for you.

1 Like

I am afk right now, but considering that it’s exactly what I did before, it should work :slight_smile:

1 Like