Documentation
¶
Overview ¶
Package texture reads Source 2 compiled textures (.vtex_c): the header in the resource's DATA block, the mips stored after it, smallest first, and the top mip decoded to an image.
Index ¶
Constants ¶
const FlagCube = 0x10
FlagCube marks a cube map, whose every mip holds six faces in turn.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Format ¶
type Format uint8
Format is how a texture encodes its texels, by the number its header stores.
const ( // FormatDXT1 is BC1: 4x4 blocks of 8 bytes, two 565 colors. FormatDXT1 Format = 1 // FormatDXT5 is BC3: a BC4 alpha block before a BC1 color block. FormatDXT5 Format = 2 // FormatRGBA8888 stores four bytes per texel, red first. FormatRGBA8888 Format = 4 // FormatBC6H is half-float color in 16 byte blocks. FormatBC6H Format = 19 // FormatBC7 is 8-bit color and alpha in 16 byte blocks. FormatBC7 Format = 20 // FormatATI2N is BC5: two BC4 blocks, red then green. FormatATI2N Format = 21 // FormatATI1N is BC4: one channel in 8 byte blocks. FormatATI1N Format = 27 // FormatBGRA8888 stores four bytes per texel, blue first. FormatBGRA8888 Format = 28 )
The texture formats Deadlock ships.
func (Format) BlockBytes ¶
BlockBytes returns the bytes in each 4x4 block of a block-compressed format, and zero for any other.
type Texture ¶
type Texture struct {
// AverageColor is the stored linear RGB reflectivity used as the shader's
// color-correction pivot, without a gamma conversion.
AverageColor [3]float32
// Width is the top mip's width in texels.
Width int
// Height is the top mip's height in texels.
Height int
// Depth is the top mip's depth in slices, at least one.
Depth int
// Format is how the mips encode their texels.
Format Format
// Mips counts the stored mips, at least one.
Mips int
// Flags holds the header's flags, such as FlagCube.
Flags int
// VisibleWidth is the width of the image inside any padding.
VisibleWidth int
// VisibleHeight is the height of the image inside any padding.
VisibleHeight int
// Pixels holds every mip as stored, smallest first, and aliases the
// resource Read was given.
Pixels []byte
}
Texture is a compiled texture's header and its stored mips.
func (*Texture) Image ¶
Image decodes the top mip's first face or slice, cropped to the visible size. BC4 decodes to gray and BC5 to red and green.