Jump to content

Invert Normal Map


Recommended Posts

About


This resource will flip(invert) the green channel of the normal map. It doesn't actually touch the image but will invert the expanded normal map's green channel in the pixel shader. In other words it will flip the direction of the bumps in your normal map. I have not modified the GUI here so it's script only. Only tested on advanced lighting


Material Script Usage

 

invertNormalMap = true;

 

Implementation


Source File: Engine/source/materials/materialFeatureTypes.h

After Line: 89

/// This feature flips the green channel of the normal map
DeclareFeatureType( MFT_InvertNormalMap );

 

Source File: Engine/source/materials/materialFeatureTypes.cpp

After Line: 62

ImplementFeatureType( MFT_InvertNormalMap, U32(-1), -1, true );

 

Source File: Engine/source/materials/materialDefinition.h

After Line: 282

bool mInvertNormalMap;

 

Source File: Engine/source/materials/materialDefinition.cpp

After Line: 197

mInvertNormalMap = false;
After Line: 367

addField( "invertNormalMap", TypeBool, Offset(mInvertNormalMap, Material),
   "If true this will flip(invert) the normal map/s green channel of this material." );

 

Source File: Engine/source/materials/processedShaderMaterial.cpp

After Line: 388

if(mMaterial->mInvertNormalMap)
   fd.features.addFeature( MFT_InvertNormalMap );

 

Source File: Engine/source/renderInstance/renderPrePassMgr.cpp

After Line: 554

type == MFT_InvertNormalMap ||

 

Source File: Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp

After Line: 178

if( fd.features.hasFeature( MFT_InvertNormalMap ))
   meta->addStatement( new GenOp( "   @.y *= -1.0;\r\n", normalVar ) );

 

Source File: Engine/source/shaderGen/HLSL/shaderGenHLSLInit.cpp

After Line: 48

FEATUREMGR->registerFeature( MFT_InvertNormalMap, new NamedFeatureHLSL( "Invert Normal Map" ) );

 

Consequences


This will create yet another shader permutation in the ShaderGen system.

Edited by Timmy
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...