godot/thirdparty/cvtt/etc_notes.txt
K. S. Ernest (iFire) Lee 419b342a9a Faster CVTT by reducing quality.
Make BC6 and BC7 CVTT faster while still having better quality than DXT5.
2022-02-04 15:15:26 -08:00

27 lines
1.8 KiB
Plaintext

The ETC1 compressor uses modified cluster fit:
Assume that there exists an ideal base color and set of selectors for a given table.
For a given table and set of selectors, the ideal base color can be determined by subtracting the offsets from each pixel and averaging them.
Doing that is equivalent to subtracting the average offset from the average color.
Because positive and negative selectors of the same magnitude cancel out, the search space of possible average offsets is reduced: 57 unique offsets for the first table and 81 for the others.
Most of the offsets result in the same color as another average offset due to quantization of the base color, so those can be de-duplicated.
So:
- Start with a high-precision average color.
- Apply precomputed luma offsets to it.
- Quantize and de-duplicate the base colors.
- Find the ideal selectors for each base color.
Differential mode is solved by just finding the best legal combination from those attempts.
There are several scenarios where this is not ideal:
- Clamping behavior can sometimes be leveraged for a more accurate block.
- Differentials can sometimes be moved slightly closer to become legal.
- This only works when MSE is the error metric (i.e. not normal maps)
- This only works when pixel weights are of equal importance (i.e. not using weight by alpha or edge deblocking)
T and H mode just work by generating clustering assignments by computing a chrominance line and splitting the block in half by the chrominance midpoint and using those to determine the averages.
Planar mode is just solved algebraically.
If you want to emulate etc2comp's default settings, add the flag ETC_UseFakeBT709 to use its modified Rec. 709 error coefficients.
Doing that will significantly slow down encoding because it requires much more complicated quantization math.