Possible to load .astc files?

Edit from the future: if anyone finds this thread, PVRTexTool checks all three boxes.

Three.js supports loading compressed textures from .KTX, which is great.

But our team hasn’t yet found a compression tool that:

  1. Generates ASTC files
  2. In acceptable quality
  3. Stores them in a .KTX container.

The popular suggestion is AMD’s Compressonator, but in a side-by-side comparison the produced ASTC-as-KTX files are lower quality than any other compressor. ARM’s command line AstcEnc.exe tool does output to .KTX, but describes the process as ‘decompressing’ and doesn’t seem to actually be storing ASTC in the resultant KTX files. I’ve found that ARM’s Mali Texture Compression Tool outputs ASTC images that look great, but again it can’t export them as .KTX (though it can do so with other formats).

So there doesn’t seem to be a way to store ASTC images in a KTX container without heavily compromising on quality. While we look for other tools, is there a way we can directly load .astc files into Three.js, rather than using .KTX?

As a new user, I get to upload one image; here’s how bad Compressonator’s best output is vs Mali TCT at medium settings:

No, three.js does not provide an ASTCLoader. Have you considered to use basis instead of a concrete texture compression format? From the docs:

Basis Universal is a “supercompressed” GPU texture and texture video compression system that outputs a highly compressed intermediate file format (.basis) that can be quickly transcoded to a wide variety of GPU texture compression formats.

When using a concrete texture compression formats like ASTC or S3TC, you depend on the fact that only specific hardware supports certain formats. This is especially bad in the web since you often don’t know which device uses your application. By using basis, you achieve much better platform independence (basis textures can also be transcoded to ASTC). I suggest you study the format and bit and the official example. It might be the right choice for you:

https://threejs.org/examples/webgl_loader_texture_basis

1 Like

We’ve tested Basis, but found that compression times are so long, and the quality is a bit worse, compared to (good) ASTCs since internally it uses ETC1S. The hardware we’re working on all supports ASTC so it would be our preferred format on the basis of quality. We can make Basis work until .KTX support improves, though.

If anyone pops in, sees this, and can recommend a better ASTC compressor, let me know!

Is it possible to load the .astc file as an ArrayBuffer, and just construct a CompressedTexture from that? I’m not sure whether .astc just has the raw texture data or some sort of file header, and I don’t have any examples that aren’t in a container.

Note that KTX v2 offers Basis internally, there are various quality/speed options in the Basis compressor, and some planned updates to the Basis library for higher quality. I am not sure whether KTX v1 support will improve, or tools will shift to v2. You may want to file an issue on the Basis repository if you’re not getting the results you want, because that’s where I would expect most developer effort to be happening right now.

1 Like

That’s along the lines of how I thought it might be doable, but 1. I see what looks like a header, just inspecting the binary in a couple of my images, 2. I never got around to trying it because I found a better compressor.

I’m only commenting here for anyone else who might find this thread with the same question - PVRTexTool does the job and it took me ages to find out it supports ASTC.

1 Like