Documentation
¶
Overview ¶
Package texcompress implements pure-Go block compression for build-time texture preprocessing. Every encoder is deterministic and reuses scratch storage where possible, so a build stays reproducible and keeps a small heap.
Encoders read straight or premultiplied RGBA8 pixels and never touch alpha unless the target format stores it. BC1 and BC3 read colour from the red, green, and blue channels; BC4 and BC5 read red and green, which is where normal and material maps keep their data. ASTC 4x4 stores all four channels in its standard constant-color block form.
Index ¶
- func DecodeBCLevel(dst, src []byte, width, height int, format render.TextureFormat)
- func DownsampleRGBA(pixels []byte, width, height int, srgb bool) ([]byte, error)
- func EncodeASTCChain(pixels []byte, width, height int, srgb bool) ([]byte, int, error)
- func EncodeChain(format render.TextureFormat, pixels []byte, width, height int) ([]byte, int, error)
- func EncodeLevel(format render.TextureFormat, pixels []byte, width, height int) ([]byte, error)
- func Formats() []render.TextureFormat
- func Opaque(pixels []byte) bool
- func Supported(format render.TextureFormat) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeBCLevel ¶ added in v0.1.9
func DecodeBCLevel(dst, src []byte, width, height int, format render.TextureFormat)
DecodeBCLevel expands one BC1 RGB or BC3 level, clipping partial edge blocks to its logical dimensions. Both buffers have been sized by the caller.
func DownsampleRGBA ¶
DownsampleRGBA halves one RGBA8 level with the same deterministic box filter used by EncodeChain. External block encoders use it so every target ships an identical mip hierarchy.
func EncodeASTCChain ¶
EncodeASTCChain encodes an RGBA8 mip chain as standard ASTC 4x4 blocks.
The encoder uses ASTC's constant-color (void-extent) block form. Every block stores the average RGBA value of its 4x4 texel footprint, including edge texels replicated to fill a partial block. This form is intentionally small, deterministic, and can be decoded by all ASTC 4x4 implementations. Encoding allocates the returned payload and borrows an RGBA mip buffer from the pool.
func EncodeChain ¶
func EncodeChain(format render.TextureFormat, pixels []byte, width, height int) ([]byte, int, error)
EncodeChain compresses a full mip chain from the largest level down to 1x1 and returns the concatenated payload together with its level count.
func EncodeLevel ¶
EncodeLevel compresses one mip level of RGBA8 pixels.
func Formats ¶
func Formats() []render.TextureFormat
Formats reports every format this package can encode.
func Opaque ¶
Opaque reports whether every texel of an RGBA8 level is fully opaque. BC1 cannot store alpha, so callers use this to choose between BC1 and BC3.
func Supported ¶
func Supported(format render.TextureFormat) bool
Supported reports whether format has an encoder in this package.
Types ¶
This section is empty.