-
Notifications
You must be signed in to change notification settings - Fork 290
Description
The simplest way is to take the output of the ASTC encoder and pass it through the ERT (Entropy Reduction Transform) in this repo:
https://github.com/richgel999/bc7enc_rdo
See this class:
https://github.com/richgel999/bc7enc_rdo/blob/master/ert.h
The ERT is format agnostic. It just cares about block bytes, the original block's RGBA pixels, and a block unpack function.
You pass it an array of encoded blocks, an array of original block pixels, some parameters, and a pointer to a block unpack function. It does the rest. We need to find a good ASTC block unpacker. (There may be one with astc-encoder repo that is included in this repo. I haven't confirmed.) The main problem is the ASTC specification is so complex that some block unpackers wouldn't always catch invalid blocks, which the ERT will sometimes create as it injects trial matches into blocks. These blocks would fail to be unpacked by some unpackers, but would be unpacked by others, which is an issue.
The ERT is really simple and not much code, so it should be a good place to start.
A possible improvement is to encode a texture to ASTC multiple times, and use that as the source into the ERT. Each encode can use a different encoding that achieves more or less the same error.