Fix normal map mipmap generation.

2.0
castano 17 years ago
parent 5135f30d8e
commit de94fce1ce

@ -15,6 +15,7 @@
<Configurations> <Configurations>
<Configuration <Configuration
Name="Debug|Win32" Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)" IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1" ConfigurationType="1"
> >
@ -170,12 +171,24 @@
RelativePath="..\..\..\src\nvimage\nvtt\tools\cmdline.h" RelativePath="..\..\..\src\nvimage\nvtt\tools\cmdline.h"
> >
</File> </File>
<File
RelativePath=".\resource.h"
>
</File>
</Filter> </Filter>
<Filter <Filter
Name="Resource Files" Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav" Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
> >
<File
RelativePath=".\nvddsinfo.rc"
>
</File>
<File
RelativePath=".\nvidia.ico"
>
</File>
</Filter> </Filter>
</Files> </Files>
<Globals> <Globals>

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

@ -0,0 +1,16 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by nvcompress.rc
//
#define IDI_ICON1 101
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 102
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

@ -212,7 +212,7 @@
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
WarningLevel="3" WarningLevel="3"
Detect64BitPortabilityProblems="true" Detect64BitPortabilityProblems="true"
DebugInformationFormat="3" DebugInformationFormat="0"
/> />
<Tool <Tool
Name="VCManagedResourceCompilerTool" Name="VCManagedResourceCompilerTool"
@ -534,7 +534,7 @@
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
WarningLevel="3" WarningLevel="3"
Detect64BitPortabilityProblems="true" Detect64BitPortabilityProblems="true"
DebugInformationFormat="3" DebugInformationFormat="0"
/> />
<Tool <Tool
Name="VCManagedResourceCompilerTool" Name="VCManagedResourceCompilerTool"

@ -181,7 +181,7 @@ void FloatImage::packNormals(uint base_component)
void FloatImage::expandNormals(uint base_component) void FloatImage::expandNormals(uint base_component)
{ {
scaleBias(base_component, 3, 2, 0.5); scaleBias(base_component, 3, 2, -0.5);
} }
void FloatImage::scaleBias(uint base_component, uint num, float scale, float bias) void FloatImage::scaleBias(uint base_component, uint num, float scale, float bias)

@ -133,6 +133,8 @@ FloatImage * nv::createNormalMap(const Image * img, FloatImage::WrapMode wm, Vec
void nv::normalize(FloatImage * img) void nv::normalize(FloatImage * img)
{ {
nvCheck(img != NULL); nvCheck(img != NULL);
img->expandNormals(0);
img->normalize(0); img->normalize(0);
img->packNormals(0);
} }

@ -226,6 +226,12 @@ void InputOptions::setQuantization(bool colorDithering, bool alphaDithering, boo
} }
/// Indicate whether input is a normal map or not.
void InputOptions::setNormalMap(bool b)
{
m.normalMap = b;
}
/// Enable normal map conversion. /// Enable normal map conversion.
void InputOptions::setConvertToNormalMap(bool convert) void InputOptions::setConvertToNormalMap(bool convert)
{ {

@ -1,24 +1,24 @@
// Copyright NVIDIA Corporation 2007 -- Ignacio Castano <icastano@nvidia.com> // Copyright NVIDIA Corporation 2007 -- Ignacio Castano <icastano@nvidia.com>
// //
// Permission is hereby granted, free of charge, to any person // Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation // obtaining a copy of this software and associated documentation
// files (the "Software"), to deal in the Software without // files (the "Software"), to deal in the Software without
// restriction, including without limitation the rights to use, // restriction, including without limitation the rights to use,
// copy, modify, merge, publish, distribute, sublicense, and/or sell // copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the // copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following // Software is furnished to do so, subject to the following
// conditions: // conditions:
// //
// The above copyright notice and this permission notice shall be // The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software. // included in all copies or substantial portions of the Software.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, // HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
// OTHER DEALINGS IN THE SOFTWARE. // OTHER DEALINGS IN THE SOFTWARE.
#ifndef NV_TT_INPUTOPTIONS_H #ifndef NV_TT_INPUTOPTIONS_H
@ -64,6 +64,7 @@ namespace nvtt
MipmapFilter mipmapFilter; MipmapFilter mipmapFilter;
// Normal map options. // Normal map options.
bool normalMap;
bool normalizeMipmaps; bool normalizeMipmaps;
bool convertToNormalMap; bool convertToNormalMap;
nv::Vector4 heightFactors; nv::Vector4 heightFactors;

@ -255,8 +255,14 @@ static FloatImage * toFloatImage(const Image * image, const InputOptions::Privat
FloatImage * floatImage = new FloatImage(image); FloatImage * floatImage = new FloatImage(image);
// Convert to linear space. if (inputOptions.normalMap)
if (inputOptions.inputGamma != 1.0f) { {
// Expand normals. to [-1, 1] range.
// floatImage->expandNormals(0);
}
else if (inputOptions.inputGamma != 1.0f)
{
// Convert to linear space.
floatImage->toLinear(0, 3, inputOptions.inputGamma); floatImage->toLinear(0, 3, inputOptions.inputGamma);
} }

@ -172,6 +172,7 @@ namespace nvtt
NVTT_API void setQuantization(bool colorDithering, bool alphaDithering, bool binaryAlpha, int alphaThreshold = 127); NVTT_API void setQuantization(bool colorDithering, bool alphaDithering, bool binaryAlpha, int alphaThreshold = 127);
// Set normal map options. // Set normal map options.
NVTT_API void setNormalMap(bool b);
NVTT_API void setConvertToNormalMap(bool convert); NVTT_API void setConvertToNormalMap(bool convert);
NVTT_API void setHeightEvaluation(float redScale, float greenScale, float blueScale, float alphaScale); NVTT_API void setHeightEvaluation(float redScale, float greenScale, float blueScale, float alphaScale);
NVTT_API void setNormalFilter(float small, float medium, float big, float large); NVTT_API void setNormalFilter(float small, float medium, float big, float large);

@ -98,6 +98,7 @@ struct MyErrorHandler : public nvtt::ErrorHandler
// Set color to normal map conversion options. // Set color to normal map conversion options.
void setColorToNormalMap(nvtt::InputOptions & inputOptions) void setColorToNormalMap(nvtt::InputOptions & inputOptions)
{ {
inputOptions.setNormalMap(false);
inputOptions.setConvertToNormalMap(true); inputOptions.setConvertToNormalMap(true);
inputOptions.setHeightEvaluation(1.0f/3.0f, 1.0f/3.0f, 1.0f/3.0f, 0.0f); inputOptions.setHeightEvaluation(1.0f/3.0f, 1.0f/3.0f, 1.0f/3.0f, 0.0f);
//inputOptions.setNormalFilter(1.0f, 0, 0, 0); //inputOptions.setNormalFilter(1.0f, 0, 0, 0);
@ -109,6 +110,7 @@ void setColorToNormalMap(nvtt::InputOptions & inputOptions)
// Set options for normal maps. // Set options for normal maps.
void setNormalMap(nvtt::InputOptions & inputOptions) void setNormalMap(nvtt::InputOptions & inputOptions)
{ {
inputOptions.setNormalMap(true);
inputOptions.setConvertToNormalMap(false); inputOptions.setConvertToNormalMap(false);
inputOptions.setGamma(1.0f, 1.0f); inputOptions.setGamma(1.0f, 1.0f);
inputOptions.setNormalizeMipmaps(true); inputOptions.setNormalizeMipmaps(true);
@ -117,6 +119,7 @@ void setNormalMap(nvtt::InputOptions & inputOptions)
// Set options for color maps. // Set options for color maps.
void setColorMap(nvtt::InputOptions & inputOptions) void setColorMap(nvtt::InputOptions & inputOptions)
{ {
inputOptions.setNormalMap(false);
inputOptions.setConvertToNormalMap(false); inputOptions.setConvertToNormalMap(false);
inputOptions.setGamma(2.2f, 2.2f); inputOptions.setGamma(2.2f, 2.2f);
inputOptions.setNormalizeMipmaps(false); inputOptions.setNormalizeMipmaps(false);
@ -333,7 +336,8 @@ int main(int argc, char *argv[])
} }
else else
{ {
inputOptions.setMipmapping(true, nvtt::MipmapFilter_Kaiser); inputOptions.setMipmapping(true, nvtt::MipmapFilter_Box);
//inputOptions.setMipmapping(true, nvtt::MipmapFilter_Kaiser);
} }
if (wrapRepeat) if (wrapRepeat)

Loading…
Cancel
Save