Add expand and pack normal methods.

Set normal map flag.
pull/216/head
castano 15 years ago
parent a088ae5789
commit 0878c0e967

@ -758,6 +758,21 @@ void TexImage::scaleBias(int channel, float scale, float bias)
}
}
void TexImage::packNormal()
{
scaleBias(0, 0.5f, 0.5f);
scaleBias(1, 0.5f, 0.5f);
scaleBias(2, 0.5f, 0.5f);
}
void TexImage::expandNormal()
{
scaleBias(0, 2.0f, -1.0f);
scaleBias(1, 2.0f, -1.0f);
scaleBias(2, 2.0f, -1.0f);
}
void TexImage::blend(float red, float green, float blue, float alpha, float t)
{
detach();
@ -909,12 +924,22 @@ void TexImage::toNormalMap(float sm, float medium, float big, float large)
{
detach();
const Vector4 filterWeights(sm, medium, big, large);
foreach (i, m->imageArray)
{
if (m->imageArray[i] == NULL) continue;
// @@ Not implemented.
const FloatImage * img = m->imageArray[i];
m->imageArray[i] = nv::createNormalMap(img, (FloatImage::WrapMode)m->wrapMode, filterWeights);
#pragma messsage(NV_FILE_LINE "Pack and expand normals explicitly")
m->imageArray[i]->packNormals(0);
delete img;
}
m->isNormalMap = true;
}
void TexImage::toHeightMap()
@ -927,6 +952,8 @@ void TexImage::toHeightMap()
// @@ Not implemented.
}
m->isNormalMap = false;
}
void TexImage::normalizeNormalMap()
@ -943,17 +970,6 @@ void TexImage::normalizeNormalMap()
}
}
// Compress.
/*void TexImage::outputCompressed(const CompressionOptions & compressionOptions, const OutputOptions & outputOptions)
{
foreach (i, m->imageArray)
{
if (m->imageArray[i] == NULL) continue;
// @@ Not implemented.
}
}*/
float TexImage::rootMeanSquaredError_rgb(const TexImage & reference) const
{
int totalCount = 0;

@ -424,6 +424,8 @@ namespace nvtt
NVTT_API void transform(const float w0[4], const float w1[4], const float w2[4], const float w3[4], const float offset[4]);
NVTT_API void swizzle(int r, int g, int b, int a);
NVTT_API void scaleBias(int channel, float scale, float bias);
NVTT_API void packNormal();
NVTT_API void expandNormal();
NVTT_API void blend(float r, float g, float b, float a, float t);
NVTT_API void premultiplyAlpha();
NVTT_API void toGreyScale(float redScale, float greenScale, float blueScale, float alphaScale);

Loading…
Cancel
Save