Hey all, apologies if this is a silly question.
Is it possible to generate a texture array built up of compressed basis textures? I’m able to render individual sampler2d textures just fine, but when I try to render a texturearray, I get the warning WebGL warning: compressedTexSubImage: Bad format: Invalid enum value RGBA when I call vec4 texColor = texture(uTextureArray1, vUv); in my shader.
Here’s how I build the texarray:
const testTextureArrayOptions = {
name: `textureArray_${1}`,
format: basisAsset.texture.format,
// format: pc.PIXELFORMAT_R8_G8_B8_A8,
width: 512,
height: 512,
arrayLength: 1,
addressU: pc.ADDRESS_CLAMP_TO_EDGE,
addressV: pc.ADDRESS_CLAMP_TO_EDGE,
// minFilter: pc.FILTER_LINEAR_MIPMAP_LINEAR,
// magFilter: pc.FILTER_LINEAR,
levels: [
[basisAsset.texture.getSource()],
],
}
const testTextureArray = new pc.Texture(app.graphicsDevice, testTextureArrayOptions);
console.log('testTextureArray', testTextureArray)
testTextureArray.upload()
And here’s how I load the textures:
const asset = new pc.Asset(url, 'texture', {
url: `${ASSET_BASE_URL}${url}`,
})
Again it works fine when I use png sample2d textures. Similarly, the texarray works when I use a .png file, but not when I use a .basis or .ktx2. So I surmise there must be a different way to build the texture array for compressed textures, but I’m struggling to find the right resources. (Caveat I also need to be able to generate texture arrays at runtime)
(Also digging a bit more it seems as though threejs supports this? Is it possible to have a texture array of compressed textures? - #2 by Mugen87 - Questions - three.js forum
and Add support for compressed versions of DataTexture2DArray and DataTexture3D. · Issue #19676 · mrdoob/three.js · GitHub though it seems like its only for statically built .ktx2 files…)
Cheers!