Using Basis compressed textures in a texture array

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!

Honestly I am too dumb to know what you are asking for, but maybe this would help?

https://playcanvas.com/project/1374529/overview

Wanted to bump as my VRAM usage is super high with my current setup!

TL;DR is it possible to pass BASIS or other compressed textures into a texture array?

BASIS + Texture Array Always Has Point Filtering and Maximum Per-Stage Sampled Texture Limit - #6 by Syzyjeez Seems like it should be possible but it doesn’t seem to have direct playcanvas support(?)

I believe your conclusion is correct @sniffles - it should be possible, but not directly supported by the engine.

You could load compressed format that is supported on your device (or load basis and convert it to that format - that’s what basis worker does) and pass an array of those typed arrays when creating the array texture, but I suspect it would not be very simple.