Add interface to specify color transformations.
This commit is contained in:
parent
5c95f5d5e6
commit
1b73dcaf7e
|
@ -83,6 +83,9 @@ void InputOptions::reset()
|
||||||
m.inputGamma = 2.2f;
|
m.inputGamma = 2.2f;
|
||||||
m.outputGamma = 2.2f;
|
m.outputGamma = 2.2f;
|
||||||
|
|
||||||
|
m.colorTransform = ColorTransform_None;
|
||||||
|
m.linearTransform = Matrix(identity);
|
||||||
|
|
||||||
m.generateMipmaps = false;
|
m.generateMipmaps = false;
|
||||||
m.maxLevel = -1;
|
m.maxLevel = -1;
|
||||||
m.mipmapFilter = MipmapFilter_Box;
|
m.mipmapFilter = MipmapFilter_Box;
|
||||||
|
@ -258,3 +261,18 @@ void InputOptions::setNormalizeMipmaps(bool normalize)
|
||||||
{
|
{
|
||||||
m.normalizeMipmaps = normalize;
|
m.normalizeMipmaps = normalize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set color transform.
|
||||||
|
void InputOptions::setColorTransform(ColorTransform t)
|
||||||
|
{
|
||||||
|
m.colorTransform = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set linear transform for the given channel.
|
||||||
|
void InputOptions::setLinearTransfrom(int channel, float w0, float w1, float w2, float w3)
|
||||||
|
{
|
||||||
|
nvCheck(channel >= 0 && channel < 4);
|
||||||
|
|
||||||
|
Vector4 w(w0, w1, w2, w3);
|
||||||
|
//m.linearTransform.setRow(channel, w);
|
||||||
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
#include <nvcore/Ptr.h>
|
#include <nvcore/Ptr.h>
|
||||||
#include <nvmath/Vector.h>
|
#include <nvmath/Vector.h>
|
||||||
|
#include <nvmath/Matrix.h>
|
||||||
#include <nvimage/Image.h>
|
#include <nvimage/Image.h>
|
||||||
#include "nvtt.h"
|
#include "nvtt.h"
|
||||||
|
|
||||||
|
@ -58,7 +59,11 @@ namespace nvtt
|
||||||
// Gamma conversion.
|
// Gamma conversion.
|
||||||
float inputGamma;
|
float inputGamma;
|
||||||
float outputGamma;
|
float outputGamma;
|
||||||
|
|
||||||
|
// Color transform.
|
||||||
|
ColorTransform colorTransform;
|
||||||
|
nv::Matrix linearTransform;
|
||||||
|
|
||||||
// Mipmap generation options.
|
// Mipmap generation options.
|
||||||
bool generateMipmaps;
|
bool generateMipmaps;
|
||||||
int maxLevel;
|
int maxLevel;
|
||||||
|
@ -73,6 +78,7 @@ namespace nvtt
|
||||||
|
|
||||||
// Cone map options.
|
// Cone map options.
|
||||||
bool convertToConeMap;
|
bool convertToConeMap;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Internal image structure.
|
// Internal image structure.
|
||||||
|
|
|
@ -459,6 +459,14 @@ bool nvtt::compress(const InputOptions & inputOptions, const OutputOptions & out
|
||||||
img = toFixedImage(floatImage.ptr(), inputOptions.m);
|
img = toFixedImage(floatImage.ptr(), inputOptions.m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @@ Where to do the color transform?
|
||||||
|
// - Color transform may not be linear, so we cannot do before computing mipmaps.
|
||||||
|
// - Should be done in linear space, that is, after gamma correction.
|
||||||
|
|
||||||
|
// @@ Error! gamma correction is not performed when mipmap data provied.
|
||||||
|
|
||||||
|
// @@ This code is too complicated, too prone to erros, and hard to understand. Must be simplified!
|
||||||
|
|
||||||
quantize(img, inputOptions.m, format);
|
quantize(img, inputOptions.m, format);
|
||||||
|
|
||||||
compressMipmap(img, outputOptions, compressionOptions.m);
|
compressMipmap(img, outputOptions, compressionOptions.m);
|
||||||
|
|
|
@ -139,7 +139,13 @@ namespace nvtt
|
||||||
MipmapFilter_Kaiser, ///< Kaiser-windowed Sinc filter is the best downsampling filter.
|
MipmapFilter_Kaiser, ///< Kaiser-windowed Sinc filter is the best downsampling filter.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum ColorTransform
|
||||||
|
{
|
||||||
|
ColorTransform_None,
|
||||||
|
ColorTransform_Linear,
|
||||||
|
ColorTransform_CoYCg,
|
||||||
|
ColorTransform_CoSCgY,
|
||||||
|
};
|
||||||
|
|
||||||
/// Input options. Specify format and layout of the input texture.
|
/// Input options. Specify format and layout of the input texture.
|
||||||
struct InputOptions
|
struct InputOptions
|
||||||
|
@ -179,6 +185,10 @@ namespace nvtt
|
||||||
NVTT_API void setNormalFilter(float small, float medium, float big, float large);
|
NVTT_API void setNormalFilter(float small, float medium, float big, float large);
|
||||||
NVTT_API void setNormalizeMipmaps(bool b);
|
NVTT_API void setNormalizeMipmaps(bool b);
|
||||||
|
|
||||||
|
// Set color transforms.
|
||||||
|
NVTT_API void setColorTransform(ColorTransform t);
|
||||||
|
NVTT_API void setLinearTransfrom(int channel, float w0, float w1, float w2, float w3);
|
||||||
|
|
||||||
//private:
|
//private:
|
||||||
struct Private;
|
struct Private;
|
||||||
Private & m;
|
Private & m;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user