mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
cleans up a few more spots of various variables that ammount to the "PBRConfig" in the end, as well as a MFT_isDeferred test for determining if that's stored off as a temp-val or in the gbuffer. though seem to have forgotten a catch, as it's not finding the MFT_PBRConfigMap feature and falling back to recreation come time to process MFT_ReflectionProbes
This commit is contained in:
parent
bfccfca0ce
commit
ad216abc02
|
|
@ -35,22 +35,38 @@
|
|||
//****************************************************************************
|
||||
// Deferred Shading Features
|
||||
//****************************************************************************
|
||||
U32 PBRConfigMapHLSL::getOutputTargets(const MaterialFeatureData& fd) const
|
||||
{
|
||||
return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
void PBRConfigMapHLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
|
||||
{
|
||||
// Get the texture coord.
|
||||
Var *texCoord = getInTexCoord( "texCoord", "float2", componentList );
|
||||
|
||||
// search for color var
|
||||
Var *material = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
|
||||
MultiLine * meta = new MultiLine;
|
||||
if ( !material )
|
||||
MultiLine* meta = new MultiLine;
|
||||
Var* pbrConfig;
|
||||
if (fd.features[MFT_isDeferred])
|
||||
{
|
||||
// create color var
|
||||
material = new Var;
|
||||
material->setType( "fragout" );
|
||||
material->setName( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
|
||||
material->setStructName( "OUT" );
|
||||
pbrConfig = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget2));
|
||||
if (!pbrConfig)
|
||||
{
|
||||
// create material var
|
||||
pbrConfig = new Var;
|
||||
pbrConfig->setType("fragout");
|
||||
pbrConfig->setName(getOutputTargetVarName(ShaderFeature::RenderTarget2));
|
||||
pbrConfig->setStructName("OUT");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pbrConfig = (Var*)LangElement::find("PBRConfig");
|
||||
if (!pbrConfig)
|
||||
{
|
||||
pbrConfig = new Var("PBRConfig", "float4");
|
||||
meta->addStatement(new GenOp(" @;\r\n", new DecOp(pbrConfig)));
|
||||
}
|
||||
}
|
||||
|
||||
// create texture var
|
||||
|
|
@ -69,8 +85,6 @@ void PBRConfigMapHLSL::processPix( Vector<ShaderComponent*> &componentList, cons
|
|||
pbrConfigMapTex->constNum = pbrConfigMap->constNum;
|
||||
LangElement *texOp = new GenOp(" @.Sample(@, @)", pbrConfigMapTex, pbrConfigMap, texCoord);
|
||||
|
||||
Var * pbrConfig = (Var*)LangElement::find("PBRConfig");
|
||||
if (!pbrConfig) pbrConfig = new Var("PBRConfig", "float4");
|
||||
Var *metalness = (Var*)LangElement::find("metalness");
|
||||
if (!metalness) metalness = new Var("metalness", "float");
|
||||
Var *smoothness = (Var*)LangElement::find("smoothness");
|
||||
|
|
@ -82,8 +96,9 @@ void PBRConfigMapHLSL::processPix( Vector<ShaderComponent*> &componentList, cons
|
|||
if (fd.features[MFT_InvertSmoothness])
|
||||
meta->addStatement(new GenOp(" @ = 1.0-@;\r\n", smoothness, smoothness));
|
||||
|
||||
meta->addStatement(new GenOp(" @ = @.ggga;\r\n", new DecOp(pbrConfig), texOp));
|
||||
meta->addStatement(new GenOp(" @.bga = float3(@,@.g,@);\r\n", material, smoothness, pbrConfig, metalness));
|
||||
if (!fd.features[MFT_isDeferred])
|
||||
meta->addStatement(new GenOp(" @ = @.ggga;\r\n", pbrConfig, texOp));
|
||||
meta->addStatement(new GenOp(" @.bga = float3(@,@.g,@);\r\n", pbrConfig, smoothness, pbrConfig, metalness));
|
||||
output = meta;
|
||||
}
|
||||
|
||||
|
|
@ -126,14 +141,23 @@ void PBRConfigMapHLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|||
void DeferredMatInfoFlagsHLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
|
||||
{
|
||||
// search for material var
|
||||
Var *material = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
|
||||
if ( !material )
|
||||
Var* pbrConfig;
|
||||
if (fd.features[MFT_isDeferred])
|
||||
{
|
||||
// create material var
|
||||
material = new Var;
|
||||
material->setType( "fragout" );
|
||||
material->setName( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
|
||||
material->setStructName( "OUT" );
|
||||
pbrConfig = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget2));
|
||||
if (!pbrConfig)
|
||||
{
|
||||
// create material var
|
||||
pbrConfig = new Var;
|
||||
pbrConfig->setType("fragout");
|
||||
pbrConfig->setName(getOutputTargetVarName(ShaderFeature::RenderTarget2));
|
||||
pbrConfig->setStructName("OUT");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pbrConfig = (Var*)LangElement::find("PBRConfig");
|
||||
if (!pbrConfig) pbrConfig = new Var("PBRConfig", "float4");
|
||||
}
|
||||
|
||||
Var *matInfoFlags = new Var;
|
||||
|
|
@ -142,24 +166,36 @@ void DeferredMatInfoFlagsHLSL::processPix( Vector<ShaderComponent*> &componentLi
|
|||
matInfoFlags->uniform = true;
|
||||
matInfoFlags->constSortPos = cspPotentialPrimitive;
|
||||
|
||||
output = new GenOp( " @.r = @;\r\n", material, matInfoFlags );
|
||||
output = new GenOp( " @.r = @;\r\n", pbrConfig, matInfoFlags );
|
||||
}
|
||||
|
||||
U32 PBRConfigVarsHLSL::getOutputTargets(const MaterialFeatureData& fd) const
|
||||
{
|
||||
return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
// Spec Strength -> Blue Channel of Material Info Buffer.
|
||||
// Spec Power -> Alpha Channel ( of Material Info Buffer.
|
||||
void PBRConfigVarsHLSL::processPix( Vector<ShaderComponent*> &componentList, const MaterialFeatureData &fd )
|
||||
{
|
||||
// search for material var
|
||||
Var *material = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
|
||||
if ( !material )
|
||||
MultiLine* meta = new MultiLine;
|
||||
Var* pbrConfig;
|
||||
if (fd.features[MFT_isDeferred])
|
||||
{
|
||||
// create material var
|
||||
material = new Var;
|
||||
material->setType( "fragout" );
|
||||
material->setName( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
|
||||
material->setStructName( "OUT" );
|
||||
pbrConfig = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget2));
|
||||
if (!pbrConfig)
|
||||
{
|
||||
// create material var
|
||||
pbrConfig = new Var;
|
||||
pbrConfig->setType("fragout");
|
||||
pbrConfig->setName(getOutputTargetVarName(ShaderFeature::RenderTarget2));
|
||||
pbrConfig->setStructName("OUT");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pbrConfig = (Var*)LangElement::find("PBRConfig");
|
||||
if (!pbrConfig) pbrConfig = new Var("PBRConfig", "float4");
|
||||
meta->addStatement(new GenOp(" @;\r\n", new DecOp(pbrConfig)));
|
||||
}
|
||||
|
||||
Var *metalness = new Var("metalness", "float");
|
||||
metalness->uniform = true;
|
||||
metalness->constSortPos = cspPotentialPrimitive;
|
||||
|
|
@ -168,13 +204,12 @@ void PBRConfigVarsHLSL::processPix( Vector<ShaderComponent*> &componentList, con
|
|||
smoothness->uniform = true;
|
||||
smoothness->constSortPos = cspPotentialPrimitive;
|
||||
|
||||
MultiLine * meta = new MultiLine;
|
||||
//matinfo.g slot reserved for AO later
|
||||
meta->addStatement(new GenOp(" @.g = 1.0;\r\n", material));
|
||||
meta->addStatement(new GenOp(" @.b = @;\r\n", material, smoothness));
|
||||
meta->addStatement(new GenOp(" @.g = 1.0;\r\n", pbrConfig));
|
||||
meta->addStatement(new GenOp(" @.b = @;\r\n", pbrConfig, smoothness));
|
||||
if (fd.features[MFT_InvertSmoothness])
|
||||
meta->addStatement(new GenOp(" @ = 1.0-@;\r\n", smoothness, smoothness));
|
||||
meta->addStatement(new GenOp(" @.a = @;\r\n", material, metalness));
|
||||
meta->addStatement(new GenOp(" @.a = @;\r\n", pbrConfig, metalness));
|
||||
output = meta;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ class PBRConfigMapHLSL : public ShaderFeatureHLSL
|
|||
public:
|
||||
virtual String getName() { return "Deferred Shading: PBR Config Map"; }
|
||||
|
||||
virtual U32 getOutputTargets(const MaterialFeatureData& fd) const;
|
||||
|
||||
virtual void processPix( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd );
|
||||
|
||||
|
|
@ -62,10 +64,10 @@ class PBRConfigVarsHLSL : public ShaderFeatureHLSL
|
|||
public:
|
||||
virtual String getName() { return "Deferred Shading: PBR Config Explicit Numbers"; }
|
||||
|
||||
virtual U32 getOutputTargets(const MaterialFeatureData& fd) const;
|
||||
|
||||
virtual void processPix( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd );
|
||||
|
||||
virtual U32 getOutputTargets( const MaterialFeatureData &fd ) const { return ShaderFeature::RenderTarget2; }
|
||||
};
|
||||
|
||||
class DeferredEmissiveHLSL : public ShaderFeatureHLSL
|
||||
|
|
|
|||
|
|
@ -439,7 +439,15 @@ void ProcessedShaderMaterial::_determineFeatures( U32 stageNum,
|
|||
fd.features[ MFT_NormalMap ] )
|
||||
fd.features.addFeature( MFT_Parallax );
|
||||
}
|
||||
|
||||
|
||||
// Deferred Shading : PBR Config
|
||||
if (mStages[stageNum].getTex(MFT_PBRConfigMap))
|
||||
{
|
||||
fd.features.addFeature(MFT_PBRConfigMap);
|
||||
}
|
||||
else
|
||||
fd.features.addFeature(MFT_PBRConfigVars);
|
||||
|
||||
if( fd.features[ MFT_PBRConfigMap ] )
|
||||
{
|
||||
// Check for an alpha channel on the PBR Config map. If it has one (and it
|
||||
|
|
|
|||
|
|
@ -837,8 +837,8 @@ Var* ShaderFeatureGLSL::getSurface(Vector<ShaderComponent*>& componentList, Mult
|
|||
|
||||
Var* diffuseColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
|
||||
|
||||
Var* matinfo = (Var*)LangElement::find("PBRConfig");
|
||||
if (!matinfo)
|
||||
Var* pbrConfig = (Var*)LangElement::find("PBRConfig");
|
||||
if (!pbrConfig)
|
||||
{
|
||||
Var* metalness = (Var*)LangElement::find("metalness");
|
||||
if (!metalness)
|
||||
|
|
@ -856,9 +856,9 @@ Var* ShaderFeatureGLSL::getSurface(Vector<ShaderComponent*>& componentList, Mult
|
|||
smoothness->constSortPos = cspPotentialPrimitive;
|
||||
}
|
||||
|
||||
matinfo = new Var("PBRConfig", "vec4");
|
||||
LangElement* colorDecl = new DecOp(matinfo);
|
||||
meta->addStatement(new GenOp(" @ = vec4(0.0,1.0,@,@);\r\n", colorDecl, smoothness, metalness)); //reconstruct matinfo, no ao darkening
|
||||
pbrConfig = new Var("PBRConfig", "vec4");
|
||||
LangElement* colorDecl = new DecOp(pbrConfig);
|
||||
meta->addStatement(new GenOp(" @ = vec4(0.0,1.0,@,@);\r\n", colorDecl, smoothness, metalness)); //reconstruct pbrConfig, no ao darkening
|
||||
}
|
||||
|
||||
Var* wsNormal = (Var*)LangElement::find("wsNormal");
|
||||
|
|
@ -895,7 +895,7 @@ Var* ShaderFeatureGLSL::getSurface(Vector<ShaderComponent*>& componentList, Mult
|
|||
if (!surface)
|
||||
{
|
||||
surface = new Var("surface", "Surface");
|
||||
meta->addStatement(new GenOp(" @ = createForwardSurface(@,@,@,@,@,@);\r\n\n", new DecOp(surface), diffuseColor, normal, matinfo,
|
||||
meta->addStatement(new GenOp(" @ = createForwardSurface(@,@,@,@,@,@);\r\n\n", new DecOp(surface), diffuseColor, normal, pbrConfig,
|
||||
wsPosition, wsEyePos, wsView));
|
||||
}
|
||||
|
||||
|
|
@ -3046,13 +3046,7 @@ void ReflectionProbeFeatGLSL::processPix(Vector<ShaderComponent*>& componentList
|
|||
}
|
||||
|
||||
Var *curColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
|
||||
|
||||
Var *matinfo = (Var*)LangElement::find("PBRConfig");
|
||||
Var* metalness = (Var*)LangElement::find("metalness");
|
||||
Var* smoothness = (Var*)LangElement::find("smoothness");
|
||||
|
||||
Var* wsEyePos = (Var*)LangElement::find("eyePosWorld");
|
||||
|
||||
|
||||
//Reflection vec
|
||||
String computeForwardProbes = String(" @.rgb = computeForwardProbes(@,@,@,@,@,@,@,@,@,\r\n\t\t");
|
||||
computeForwardProbes += String("@,@,\r\n\t\t");
|
||||
|
|
|
|||
|
|
@ -829,8 +829,8 @@ Var* ShaderFeatureHLSL::getSurface(Vector<ShaderComponent*>& componentList, Mult
|
|||
|
||||
Var* diffuseColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
|
||||
|
||||
Var* matinfo = (Var*)LangElement::find("PBRConfig");
|
||||
if (!matinfo)
|
||||
Var* pbrConfig = (Var*)LangElement::find("PBRConfig");
|
||||
if (!pbrConfig)
|
||||
{
|
||||
Var* metalness = (Var*)LangElement::find("metalness");
|
||||
if (!metalness)
|
||||
|
|
@ -848,8 +848,8 @@ Var* ShaderFeatureHLSL::getSurface(Vector<ShaderComponent*>& componentList, Mult
|
|||
smoothness->constSortPos = cspPotentialPrimitive;
|
||||
}
|
||||
|
||||
matinfo = new Var("PBRConfig", "float4");
|
||||
LangElement* colorDecl = new DecOp(matinfo);
|
||||
pbrConfig = new Var("PBRConfig", "float4");
|
||||
LangElement* colorDecl = new DecOp(pbrConfig);
|
||||
meta->addStatement(new GenOp(" @ = float4(0.0,1.0,@,@);\r\n", colorDecl, smoothness, metalness)); //reconstruct matinfo, no ao darkening
|
||||
}
|
||||
|
||||
|
|
@ -879,7 +879,7 @@ Var* ShaderFeatureHLSL::getSurface(Vector<ShaderComponent*>& componentList, Mult
|
|||
if (!surface)
|
||||
{
|
||||
surface = new Var("surface", "Surface");
|
||||
meta->addStatement(new GenOp(" @ = createForwardSurface(@,@,@,@,@,@);\r\n\n", new DecOp(surface), diffuseColor, normal, matinfo,
|
||||
meta->addStatement(new GenOp(" @ = createForwardSurface(@,@,@,@,@,@);\r\n\n", new DecOp(surface), diffuseColor, normal, pbrConfig,
|
||||
wsPosition, wsEyePos, wsView));
|
||||
}
|
||||
|
||||
|
|
@ -3106,12 +3106,6 @@ void ReflectionProbeFeatHLSL::processPix(Vector<ShaderComponent*> &componentList
|
|||
|
||||
Var *curColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::DefaultTarget));
|
||||
|
||||
Var *matinfo = (Var*)LangElement::find("PBRConfig");
|
||||
Var* metalness = (Var*)LangElement::find("metalness");
|
||||
Var* smoothness = (Var*)LangElement::find("smoothness");
|
||||
|
||||
Var* wsEyePos = (Var*)LangElement::find("eyePosWorld");
|
||||
|
||||
//Reflection vec
|
||||
String computeForwardProbes = String::String(" @.rgb = computeForwardProbes(@,@,@,@,@,@,@,@,@,\r\n\t\t");
|
||||
computeForwardProbes += String::String("@,TORQUE_SAMPLER2D_MAKEARG(@),\r\n\t\t");
|
||||
|
|
|
|||
Loading…
Reference in a new issue