Add support for linear and swizzle transforms. Fixes issue 4.

This commit is contained in:
castano
2008-05-06 23:21:39 +00:00
parent 94c3fa75a8
commit 48f61dbfc0
5 changed files with 68 additions and 6 deletions

View File

@ -651,9 +651,20 @@ void Compressor::Private::processInputImage(Mipmap & mipmap, const InputOptions:
{
mipmap.toFloatImage(inputOptions);
}
}
// @@ Linear and swizzle color transforms should be done here.
// Apply linear transforms in linear space.
FloatImage * image = mipmap.asFloatImage();
nvDebugCheck(image != NULL);
if (inputOptions.colorTransform == ColorTransform_Linear)
{
image->transform(0, inputOptions.linearTransform);
}
else if (inputOptions.colorTransform == ColorTransform_Swizzle)
{
image->swizzle(0, input.swizzleTransform[0], input.swizzleTransform[1], input.swizzleTransform[2], input.swizzleTransform[3]);
}
}
}

View File

@ -316,10 +316,10 @@ void InputOptions::setSwizzleTransform(int x, int y, int z, int w)
nvCheck(z >= 0 && z < 3);
nvCheck(w >= 0 && w < 3);
// m.xswizzle = x;
// m.yswizzle = y;
// m.zswizzle = z;
// m.wswizzle = w;
m.swizzleTransform[0] = x;
m.swizzleTransform[1] = y;
m.swizzleTransform[2] = z;
m.swizzleTransform[3] = w;
}
void InputOptions::setMaxExtents(int e)

View File

@ -56,6 +56,7 @@ namespace nvtt
// Color transform.
ColorTransform colorTransform;
nv::Matrix linearTransform;
uint swizzleTransform[4];
// Mipmap generation options.
bool generateMipmaps;