Add mipmap scaling according to alphatest coverage.
This commit is contained in:
@ -112,7 +112,7 @@ void OutputOptions::Private::beginImage(int size, int width, int height, int dep
|
||||
|
||||
bool OutputOptions::Private::writeData(const void * data, int size) const
|
||||
{
|
||||
if (outputHandler != NULL) return outputHandler->writeData(data, size);
|
||||
return outputHandler == NULL || outputHandler->writeData(data, size);
|
||||
}
|
||||
|
||||
void OutputOptions::Private::error(Error e) const
|
||||
|
@ -244,6 +244,29 @@ int TexImage::countMipmaps() const
|
||||
return ::countMipmaps(width(), height(), depth());
|
||||
}
|
||||
|
||||
float TexImage::alphaTestCoverage(float alphaRef/*= 0.5*/) const
|
||||
{
|
||||
int imageCount = 0.0f;
|
||||
float coverage = 0.0f;
|
||||
|
||||
foreach (i, m->imageArray)
|
||||
{
|
||||
FloatImage * img = m->imageArray[i];
|
||||
|
||||
if (img == NULL) continue;
|
||||
|
||||
imageCount++;
|
||||
coverage += img->alphaTestCoverage(alphaRef, 3);
|
||||
}
|
||||
|
||||
if (imageCount > 0) {
|
||||
return coverage / imageCount;
|
||||
}
|
||||
else {
|
||||
return 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool TexImage::load(const char * fileName)
|
||||
{
|
||||
@ -937,6 +960,21 @@ void TexImage::fill(float red, float green, float blue, float alpha)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TexImage::scaleAlphaToCoverage(float coverage, float alphaRef/*= 0.5f*/)
|
||||
{
|
||||
detach();
|
||||
|
||||
foreach (i, m->imageArray)
|
||||
{
|
||||
FloatImage * img = m->imageArray[i];
|
||||
if (img == NULL) continue;
|
||||
|
||||
img->scaleAlphaToCoverage(coverage, alphaRef, 3);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Set normal map options.
|
||||
void TexImage::toNormalMap(float sm, float medium, float big, float large)
|
||||
{
|
||||
|
@ -412,6 +412,7 @@ namespace nvtt
|
||||
NVTT_API AlphaMode alphaMode() const;
|
||||
NVTT_API bool isNormalMap() const;
|
||||
NVTT_API int countMipmaps() const;
|
||||
NVTT_API float alphaTestCoverage(float alphaRef = 0.5) const;
|
||||
|
||||
// Texture data.
|
||||
NVTT_API bool load(const char * fileName);
|
||||
@ -424,7 +425,7 @@ namespace nvtt
|
||||
NVTT_API void resize(int w, int h, ResizeFilter filter);
|
||||
NVTT_API void resize(int maxExtent, RoundMode mode, ResizeFilter filter);
|
||||
NVTT_API bool buildNextMipmap(MipmapFilter filter);
|
||||
|
||||
|
||||
// Color transforms.
|
||||
NVTT_API void toLinear(float gamma);
|
||||
NVTT_API void toGamma(float gamma);
|
||||
@ -438,6 +439,7 @@ namespace nvtt
|
||||
NVTT_API void toGreyScale(float redScale, float greenScale, float blueScale, float alphaScale);
|
||||
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 scaleAlphaToCoverage(float coverage, float alphaRef = 0.5f);
|
||||
|
||||
// Set normal map options.
|
||||
NVTT_API void toNormalMap(float sm, float medium, float big, float large);
|
||||
|
@ -386,7 +386,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
if (nv::strCaseCmp(input.extension(), ".exr") == 0)
|
||||
if (nv::strCaseCmp(input.extension(), ".exr") == 0 || nv::strCaseCmp(input.extension(), ".hdr") == 0)
|
||||
{
|
||||
loadAsFloat = true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user