mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-04-27 23:35:45 +00:00
shift pbrconfig to ORM
This commit is contained in:
parent
22b0785c73
commit
0c7811bd1a
54 changed files with 879 additions and 680 deletions
|
|
@ -49,7 +49,7 @@ namespace
|
|||
FEATUREMGR->registerFeature( MFT_TerrainLightMap, new TerrainLightMapFeatGLSL );
|
||||
FEATUREMGR->registerFeature( MFT_TerrainSideProject, new NamedFeatureGLSL( "Terrain Side Projection" ) );
|
||||
FEATUREMGR->registerFeature( MFT_TerrainAdditive, new TerrainAdditiveFeatGLSL );
|
||||
FEATUREMGR->registerFeature( MFT_TerrainCompositeMap, new TerrainCompositeMapFeatGLSL );
|
||||
FEATUREMGR->registerFeature( MFT_TerrainORMMap, new TerrainORMMapFeatGLSL );
|
||||
FEATUREMGR->registerFeature( MFT_DeferredTerrainBlankInfoMap, new TerrainBlankInfoMapFeatGLSL );
|
||||
}
|
||||
|
||||
|
|
@ -142,22 +142,22 @@ Var* TerrainFeatGLSL::_getNormalMapTex()
|
|||
return normalMap;
|
||||
}
|
||||
|
||||
Var* TerrainFeatGLSL::_getCompositeMapTex()
|
||||
Var* TerrainFeatGLSL::_getORMConfigMapTex()
|
||||
{
|
||||
String name(String::ToString("compositeMap%d", getProcessIndex()));
|
||||
Var *compositeMap = (Var*)LangElement::find(name);
|
||||
String name(String::ToString("ormConfigMap%d", getProcessIndex()));
|
||||
Var *ormConfigMap = (Var*)LangElement::find(name);
|
||||
|
||||
if (!compositeMap)
|
||||
if (!ormConfigMap)
|
||||
{
|
||||
compositeMap = new Var;
|
||||
compositeMap->setType("sampler2D");
|
||||
compositeMap->setName(name);
|
||||
compositeMap->uniform = true;
|
||||
compositeMap->sampler = true;
|
||||
compositeMap->constNum = Var::getTexUnitNum();
|
||||
ormConfigMap = new Var;
|
||||
ormConfigMap->setType("sampler2D");
|
||||
ormConfigMap->setName(name);
|
||||
ormConfigMap->uniform = true;
|
||||
ormConfigMap->sampler = true;
|
||||
ormConfigMap->constNum = Var::getTexUnitNum();
|
||||
}
|
||||
|
||||
return compositeMap;
|
||||
return ormConfigMap;
|
||||
}
|
||||
|
||||
Var* TerrainFeatGLSL::_getDetailIdStrengthParallax()
|
||||
|
|
@ -1140,7 +1140,7 @@ void TerrainAdditiveFeatGLSL::processPix( Vector<ShaderComponent*> &componentLis
|
|||
//.b = specular strength, a= spec power.
|
||||
|
||||
|
||||
void TerrainCompositeMapFeatGLSL::processVert(Vector<ShaderComponent*> &componentList,
|
||||
void TerrainORMMapFeatGLSL::processVert(Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd)
|
||||
{
|
||||
const S32 detailIndex = getProcessIndex();
|
||||
|
|
@ -1230,12 +1230,12 @@ void TerrainCompositeMapFeatGLSL::processVert(Vector<ShaderComponent*> &componen
|
|||
output = meta;
|
||||
}
|
||||
|
||||
U32 TerrainCompositeMapFeatGLSL::getOutputTargets(const MaterialFeatureData &fd) const
|
||||
U32 TerrainORMMapFeatGLSL::getOutputTargets(const MaterialFeatureData &fd) const
|
||||
{
|
||||
return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::RenderTarget1;
|
||||
}
|
||||
|
||||
void TerrainCompositeMapFeatGLSL::processPix(Vector<ShaderComponent*> &componentList,
|
||||
void TerrainORMMapFeatGLSL::processPix(Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd)
|
||||
{
|
||||
/// Get the texture coord.
|
||||
|
|
@ -1243,7 +1243,7 @@ void TerrainCompositeMapFeatGLSL::processPix(Vector<ShaderComponent*> &component
|
|||
Var *inTex = getVertTexCoord("texCoord");
|
||||
|
||||
const S32 compositeIndex = getProcessIndex();
|
||||
Var *compositeMap = _getCompositeMapTex();
|
||||
Var *ormConfigMap = _getORMConfigMapTex();
|
||||
// Sample the normal map.
|
||||
//
|
||||
// We take two normal samples and lerp between them for
|
||||
|
|
@ -1253,28 +1253,28 @@ void TerrainCompositeMapFeatGLSL::processPix(Vector<ShaderComponent*> &component
|
|||
if (fd.features.hasFeature(MFT_TerrainSideProject, compositeIndex))
|
||||
{
|
||||
texOp = new GenOp("lerp( tex2D( @, @.yz ), tex2D( @, @.xz ), @.z )",
|
||||
compositeMap, inDet, compositeMap, inDet, inTex);
|
||||
ormConfigMap, inDet, ormConfigMap, inDet, inTex);
|
||||
}
|
||||
else
|
||||
texOp = new GenOp("tex2D(@, @.xy)", compositeMap, inDet);
|
||||
texOp = new GenOp("tex2D(@, @.xy)", ormConfigMap, inDet);
|
||||
|
||||
// search for material var
|
||||
Var * pbrConfig;
|
||||
Var * ormConfig;
|
||||
OutputTarget targ = RenderTarget1;
|
||||
if (fd.features[MFT_isDeferred])
|
||||
{
|
||||
targ = RenderTarget2;
|
||||
}
|
||||
pbrConfig = (Var*)LangElement::find(getOutputTargetVarName(targ));
|
||||
ormConfig = (Var*)LangElement::find(getOutputTargetVarName(targ));
|
||||
|
||||
MultiLine * meta = new MultiLine;
|
||||
if (!pbrConfig)
|
||||
if (!ormConfig)
|
||||
{
|
||||
// create color var
|
||||
pbrConfig = new Var;
|
||||
pbrConfig->setType("fragout");
|
||||
pbrConfig->setName(getOutputTargetVarName(targ));
|
||||
pbrConfig->setStructName("OUT");
|
||||
ormConfig = new Var;
|
||||
ormConfig->setType("fragout");
|
||||
ormConfig->setName(getOutputTargetVarName(targ));
|
||||
ormConfig->setStructName("OUT");
|
||||
}
|
||||
|
||||
Var *detailBlend = (Var*)LangElement::find(String::ToString("detailBlend%d", compositeIndex));
|
||||
|
|
@ -1287,23 +1287,23 @@ void TerrainCompositeMapFeatGLSL::processPix(Vector<ShaderComponent*> &component
|
|||
if (priorComp)
|
||||
{
|
||||
meta->addStatement(new GenOp(" @ = @.rgb*@;\r\n", new DecOp(matinfoCol), texOp, detailBlend));
|
||||
meta->addStatement(new GenOp(" @.bga += @;\r\n", pbrConfig, matinfoCol));
|
||||
meta->addStatement(new GenOp(" @.gba += @;\r\n", ormConfig, matinfoCol));
|
||||
}
|
||||
else
|
||||
{
|
||||
meta->addStatement(new GenOp(" @ = lerp(vec3(0,1,0),@.rgb,@);\r\n", new DecOp(matinfoCol), texOp, detailBlend));
|
||||
meta->addStatement(new GenOp(" @ = vec4(0.0,@);\r\n", pbrConfig, matinfoCol));
|
||||
meta->addStatement(new GenOp(" @ = lerp(vec3(1.0,1.0,0.0),@.rgb,@);\r\n", new DecOp(matinfoCol), texOp, detailBlend));
|
||||
meta->addStatement(new GenOp(" @ = vec4(0.0,@);\r\n", ormConfig, matinfoCol));
|
||||
}
|
||||
|
||||
if (!fd.features[MFT_InvertSmoothness])
|
||||
if (fd.features[MFT_InvertRoughness])
|
||||
{
|
||||
meta->addStatement(new GenOp(" @.b = 1.0-@.b;\r\n", pbrConfig, pbrConfig));
|
||||
meta->addStatement(new GenOp(" @.b = 1.0-@.b;\r\n", ormConfig, ormConfig));
|
||||
}
|
||||
|
||||
output = meta;
|
||||
}
|
||||
|
||||
ShaderFeature::Resources TerrainCompositeMapFeatGLSL::getResources(const MaterialFeatureData &fd)
|
||||
ShaderFeature::Resources TerrainORMMapFeatGLSL::getResources(const MaterialFeatureData &fd)
|
||||
{
|
||||
Resources res;
|
||||
res.numTex = 1;
|
||||
|
|
@ -1340,7 +1340,7 @@ void TerrainBlankInfoMapFeatGLSL::processPix(Vector<ShaderComponent*> &component
|
|||
material->setStructName("OUT");
|
||||
}
|
||||
|
||||
meta->addStatement(new GenOp(" @ = vec4(0.0,0.0,1.0,0);\r\n", material));
|
||||
meta->addStatement(new GenOp(" @ = vec4(0.0,1.0,1.0,0.0);\r\n", material));
|
||||
|
||||
output = meta;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue