public static class BlockCompressorEncodes a texture into a block-compressed format, and back for inspection.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
This is build-time code. The runtime never decodes a block: a shipped texture is already in the format the GPU samples, and loading it is a header parse and an upload. Decode exists so that an editor can show what a compressed texture will actually look like, and so that these encoders can be tested against something other than themselves.
What is here is BC, and only BC. ASTC and ETC2 are not, and are not coming in managed code — [03](../../../docs/plan/03-core-foundation.md) says so and gives the reason: ASTC encoding is measured in minutes per gigabyte outside a vectorised native encoder, and astcenc is already in doc 01's dependency register for exactly this. Both formats are carried through TextureData and Ktx2 so that a build which has that encoder can ship them.
What quality to expect. BC1, BC3, BC4 and BC5 here are complete encoders: they fit the principal axis of the block's own colours and refine the endpoints by least squares, which is what a production BCn encoder does, and the formats have no modes left to choose between. BC7 and BC6H each write one mode of eight and fourteen — see Bc7Block and Bc6HBlock — which is a real quality ceiling on blocks with an edge running through them, and is stated where each one is written.
Methods (8)
public static bool CanEncode(PixelFormat format)Whether this can produce that format.
public static bool IsHighDynamicRange(PixelFormat format)Whether the format holds high dynamic range, and so is encoded from float rather than bytes.
public static TextureData Encode(TextureData source, PixelFormat target)Compresses every level of a texture.
public static TextureData Decode(TextureData source)Decompresses every level of a texture, for inspection.
public static void EncodeBlock(PixelFormat target, ReadOnlySpan<byte> rgba, Span<byte> block)Compresses one 4×4 block of eight-bit colour.
public static void EncodeHdrBlock(ReadOnlySpan<ushort> rgb, Span<byte> block)Compresses one 4×4 block of high dynamic range colour, as BC6H.
public static void DecodeBlock(PixelFormat source, ReadOnlySpan<byte> block, Span<byte> rgba)Decompresses one block.
public static void DecodeHdrBlock(ReadOnlySpan<byte> block, Span<ushort> rgb)Decompresses one BC6H block.
Used by (3)
- BlockCompressorTestsVixen.Core.Imaging.Tests
- BlockEncoderTestsVixen.Core.Imaging.Tests
- TextureImporterVixen.Editor.Assets