nvtt
Loading...
Searching...
No Matches
Public Member Functions | List of all members
nvtt::CompressionOptions Struct Reference

Compression options. This class describes the desired compression format and other compression settings. More...

#include <nvtt.h>

Public Member Functions

NVTT_API CompressionOptions ()
 Constructor. Sets compression options to the default values.
 
NVTT_API ~CompressionOptions ()
 Destructor.
 
NVTT_API void reset ()
 Set default compression options.
 
NVTT_API void setFormat (Format format)
 Set desired compression format.
 
NVTT_API void setQuality (Quality quality)
 Set compression quality settings.
 
NVTT_API void setColorWeights (float red, float green, float blue, float alpha=1.0f)
 Set the weights of each color channel used to measure compression error.
 
NVTT_API void setPixelFormat (unsigned int bitcount, unsigned int rmask, unsigned int gmask, unsigned int bmask, unsigned int amask)
 Describes an RGB/RGBA format using 32-bit masks per channel.
 
NVTT_API void setPixelFormat (unsigned char rsize, unsigned char gsize, unsigned char bsize, unsigned char asize)
 Describes an RGB/RGBA format using the number of bits per channel.
 
NVTT_API void setPixelType (PixelType pixelType)
 Set pixel type.
 
NVTT_API void setPitchAlignment (int pitchAlignment)
 Set pitch alignment in bytes.
 
NVTT_API void setQuantization (bool colorDithering, bool alphaDithering, bool binaryAlpha, int alphaThreshold=127)
 Set quantization options.
 
NVTT_API unsigned int d3d9Format () const
 Translates to a D3D format.
 

Detailed Description

Compression options. This class describes the desired compression format and other compression settings.

Member Function Documentation

◆ d3d9Format()

NVTT_API unsigned int nvtt::CompressionOptions::d3d9Format ( ) const

Translates to a D3D format.

Returns 0 if no corresponding format could be found.

For Format_RGB, this looks at the pixel type and pixel format to determine the corresponding D3D format. For BC6, BC7, and ASTC, this returns a FourCC code: 'BC6H' for both unsigned and signed BC6, 'BC7L' for BC7, and 'ASTC' for all ASTC formats.

◆ setColorWeights()

NVTT_API void nvtt::CompressionOptions::setColorWeights ( float red,
float green,
float blue,
float alpha = 1.0f )

Set the weights of each color channel used to measure compression error.

The choice for these values is subjective. In most cases uniform color weights (1.0, 1.0, 1.0) work very well. A popular choice is to use the NTSC luma encoding weights (0.2126, 0.7152, 0.0722), but I think that blue contributes to our perception more than 7%. A better choice in my opinion is (3, 4, 2).

◆ setPixelFormat() [1/2]

NVTT_API void nvtt::CompressionOptions::setPixelFormat ( unsigned char rsize,
unsigned char gsize,
unsigned char bsize,
unsigned char asize )

Describes an RGB/RGBA format using the number of bits per channel.

Note that this sets the masks per channel to 0.

◆ setPixelFormat() [2/2]

NVTT_API void nvtt::CompressionOptions::setPixelFormat ( unsigned int bitcount,
unsigned int rmask,
unsigned int gmask,
unsigned int bmask,
unsigned int amask )

Describes an RGB/RGBA format using 32-bit masks per channel.

Note that this sets the number of bits per channel to 0.

◆ setPixelType()

NVTT_API void nvtt::CompressionOptions::setPixelType ( PixelType pixelType)

Set pixel type.

These are used for Format_RGB: they indicate how the output should be interpreted, but do not have any influence over the input. They are ignored for other compression modes.

◆ setQuantization()

NVTT_API void nvtt::CompressionOptions::setQuantization ( bool colorDithering,
bool alphaDithering,
bool binaryAlpha,
int alphaThreshold = 127 )

Set quantization options.

Warning
Do not enable dithering unless you know what you are doing. Quantization introduces errors. It's better to let the compressor quantize the result to minimize the error, instead of quantizing the data before handling it to the compressor.

The documentation for this struct was generated from the following file: