Fix some messages. Add support for range scaling in TexImage.
This commit is contained in:
parent
47df8ff7d6
commit
09e46ead48
@ -563,7 +563,7 @@ bool nv::ImageIO::saveFreeImage(FREE_IMAGE_FORMAT fif, Stream & s, const Image *
|
|||||||
|
|
||||||
if (tags != NULL)
|
if (tags != NULL)
|
||||||
{
|
{
|
||||||
#pragma message(NV_FILE_LINE "TODO: Save image metadata")
|
#pragma NV_MESSAGE("TODO: Save image metadata")
|
||||||
//FreeImage_SetMetadata(
|
//FreeImage_SetMetadata(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1463,7 +1463,7 @@ CompressorInterface * Compressor::Private::chooseGpuCompressor(const Compression
|
|||||||
}
|
}
|
||||||
else if (compressionOptions.format == Format_DXT1a)
|
else if (compressionOptions.format == Format_DXT1a)
|
||||||
{
|
{
|
||||||
#pragma message(NV_FILE_LINE "TODO: Implement CUDA DXT1a compressor.")
|
#pragma NV_MESSAGE("TODO: Implement CUDA DXT1a compressor.")
|
||||||
}
|
}
|
||||||
else if (compressionOptions.format == Format_DXT1n)
|
else if (compressionOptions.format == Format_DXT1n)
|
||||||
{
|
{
|
||||||
|
@ -999,6 +999,54 @@ void TexImage::scaleAlphaToCoverage(float coverage, float alphaRef/*= 0.5f*/)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TexImage::normalizeRange(float * rangeMin, float * rangeMax)
|
||||||
|
{
|
||||||
|
Vector2 range(FLT_MAX, -FLT_MAX);
|
||||||
|
|
||||||
|
// Compute range.
|
||||||
|
foreach (i, m->imageArray) {
|
||||||
|
FloatImage * img = m->imageArray[i];
|
||||||
|
if (img == NULL) continue;
|
||||||
|
|
||||||
|
const uint count = img->count();
|
||||||
|
for (uint p = 0; p < count; p++) {
|
||||||
|
float c = img->pixel(p);
|
||||||
|
|
||||||
|
if (c < range.x) range.x = c;
|
||||||
|
if (c > range.y) range.y = c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (range.x == range.y) {
|
||||||
|
// Single color image.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
*rangeMin = range.x;
|
||||||
|
*rangeMax = range.y;
|
||||||
|
|
||||||
|
const float scale = 1.0f / (range.y - range.x);
|
||||||
|
const float bias = range.x * scale;
|
||||||
|
|
||||||
|
if (scale == 1.0f && bias == 0.0f) {
|
||||||
|
// Already normalized.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
detach();
|
||||||
|
|
||||||
|
// Scale to range.
|
||||||
|
foreach (i, m->imageArray) {
|
||||||
|
FloatImage * img = m->imageArray[i];
|
||||||
|
if (img == NULL) continue;
|
||||||
|
|
||||||
|
img->scaleBias(0, 4, scale, bias);
|
||||||
|
//img->clamp(0, 4, 0.0f, 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Set normal map options.
|
// Set normal map options.
|
||||||
void TexImage::toNormalMap(float sm, float medium, float big, float large)
|
void TexImage::toNormalMap(float sm, float medium, float big, float large)
|
||||||
|
@ -444,6 +444,7 @@ namespace nvtt
|
|||||||
NVTT_API void setBorder(float r, float g, float b, float a);
|
NVTT_API void setBorder(float r, float g, float b, float a);
|
||||||
NVTT_API void fill(float r, float g, float b, float a);
|
NVTT_API void fill(float r, float g, float b, float a);
|
||||||
NVTT_API void scaleAlphaToCoverage(float coverage, float alphaRef = 0.5f);
|
NVTT_API void scaleAlphaToCoverage(float coverage, float alphaRef = 0.5f);
|
||||||
|
NVTT_API bool normalizeRange(float * rangeMin, float * rangeMax);
|
||||||
|
|
||||||
// Set normal map options.
|
// Set normal map options.
|
||||||
NVTT_API void toNormalMap(float sm, float medium, float big, float large);
|
NVTT_API void toNormalMap(float sm, float medium, float big, float large);
|
||||||
|
@ -373,8 +373,8 @@ int main(int argc, char *argv[])
|
|||||||
printf(" 1: \tWaterloo.\n");
|
printf(" 1: \tWaterloo.\n");
|
||||||
printf(" 2: \tEpic.\n");
|
printf(" 2: \tEpic.\n");
|
||||||
printf(" 3: \tFarbrausch.\n");
|
printf(" 3: \tFarbrausch.\n");
|
||||||
printf(" 4: \Lugaru.\n");
|
printf(" 4: \tLugaru.\n");
|
||||||
printf(" 5: \Quake 3.\n");
|
printf(" 5: \tQuake 3.\n");
|
||||||
printf(" -dec x \tDecompressor.\n");
|
printf(" -dec x \tDecompressor.\n");
|
||||||
printf(" 0: \tReference.\n");
|
printf(" 0: \tReference.\n");
|
||||||
printf(" 1: \tNVIDIA.\n");
|
printf(" 1: \tNVIDIA.\n");
|
||||||
|
Loading…
Reference in New Issue
Block a user