mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
Merge pull request #549 from Azaezel/alpha40/shadergenCleanups
be clear where we're referencing gbuffer render targets
This commit is contained in:
commit
fdcb4c033c
|
|
@ -55,7 +55,7 @@ void AccuTexFeatGLSL::processPix(Vector<ShaderComponent*> &componentList,
|
|||
output = meta;
|
||||
|
||||
// OUT.col
|
||||
Var *color = (Var*) LangElement::find( "col1" );
|
||||
Var *color = (Var*) LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget1));
|
||||
if (!color)
|
||||
{
|
||||
output = new GenOp(" //NULL COLOR!");
|
||||
|
|
@ -236,4 +236,4 @@ Var* AccuTexFeatGLSL::addOutAccuVec(Vector<ShaderComponent*> &componentList, Mul
|
|||
}
|
||||
|
||||
return outAccuVec;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -452,7 +452,7 @@ void NormalsOutFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
}
|
||||
|
||||
LangElement *normalOut;
|
||||
Var *outColor = (Var*)LangElement::find( "col" );
|
||||
Var *outColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
|
||||
if ( outColor && !fd.features[MFT_AlphaTest] )
|
||||
normalOut = new GenOp( "float4( ( -@ + 1 ) * 0.5, @.a )", wsNormal, outColor );
|
||||
else
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ void DebugVizGLSL::processPix(Vector<ShaderComponent*>& componentList,
|
|||
|
||||
if (surface && (vizDisplayMode == 0 || vizDisplayMode == 1))
|
||||
{
|
||||
Var* color = (Var*)LangElement::find("col");
|
||||
Var* color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
|
||||
if (color)
|
||||
{
|
||||
Var* specularColor = (Var*)LangElement::find("specularColor");
|
||||
|
|
|
|||
|
|
@ -1181,13 +1181,13 @@ void DiffuseFeatureGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
diffuseMaterialColor->constSortPos = cspPotentialPrimitive;
|
||||
|
||||
MultiLine* meta = new MultiLine;
|
||||
Var *col = (Var*)LangElement::find("col");
|
||||
Var *col = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
|
||||
ShaderFeature::OutputTarget targ = ShaderFeature::DefaultTarget;
|
||||
if (fd.features[MFT_isDeferred])
|
||||
{
|
||||
targ = ShaderFeature::RenderTarget1;
|
||||
|
||||
col = (Var*)LangElement::find("col1");
|
||||
col = (Var*)LangElement::find(getOutputTargetVarName(targ));
|
||||
meta = new MultiLine;
|
||||
if (!col)
|
||||
{
|
||||
|
|
@ -1196,7 +1196,7 @@ void DiffuseFeatureGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
col->setType("vec4");
|
||||
col->setName(getOutputTargetVarName(targ));
|
||||
col->setStructName("OUT");
|
||||
meta->addStatement(new GenOp(" @ = vec4(1.0);\r\n", col));
|
||||
meta->addStatement(new GenOp(" @ = vec4(1.0,1.0,1.0,1.0);\r\n", col));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2334,7 +2334,7 @@ void FogFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
fogColor->constSortPos = cspPass;
|
||||
|
||||
// Get the out color.
|
||||
Var *color = (Var*) LangElement::find( "col" );
|
||||
Var *color = (Var*) LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
|
||||
if ( !color )
|
||||
{
|
||||
color = new Var;
|
||||
|
|
@ -2466,7 +2466,7 @@ void VisibilityFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
// Translucent objects do a simple alpha fade.
|
||||
if ( fd.features[ MFT_IsTranslucent ] )
|
||||
{
|
||||
Var *color = (Var*) LangElement::find( "col" );
|
||||
Var *color = (Var*) LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
|
||||
meta->addStatement( new GenOp( " @.a *= @;\r\n", color, visibility ) );
|
||||
return;
|
||||
}
|
||||
|
|
@ -2507,9 +2507,9 @@ void AlphaTestGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
}
|
||||
|
||||
// If we don't have a color var then we cannot do an alpha test.
|
||||
Var *color = (Var*)LangElement::find( "col1" );
|
||||
Var *color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget1) );
|
||||
if ( !color )
|
||||
color = (Var*)LangElement::find("col");
|
||||
color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
|
||||
if ( !color )
|
||||
{
|
||||
output = NULL;
|
||||
|
|
@ -2542,7 +2542,7 @@ void GlowMaskGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
//
|
||||
// The shader compiler will optimize out all the other
|
||||
// code above that doesn't contribute to the alpha mask.
|
||||
Var *color = (Var*)LangElement::find( "col" );
|
||||
Var *color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
|
||||
if ( color )
|
||||
output = new GenOp( " @.rgb = vec3(0);\r\n", color );
|
||||
}
|
||||
|
|
@ -2574,7 +2574,7 @@ void HDROutGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
const MaterialFeatureData &fd )
|
||||
{
|
||||
// Let the helper function do the work.
|
||||
Var *color = (Var*)LangElement::find( "col" );
|
||||
Var *color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
|
||||
if ( color )
|
||||
output = new GenOp( " @ = hdrEncode( @ );\r\n", color, color );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ void AccuTexFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
output = meta;
|
||||
|
||||
// OUT.col
|
||||
Var *color = (Var*) LangElement::find( "col1" );
|
||||
Var *color = (Var*) LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget1));
|
||||
if (!color)
|
||||
{
|
||||
output = new GenOp(" //NULL COLOR!");
|
||||
|
|
|
|||
|
|
@ -460,7 +460,7 @@ void NormalsOutFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
}
|
||||
|
||||
LangElement *normalOut;
|
||||
Var *outColor = (Var*)LangElement::find( "col" );
|
||||
Var *outColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
|
||||
if ( outColor && !fd.features[MFT_AlphaTest] )
|
||||
normalOut = new GenOp( "float4( ( -@ + 1 ) * 0.5, @.a )", wsNormal, outColor );
|
||||
else
|
||||
|
|
|
|||
|
|
@ -68,136 +68,6 @@ void CustomFeatureHLSL::processPix(Vector<ShaderComponent*>& componentList,
|
|||
|
||||
mOutputState = PixelOutput;
|
||||
|
||||
/*MultiLine *meta = new MultiLine;
|
||||
|
||||
output = meta;
|
||||
|
||||
// OUT.col
|
||||
Var *color = (Var*) LangElement::find( "col1" );
|
||||
if (!color)
|
||||
{
|
||||
output = new GenOp(" //NULL COLOR!");
|
||||
return;
|
||||
}
|
||||
|
||||
// accu map
|
||||
Var *accuMap = new Var;
|
||||
accuMap->setType("SamplerState");
|
||||
|
||||
accuMap->setName( "accuMap" );
|
||||
accuMap->uniform = true;
|
||||
accuMap->sampler = true;
|
||||
accuMap->constNum = Var::getTexUnitNum(); // used as texture unit num here
|
||||
|
||||
// accuColor var
|
||||
Var *accuColor = new Var;
|
||||
accuColor->setType( "float4" );
|
||||
accuColor->setName( "accuColor" );
|
||||
LangElement *colorAccuDecl = new DecOp( accuColor );
|
||||
|
||||
// plc (placement)
|
||||
Var *accuPlc = new Var;
|
||||
accuPlc->setType( "float4" );
|
||||
accuPlc->setName( "plc" );
|
||||
LangElement *plcAccu = new DecOp( accuPlc );
|
||||
|
||||
// accu constants
|
||||
Var *accuScale = (Var*)LangElement::find( "accuScale" );
|
||||
if ( !accuScale )
|
||||
{
|
||||
accuScale = new Var;
|
||||
accuScale->setType( "float" );
|
||||
accuScale->setName( "accuScale" );
|
||||
accuScale->uniform = true;
|
||||
accuScale->sampler = false;
|
||||
accuScale->constSortPos = cspPotentialPrimitive;
|
||||
}
|
||||
Var *accuDirection = (Var*)LangElement::find( "accuDirection" );
|
||||
if ( !accuDirection )
|
||||
{
|
||||
accuDirection = new Var;
|
||||
accuDirection->setType( "float" );
|
||||
accuDirection->setName( "accuDirection" );
|
||||
accuDirection->uniform = true;
|
||||
accuDirection->sampler = false;
|
||||
accuDirection->constSortPos = cspPotentialPrimitive;
|
||||
}
|
||||
Var *accuStrength = (Var*)LangElement::find( "accuStrength" );
|
||||
if ( !accuStrength )
|
||||
{
|
||||
accuStrength = new Var;
|
||||
accuStrength->setType( "float" );
|
||||
accuStrength->setName( "accuStrength" );
|
||||
accuStrength->uniform = true;
|
||||
accuStrength->sampler = false;
|
||||
accuStrength->constSortPos = cspPotentialPrimitive;
|
||||
}
|
||||
Var *accuCoverage = (Var*)LangElement::find( "accuCoverage" );
|
||||
if ( !accuCoverage )
|
||||
{
|
||||
accuCoverage = new Var;
|
||||
accuCoverage->setType( "float" );
|
||||
accuCoverage->setName( "accuCoverage" );
|
||||
accuCoverage->uniform = true;
|
||||
accuCoverage->sampler = false;
|
||||
accuCoverage->constSortPos = cspPotentialPrimitive;
|
||||
}
|
||||
Var *accuSpecular = (Var*)LangElement::find( "accuSpecular" );
|
||||
if ( !accuSpecular )
|
||||
{
|
||||
accuSpecular = new Var;
|
||||
accuSpecular->setType( "float" );
|
||||
accuSpecular->setName( "accuSpecular" );
|
||||
accuSpecular->uniform = true;
|
||||
accuSpecular->sampler = false;
|
||||
accuSpecular->constSortPos = cspPotentialPrimitive;
|
||||
}
|
||||
|
||||
Var *inTex = getInTexCoord( "texCoord", "float2", componentList );
|
||||
Var *accuVec = getInTexCoord( "accuVec", "float3", componentList );
|
||||
Var *bumpNorm = (Var *)LangElement::find( "bumpSample" );
|
||||
if( bumpNorm == NULL )
|
||||
{
|
||||
bumpNorm = (Var *)LangElement::find( "bumpNormal" );
|
||||
if (!bumpNorm)
|
||||
return;
|
||||
}
|
||||
|
||||
// get the accu pixel color
|
||||
|
||||
Var *accuMapTex = new Var;
|
||||
accuMapTex->setType("Texture2D");
|
||||
accuMapTex->setName("accuMapTex");
|
||||
accuMapTex->uniform = true;
|
||||
accuMapTex->texture = true;
|
||||
accuMapTex->constNum = accuMap->constNum;
|
||||
meta->addStatement(new GenOp(" @ = @.Sample(@, @ * @);\r\n", colorAccuDecl, accuMapTex, accuMap, inTex, accuScale));
|
||||
|
||||
// scale up normals
|
||||
meta->addStatement( new GenOp( " @.xyz = @.xyz * 2.0 - 0.5;\r\n", bumpNorm, bumpNorm ) );
|
||||
|
||||
// assign direction
|
||||
meta->addStatement( new GenOp( " @.z *= @*2.0;\r\n", accuVec, accuDirection ) );
|
||||
|
||||
// saturate based on strength
|
||||
meta->addStatement( new GenOp( " @ = saturate( dot( @.xyz, @.xyz * pow(@, 5) ) );\r\n", plcAccu, bumpNorm, accuVec, accuStrength ) );
|
||||
|
||||
// add coverage
|
||||
meta->addStatement( new GenOp( " @.a += (2 * pow(@/2, 5)) - 0.5;\r\n", accuPlc, accuCoverage ) );
|
||||
|
||||
// clamp to a sensible value
|
||||
meta->addStatement( new GenOp( " @.a = clamp(@.a, 0, 1);\r\n", accuPlc, accuPlc ) );
|
||||
|
||||
// light
|
||||
Var *lightColor = (Var*) LangElement::find( "d_lightcolor" );
|
||||
if(lightColor != NULL)
|
||||
meta->addStatement( new GenOp( " @ *= float4(@, 1.0);\r\n\r\n", accuColor, lightColor ) );
|
||||
|
||||
// lerp with current pixel - use the accu alpha as well
|
||||
meta->addStatement( new GenOp( " @ = lerp( @, @, @.a * @.a);\r\n", color, color, accuColor, accuPlc, accuColor ) );
|
||||
|
||||
// the result should always be opaque
|
||||
meta->addStatement( new GenOp( " @.a = 1.0;\r\n", color ) );*/
|
||||
if (mOwner->isMethod("processPixelHLSL"))
|
||||
Con::executef(mOwner, "processPixelHLSL");
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ void DebugVizHLSL::processPix(Vector<ShaderComponent*>& componentList,
|
|||
{
|
||||
MultiLine* meta = new MultiLine;
|
||||
Var* surface = (Var*)LangElement::find("surface");
|
||||
Var* color = (Var*)LangElement::find("col");
|
||||
Var* color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
|
||||
|
||||
if (!surface)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -1192,13 +1192,13 @@ void DiffuseFeatureHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
diffuseMaterialColor->constSortPos = cspPotentialPrimitive;
|
||||
|
||||
MultiLine* meta = new MultiLine;
|
||||
Var *col = (Var*)LangElement::find("col");
|
||||
Var *col = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
|
||||
ShaderFeature::OutputTarget targ = ShaderFeature::DefaultTarget;
|
||||
if (fd.features[MFT_isDeferred])
|
||||
{
|
||||
targ = ShaderFeature::RenderTarget1;
|
||||
|
||||
col = (Var*)LangElement::find("col1");
|
||||
col = (Var*)LangElement::find(getOutputTargetVarName(targ));
|
||||
if (!col)
|
||||
{
|
||||
// create color var
|
||||
|
|
@ -2403,7 +2403,7 @@ void FogFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
fogColor->constSortPos = cspPass;
|
||||
|
||||
// Get the out color.
|
||||
Var *color = (Var*) LangElement::find( "col" );
|
||||
Var *color = (Var*) LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
|
||||
if ( !color )
|
||||
{
|
||||
color = new Var;
|
||||
|
|
@ -2535,7 +2535,7 @@ void VisibilityFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
// Translucent objects do a simple alpha fade.
|
||||
if ( fd.features[ MFT_IsTranslucent ] )
|
||||
{
|
||||
Var *color = (Var*)LangElement::find( "col" );
|
||||
Var *color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
|
||||
meta->addStatement( new GenOp( " @.a *= @;\r\n", color, visibility ) );
|
||||
return;
|
||||
}
|
||||
|
|
@ -2577,9 +2577,9 @@ void AlphaTestHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
}
|
||||
|
||||
// If we don't have a color var then we cannot do an alpha test.
|
||||
Var *color = (Var*)LangElement::find( "col1" );
|
||||
Var *color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget1));
|
||||
if (!color)
|
||||
color = (Var*)LangElement::find("col");
|
||||
color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
|
||||
if ( !color )
|
||||
{
|
||||
output = NULL;
|
||||
|
|
@ -2612,7 +2612,7 @@ void GlowMaskHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
//
|
||||
// The shader compiler will optimize out all the other
|
||||
// code above that doesn't contribute to the alpha mask.
|
||||
Var *color = (Var*)LangElement::find( "col" );
|
||||
Var *color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
|
||||
if ( color )
|
||||
output = new GenOp( " @.rgb = 0;\r\n", color );
|
||||
}
|
||||
|
|
@ -2644,7 +2644,7 @@ void HDROutHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
const MaterialFeatureData &fd )
|
||||
{
|
||||
// Let the helper function do the work.
|
||||
Var *color = (Var*)LangElement::find( "col" );
|
||||
Var *color = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
|
||||
if ( color )
|
||||
output = new GenOp( " @ = hdrEncode( @ );\r\n", color, color );
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue