HACKALERT: eat the low bit of the depth map to store off a copy of the blend total for norm|depth layer blending when layers exceed single passes. really should hunt down root causality there...

This commit is contained in:
AzaezelX 2020-03-08 17:25:27 -05:00
parent 9c381caea2
commit 9beaba0e60
2 changed files with 54 additions and 26 deletions

View file

@ -1019,19 +1019,28 @@ void TerrainNormalMapFeatGLSL::processPix( Vector<ShaderComponent*> &component
LangElement *bumpNormDecl = new DecOp( bumpNorm );
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
// can test to see the total blend value
// to see if we should clip the result.
//if ( fd.features.getNextFeatureIndex( MFT_TerrainNormalMap, normalIndex ) == -1 )
//meta->addStatement( new GenOp( " clip( @ - 0.0001f );\r\n", blendTotal ) );
Var* blendTotal = (Var*)LangElement::find("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;
}
@ -1103,11 +1112,12 @@ void TerrainAdditiveFeatGLSL::processPix( Vector<ShaderComponent*> &componentLis
const MaterialFeatureData &fd )
{
Var *color = NULL;
Var* norm = NULL;
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));
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( " @.a = @;\r\n", color, blendTotal ) );
if (fd.features[MFT_isDeferred])
{
meta->addStatement(new GenOp(" @.a = @;\r\n", norm, blendTotal));
}
output = meta;
}