This is needed to instantiate `std::streampos`. It currently relies on transitive header inclusion to get that, which is going away for libc++ in ebcf1bf2ec.
mipgen can now emit basis-encoded KTX2 files. Both the desktop and
web "suzanne" samples use this as a test for compressed textures.
This PR does not add KTX2 support to glTF, but it's on the way.
`BasisEncoder` has a builder style API that calls the basis encoder to
create KTX2 files. This hides some low-level BasisU features that we are
not using, like file I/O and mipmap generation.
`Ktx2Reader` is an easy-to-use API for creating Filament textures from
KTX2 files. Its API primarily consists of these two methods:
bool requestFormat(Texture::InternalFormat format);
Filament::Texture* load(const uint8_t* data, size_t size);
The first method is used to build an ordered list of formats that are
supported by your hardware. The second method consumes the contents of a
basis-encoded KTX2 file and attempts to produce a Filament texture with
a preferred format.
IMPORTANT: Our tools still let you use KTX1 for non-compressed images
because it is useful for HDR, but you can no longer use KTX1 for
block-compressed data.
Partial fix for #4771.
The `g_linearized` variable was being used for two purposes: to denote
the linearity of the source format AND the linearity of the destination
format. This was confusing and is now split is `sourceIsLinear` and
`destIsLinear`.
This change has no effect on the the look of the suzanne demo.
- RGB_11_11_10 is exported in a RGBA PNG file where the 4 channels are
used as a uint32 storing a RGB_10_11_11_REV pixel.
We use the .rgb32f extension, and those PNG files contain garbage
when seen in a PNG viewer.
- This is now the default for the -x option.
- compressed KTX files don't encode RGBM, which means they can't
support HDR, unless an HDR compression scheme is used.
This shrinks file size as follows, although it seems to darken the
rendered result.
```
1398209 Oct 2 16:22 ao.ktx
699172 Oct 2 16:20 ao_etc.ktx
1398209 Oct 2 16:22 metallic.ktx
699172 Oct 2 16:19 metallic_etc.ktx
1398209 Oct 2 16:22 roughness.ktx
699172 Oct 2 16:20 roughness_etc.ktx
```
At build time, mipgen now creates several compressed and non-compressed
variants for albedo.
For ASTC we use the ARM encoder, for S3TC we use the STB encoder. The
latter is somewhat limited so we may wish to investigate other libraries
in the future (e.g., AMD Compressenator).
At run time, we detect which of these variants to download, based on
available WebGL extensions. In practice, this means that desktop
browsers will use the S3TC variant and mobile browsers will use the ASTC
variant.
The makes unzipped albedo go from ~4 MB to 682 KB using S3TC.
Mobile support (ASTC and ETC2) is coming in a future PR, stay tuned.
The compression API now takes block size instead of bit rate. Otherwise
it is quite possible for the encoder to generate a block size that is
not one of the valid block sizes that graphics API's can actually
consume.