I was trying to create THREE.CubeTexture using 6 different THREE.CompressedTextures and realized that the CubeTexture does not support CompressedTextures. I opened this issue but have not received any feedback: https://github.com/mrdoob/three.js/issues/16584
Does anyone have any opinion on this? I’ll try to do a PR about this issue but want to make sure if this is an actual bug, so was hoping for some feedback.
Thanks for the suggestion. I compressed the 6 textures used in the example to KTX format using S3TC compression, tested them with a KTXLoader and mapped them to a cube to make sure they are valid textures. Then I changed only this line:
This makes perfect sense to me as the CubeTextureLoader does not perform a file format check and internally uses an ImageLoader which seem to work well on Web friendly formats such as PNG and JPEG but not with KTX. IMO the CubeTextureLoader should accept an optional loader variable to be able to load compressed textures.
Clone the repo and start a webserver (I use “python -m SimpleHTTPServer”)
There are 3 HTML files:
withJPG.html -> This is the normal, working version with JPG textures
withKTX.html -> This is almost the same as withJPG.html, instead KTX textures are used to prove that THREE.CubeTextureLoader does not go well with compressed textures
withCompressedTextures.html -> This uses a KTXLoader to load 6 different KTX textures, constructs directly an instance of THREE.CubeTexture without using a CubeTextureLoader. I did this to demonstrate some possible logical problems inside WebglTextures class.
CubeTextureLoader is definitely not designed for compressed textures and I think it’s no good to add support for it. Otherwise it would rely on too many loaders from the examples.
So let’s assume you create a CubeTexture with compressed textures by yourself (like in withCompressedTextures.html). I can confirm that in this case there are several issues in WebGLTextures. For example:
var isCompressed = ( texture && texture.isCompressedTexture );
However, even if I add this code, I get the following WebGL error in Firefox:
Error: WebGL warning: texImage2D: Desired upload requires more data than is available: (511 rows plus 512 pixels needed, 85 rows plus 170 pixels available)
Error: WebGL warning: generateMipmap: The texture’s base level must be complete.
Yes I had the same problem, it was complaining about the buffer size and yes I can confirm that they are actually valid textures. It is not supposed to call textImage2D anyway. That’s the problem. It’s supposed to call compressedTexImage2D. So the error message you posted is probably caused by Compressed Texture + textImage2D