texcompress

package
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownsampleRGBA

func DownsampleRGBA(pixels []byte, width, height int, srgb bool) ([]byte, error)

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

func EncodeASTCChain(pixels []byte, width, height int, srgb bool) ([]byte, int, error)

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

func EncodeLevel(format render.TextureFormat, pixels []byte, width, height int) ([]byte, error)

EncodeLevel compresses one mip level of RGBA8 pixels.

func Formats

func Formats() []render.TextureFormat

Formats reports every format this package can encode.

func Opaque

func Opaque(pixels []byte) bool

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL