BinomialLLC / basis_universal

Basis Universal GPU Texture Codec
Apache License 2.0
2.71k stars 266 forks source link

Investigate ETC1S to EAC A8 transcoding path #253

Open lexaknyazev opened 3 years ago

lexaknyazev commented 3 years ago

Currently, the transcoder chooses the predefined EAC A8 configuration (i.e., the base color, the multiplier, the table index, and the selectors) based on the ETC1S selectors used. For example, if an ETC1S block uses only selectors 1 and 2, the transcoder would choose a mapping configuration optimized for this exact case.

Still, there are two potential improvements (with some tradeoffs).

The predefined tables consider only minimum and maximum selector values, ignoring the gaps. For example, an ETC1S block that uses only 0 and 2 would be converted as if it also uses 1, thus potentially producing less optimal output in about 16 cases.

A lower-hanging fruit is the range selection code that always falls back to full-range configurations even when a more optimal option is available. For example, an ETC1S block that uses only 0 and 1 is converted with the full-range configuration although 0-2 range would be better.

lexaknyazev commented 3 years ago

image

image

lexaknyazev commented 3 years ago

Columns are existing or potential LUTs, rows are per-block selector usage, and cells are max error values. image

Simple transcoding suggestions:

Optional next steps to consider:

richgel999 commented 3 years ago

This is awesome - thanks! I'll need to parse this an absorb it. (Right now the focus is on OpenCL come hell or high water.)