pull/275/merge
StefanBruens 3 years ago committed by GitHub
commit 027471bede
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -280,6 +280,11 @@ bool Compressor::Private::compress(const InputOptions::Private & inputOptions, c
// Resize input.
img.resize(w, h, d, ResizeFilter_Box);
// Apply color transform.
if (inputOptions.colorTransform == ColorTransform_YCoCg) {
img.toYCoCg();
}
nvtt::Surface tmp = img;
if (!img.isNormalMap()) {
tmp.toGamma(inputOptions.outputGamma);

@ -104,6 +104,8 @@ void InputOptions::reset()
m.inputGamma = 2.2f;
m.outputGamma = 2.2f;
m.colorTransform = ColorTransform_None;
m.generateMipmaps = true;
m.maxLevel = -1;
m.mipmapFilter = MipmapFilter_Box;
@ -124,7 +126,14 @@ void InputOptions::reset()
// Setup the input image.
void InputOptions::setTextureLayout(TextureType type, int width, int height, int depth /*= 1*/, int arraySize /*= 1*/)
// Overload for ABI compatibility
void InputOptions::setTextureLayout(TextureType type, int width, int height, int depth /*= 1*/)
{
setTextureLayout(type, width, height, depth, 1);
}
// Setup the input image.
void InputOptions::setTextureLayout(TextureType type, int width, int height, int depth, int arraySize)
{
// Validate arguments.
nvCheck(width >= 0);
@ -330,6 +339,18 @@ void InputOptions::setNormalizeMipmaps(bool normalize)
m.normalizeMipmaps = normalize;
}
// Set color transform.
void InputOptions::setColorTransform(ColorTransform t)
{
m.colorTransform = t;
}
// Set linear transform for the given channel.
// Stub for ABI compatibily, never implemented
void InputOptions::setLinearTransform(int, float, float, float, float)
{
}
void InputOptions::setMaxExtents(int e)
{
nvDebugCheck(e > 0);

@ -55,6 +55,9 @@ namespace nvtt
float inputGamma;
float outputGamma;
// Color transform.
ColorTransform colorTransform;
// Mipmap generation options.
bool generateMipmaps;
int maxLevel;

@ -249,6 +249,17 @@ namespace nvtt
ResizeFilter_Mitchell,
};
// Color transformation.
// deprecated since 2.1.0
enum ColorTransform
{
ColorTransform_None,
ColorTransform_Linear,
ColorTransform_Swizzle,
ColorTransform_YCoCg,
ColorTransform_ScaledYCoCg,
};
// Extents rounding mode.
enum RoundMode
{
@ -290,7 +301,9 @@ namespace nvtt
NVTT_API void reset();
// Setup input layout.
NVTT_API void setTextureLayout(TextureType type, int w, int h, int d = 1, int arraySize = 1);
// Overload for ABI compatibility
NVTT_API void setTextureLayout(TextureType type, int w, int h, int d = 1 /*, arraysize = 1 */);
NVTT_API void setTextureLayout(TextureType type, int w, int h, int d, int arraySize);
NVTT_API void resetTextureLayout();
// Set mipmap data. Copies the data.
@ -320,6 +333,10 @@ namespace nvtt
NVTT_API void setNormalFilter(float sm, float medium, float big, float large);
NVTT_API void setNormalizeMipmaps(bool b);
// Set color transforms.
NVTT_API void setColorTransform(ColorTransform t);
NVTT_API void setLinearTransform(int channel, float w0, float w1, float w2, float w3);
// Set resizing options.
NVTT_API void setMaxExtents(int d);
NVTT_API void setRoundMode(RoundMode mode);

Loading…
Cancel
Save