mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-11 22:54:34 +00:00
Merge pull request #148 from Azaezel/alpha40TerainLayerHack
'fixes' terrain normal blending for tightly grouped >4 layer scenarios
This commit is contained in:
commit
2a01d8a651
2 changed files with 54 additions and 26 deletions
|
|
@ -1019,19 +1019,28 @@ void TerrainNormalMapFeatGLSL::processPix( Vector<ShaderComponent*> &component
|
||||||
LangElement *bumpNormDecl = new DecOp( bumpNorm );
|
LangElement *bumpNormDecl = new DecOp( bumpNorm );
|
||||||
meta->addStatement( expandNormalMap( texOp, bumpNormDecl, bumpNorm, fd ) );
|
meta->addStatement( expandNormalMap( texOp, bumpNormDecl, bumpNorm, fd ) );
|
||||||
|
|
||||||
// Normalize is done later...
|
|
||||||
// Note: The reverse mul order is intentional. Affine matrix.
|
|
||||||
meta->addStatement( new GenOp( " @ = lerp( @, tMul( @.xyz, @ ), min( @, @.w ) );\r\n",
|
|
||||||
gbNormal, gbNormal, bumpNorm, viewToTangent, detailBlend, inDet ) );
|
|
||||||
|
|
||||||
// End the conditional block.
|
|
||||||
meta->addStatement( new GenOp( " }\r\n" ) );
|
|
||||||
|
|
||||||
// If this is the last normal map then we
|
// If this is the last normal map then we
|
||||||
// can test to see the total blend value
|
// can test to see the total blend value
|
||||||
// to see if we should clip the result.
|
// to see if we should clip the result.
|
||||||
//if ( fd.features.getNextFeatureIndex( MFT_TerrainNormalMap, normalIndex ) == -1 )
|
Var* blendTotal = (Var*)LangElement::find("blendTotal");
|
||||||
//meta->addStatement( new GenOp( " clip( @ - 0.0001f );\r\n", blendTotal ) );
|
if (blendTotal)
|
||||||
|
{
|
||||||
|
if (fd.features.getNextFeatureIndex(MFT_TerrainNormalMap, normalIndex) == -1)
|
||||||
|
meta->addStatement(new GenOp(" if ( @ > 0.0001f ){\r\n\r\n", blendTotal));
|
||||||
|
}
|
||||||
|
// Normalize is done later...
|
||||||
|
// Note: The reverse mul order is intentional. Affine matrix.
|
||||||
|
meta->addStatement(new GenOp(" @ = lerp( @, mul( @.xyz, @ ), min( @, @.w ) );\r\n",
|
||||||
|
gbNormal, gbNormal, bumpNorm, viewToTangent, detailBlend, inDet));
|
||||||
|
|
||||||
|
if (blendTotal)
|
||||||
|
{
|
||||||
|
if (fd.features.getNextFeatureIndex(MFT_TerrainNormalMap, normalIndex) == -1)
|
||||||
|
meta->addStatement(new GenOp(" }\r\n"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// End the conditional block.
|
||||||
|
meta->addStatement( new GenOp( " }\r\n" ) );
|
||||||
|
|
||||||
output = meta;
|
output = meta;
|
||||||
}
|
}
|
||||||
|
|
@ -1103,11 +1112,12 @@ void TerrainAdditiveFeatGLSL::processPix( Vector<ShaderComponent*> &componentLis
|
||||||
const MaterialFeatureData &fd )
|
const MaterialFeatureData &fd )
|
||||||
{
|
{
|
||||||
Var *color = NULL;
|
Var *color = NULL;
|
||||||
|
Var* norm = NULL;
|
||||||
if (fd.features[MFT_isDeferred])
|
if (fd.features[MFT_isDeferred])
|
||||||
{
|
{
|
||||||
color = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget1) );
|
color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget1));
|
||||||
|
norm = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
|
||||||
}
|
}
|
||||||
else
|
|
||||||
color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
|
color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
|
||||||
|
|
||||||
Var *blendTotal = (Var*)LangElement::find( "blendTotal" );
|
Var *blendTotal = (Var*)LangElement::find( "blendTotal" );
|
||||||
|
|
@ -1118,6 +1128,10 @@ void TerrainAdditiveFeatGLSL::processPix( Vector<ShaderComponent*> &componentLis
|
||||||
|
|
||||||
meta->addStatement( new GenOp( " clip( @ - 0.0001 );\r\n", blendTotal ) );
|
meta->addStatement( new GenOp( " clip( @ - 0.0001 );\r\n", blendTotal ) );
|
||||||
meta->addStatement( new GenOp( " @.a = @;\r\n", color, blendTotal ) );
|
meta->addStatement( new GenOp( " @.a = @;\r\n", color, blendTotal ) );
|
||||||
|
if (fd.features[MFT_isDeferred])
|
||||||
|
{
|
||||||
|
meta->addStatement(new GenOp(" @.a = @;\r\n", norm, blendTotal));
|
||||||
|
}
|
||||||
|
|
||||||
output = meta;
|
output = meta;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1028,19 +1028,27 @@ void TerrainNormalMapFeatHLSL::processPix( Vector<ShaderComponent*> &component
|
||||||
LangElement *bumpNormDecl = new DecOp( bumpNorm );
|
LangElement *bumpNormDecl = new DecOp( bumpNorm );
|
||||||
meta->addStatement( expandNormalMap( texOp, bumpNormDecl, bumpNorm, fd ) );
|
meta->addStatement( expandNormalMap( texOp, bumpNormDecl, bumpNorm, fd ) );
|
||||||
|
|
||||||
// Normalize is done later...
|
|
||||||
// Note: The reverse mul order is intentional. Affine matrix.
|
|
||||||
meta->addStatement( new GenOp( " @ = lerp( @, mul( @.xyz, @ ), min( @, @.w ) );\r\n",
|
|
||||||
gbNormal, gbNormal, bumpNorm, viewToTangent, detailBlend, inDet ) );
|
|
||||||
|
|
||||||
// End the conditional block.
|
|
||||||
meta->addStatement( new GenOp( " }\r\n" ) );
|
|
||||||
|
|
||||||
// If this is the last normal map then we
|
// If this is the last normal map then we
|
||||||
// can test to see the total blend value
|
// can test to see the total blend value
|
||||||
// to see if we should clip the result.
|
// to see if we should clip the result.
|
||||||
//if ( fd.features.getNextFeatureIndex( MFT_TerrainNormalMap, normalIndex ) == -1 )
|
Var* blendTotal = (Var*)LangElement::find("blendTotal");
|
||||||
//meta->addStatement( new GenOp( " clip( @ - 0.0001f );\r\n", blendTotal ) );
|
if (blendTotal)
|
||||||
|
{
|
||||||
|
if (fd.features.getNextFeatureIndex(MFT_TerrainNormalMap, normalIndex) == -1)
|
||||||
|
meta->addStatement(new GenOp(" if ( @ > 0.0001f ){\r\n\r\n", blendTotal));
|
||||||
|
}
|
||||||
|
// Normalize is done later...
|
||||||
|
// Note: The reverse mul order is intentional. Affine matrix.
|
||||||
|
meta->addStatement( new GenOp( " @ = lerp( @, mul( @.xyz, @ ), min( @, @.w ) );\r\n",
|
||||||
|
gbNormal, gbNormal, bumpNorm, viewToTangent, detailBlend, inDet ) );
|
||||||
|
|
||||||
|
if (blendTotal)
|
||||||
|
{
|
||||||
|
if (fd.features.getNextFeatureIndex(MFT_TerrainNormalMap, normalIndex) == -1)
|
||||||
|
meta->addStatement(new GenOp(" }\r\n"));
|
||||||
|
}
|
||||||
|
// End the conditional block.
|
||||||
|
meta->addStatement( new GenOp( " }\r\n" ) );
|
||||||
|
|
||||||
output = meta;
|
output = meta;
|
||||||
}
|
}
|
||||||
|
|
@ -1112,9 +1120,11 @@ void TerrainAdditiveFeatHLSL::processPix( Vector<ShaderComponent*> &componentLis
|
||||||
const MaterialFeatureData &fd )
|
const MaterialFeatureData &fd )
|
||||||
{
|
{
|
||||||
Var *color = NULL;
|
Var *color = NULL;
|
||||||
|
Var* norm = NULL;
|
||||||
if (fd.features[MFT_isDeferred])
|
if (fd.features[MFT_isDeferred])
|
||||||
{
|
{
|
||||||
color = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget1) );
|
color = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget1) );
|
||||||
|
norm = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::DefaultTarget) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
color = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::DefaultTarget) );
|
color = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::DefaultTarget) );
|
||||||
|
|
@ -1127,6 +1137,10 @@ void TerrainAdditiveFeatHLSL::processPix( Vector<ShaderComponent*> &componentLis
|
||||||
|
|
||||||
meta->addStatement( new GenOp( " clip( @ - 0.0001 );\r\n", blendTotal ) );
|
meta->addStatement( new GenOp( " clip( @ - 0.0001 );\r\n", blendTotal ) );
|
||||||
meta->addStatement( new GenOp( " @.a = @;\r\n", color, blendTotal ) );
|
meta->addStatement( new GenOp( " @.a = @;\r\n", color, blendTotal ) );
|
||||||
|
if (fd.features[MFT_isDeferred])
|
||||||
|
{
|
||||||
|
meta->addStatement(new GenOp(" @.a = @;\r\n", norm, blendTotal));
|
||||||
|
}
|
||||||
|
|
||||||
output = meta;
|
output = meta;
|
||||||
}
|
}
|
||||||
|
|
@ -1226,7 +1240,7 @@ void TerrainCompositeMapFeatHLSL::processVert(Vector<ShaderComponent*> &componen
|
||||||
|
|
||||||
U32 TerrainCompositeMapFeatHLSL::getOutputTargets(const MaterialFeatureData &fd) const
|
U32 TerrainCompositeMapFeatHLSL::getOutputTargets(const MaterialFeatureData &fd) const
|
||||||
{
|
{
|
||||||
return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::RenderTarget1;
|
return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::DefaultTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TerrainCompositeMapFeatHLSL::processPix(Vector<ShaderComponent*> &componentList,
|
void TerrainCompositeMapFeatHLSL::processPix(Vector<ShaderComponent*> &componentList,
|
||||||
|
|
@ -1264,7 +1278,7 @@ void TerrainCompositeMapFeatHLSL::processPix(Vector<ShaderComponent*> &component
|
||||||
|
|
||||||
// search for material var
|
// search for material var
|
||||||
Var * pbrConfig;
|
Var * pbrConfig;
|
||||||
OutputTarget targ = RenderTarget1;
|
OutputTarget targ = DefaultTarget;
|
||||||
if (fd.features[MFT_isDeferred])
|
if (fd.features[MFT_isDeferred])
|
||||||
{
|
{
|
||||||
targ = RenderTarget2;
|
targ = RenderTarget2;
|
||||||
|
|
@ -1317,7 +1331,7 @@ ShaderFeature::Resources TerrainCompositeMapFeatHLSL::getResources(const Materia
|
||||||
// reminder, the matinfo buffer is flags, smooth, ao, metal
|
// reminder, the matinfo buffer is flags, smooth, ao, metal
|
||||||
U32 TerrainBlankInfoMapFeatHLSL::getOutputTargets(const MaterialFeatureData &fd) const
|
U32 TerrainBlankInfoMapFeatHLSL::getOutputTargets(const MaterialFeatureData &fd) const
|
||||||
{
|
{
|
||||||
return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::RenderTarget1;
|
return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::DefaultTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TerrainBlankInfoMapFeatHLSL::processPix(Vector<ShaderComponent*> &componentList,
|
void TerrainBlankInfoMapFeatHLSL::processPix(Vector<ShaderComponent*> &componentList,
|
||||||
|
|
@ -1325,7 +1339,7 @@ void TerrainBlankInfoMapFeatHLSL::processPix(Vector<ShaderComponent*> &component
|
||||||
{
|
{
|
||||||
// search for material var
|
// search for material var
|
||||||
Var *material;
|
Var *material;
|
||||||
OutputTarget targ = RenderTarget1;
|
OutputTarget targ = DefaultTarget;
|
||||||
if (fd.features[MFT_isDeferred])
|
if (fd.features[MFT_isDeferred])
|
||||||
{
|
{
|
||||||
targ = RenderTarget2;
|
targ = RenderTarget2;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue