Fix normal map mipmap generation.
This commit is contained in:
parent
5135f30d8e
commit
de94fce1ce
Binary file not shown.
BIN
project/vc8/nvddsinfo/nvddsinfo.rc
Normal file
BIN
project/vc8/nvddsinfo/nvddsinfo.rc
Normal file
Binary file not shown.
@ -15,6 +15,7 @@
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
>
|
||||
@ -170,12 +171,24 @@
|
||||
RelativePath="..\..\..\src\nvimage\nvtt\tools\cmdline.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\resource.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
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}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\nvddsinfo.rc"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\nvidia.ico"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
|
BIN
project/vc8/nvddsinfo/nvidia.ico
Normal file
BIN
project/vc8/nvddsinfo/nvidia.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
16
project/vc8/nvddsinfo/resource.h
Normal file
16
project/vc8/nvddsinfo/resource.h
Normal file
@ -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"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
DebugInformationFormat="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
@ -534,7 +534,7 @@
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
DebugInformationFormat="3"
|
||||
DebugInformationFormat="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
|
@ -181,7 +181,7 @@ void FloatImage::packNormals(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)
|
||||
|
@ -133,6 +133,8 @@ FloatImage * nv::createNormalMap(const Image * img, FloatImage::WrapMode wm, Vec
|
||||
void nv::normalize(FloatImage * img)
|
||||
{
|
||||
nvCheck(img != NULL);
|
||||
img->expandNormals(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.
|
||||
void InputOptions::setConvertToNormalMap(bool convert)
|
||||
{
|
||||
|
@ -1,24 +1,24 @@
|
||||
// Copyright NVIDIA Corporation 2007 -- Ignacio Castano <icastano@nvidia.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the "Software"), to deal in the Software without
|
||||
// restriction, including without limitation the rights to use,
|
||||
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following
|
||||
// conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
// Copyright NVIDIA Corporation 2007 -- Ignacio Castano <icastano@nvidia.com>
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person
|
||||
// obtaining a copy of this software and associated documentation
|
||||
// files (the "Software"), to deal in the Software without
|
||||
// restriction, including without limitation the rights to use,
|
||||
// copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the
|
||||
// Software is furnished to do so, subject to the following
|
||||
// conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be
|
||||
// included in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
// OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
#ifndef NV_TT_INPUTOPTIONS_H
|
||||
@ -64,6 +64,7 @@ namespace nvtt
|
||||
MipmapFilter mipmapFilter;
|
||||
|
||||
// Normal map options.
|
||||
bool normalMap;
|
||||
bool normalizeMipmaps;
|
||||
bool convertToNormalMap;
|
||||
nv::Vector4 heightFactors;
|
||||
|
@ -255,8 +255,14 @@ static FloatImage * toFloatImage(const Image * image, const InputOptions::Privat
|
||||
|
||||
FloatImage * floatImage = new FloatImage(image);
|
||||
|
||||
// Convert to linear space.
|
||||
if (inputOptions.inputGamma != 1.0f) {
|
||||
if (inputOptions.normalMap)
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
@ -172,6 +172,7 @@ namespace nvtt
|
||||
NVTT_API void setQuantization(bool colorDithering, bool alphaDithering, bool binaryAlpha, int alphaThreshold = 127);
|
||||
|
||||
// Set normal map options.
|
||||
NVTT_API void setNormalMap(bool b);
|
||||
NVTT_API void setConvertToNormalMap(bool convert);
|
||||
NVTT_API void setHeightEvaluation(float redScale, float greenScale, float blueScale, float alphaScale);
|
||||
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.
|
||||
void setColorToNormalMap(nvtt::InputOptions & inputOptions)
|
||||
{
|
||||
inputOptions.setNormalMap(false);
|
||||
inputOptions.setConvertToNormalMap(true);
|
||||
inputOptions.setHeightEvaluation(1.0f/3.0f, 1.0f/3.0f, 1.0f/3.0f, 0.0f);
|
||||
//inputOptions.setNormalFilter(1.0f, 0, 0, 0);
|
||||
@ -109,6 +110,7 @@ void setColorToNormalMap(nvtt::InputOptions & inputOptions)
|
||||
// Set options for normal maps.
|
||||
void setNormalMap(nvtt::InputOptions & inputOptions)
|
||||
{
|
||||
inputOptions.setNormalMap(true);
|
||||
inputOptions.setConvertToNormalMap(false);
|
||||
inputOptions.setGamma(1.0f, 1.0f);
|
||||
inputOptions.setNormalizeMipmaps(true);
|
||||
@ -117,6 +119,7 @@ void setNormalMap(nvtt::InputOptions & inputOptions)
|
||||
// Set options for color maps.
|
||||
void setColorMap(nvtt::InputOptions & inputOptions)
|
||||
{
|
||||
inputOptions.setNormalMap(false);
|
||||
inputOptions.setConvertToNormalMap(false);
|
||||
inputOptions.setGamma(2.2f, 2.2f);
|
||||
inputOptions.setNormalizeMipmaps(false);
|
||||
@ -333,7 +336,8 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
else
|
||||
{
|
||||
inputOptions.setMipmapping(true, nvtt::MipmapFilter_Kaiser);
|
||||
inputOptions.setMipmapping(true, nvtt::MipmapFilter_Box);
|
||||
//inputOptions.setMipmapping(true, nvtt::MipmapFilter_Kaiser);
|
||||
}
|
||||
|
||||
if (wrapRepeat)
|
||||
|
Loading…
Reference in New Issue
Block a user