mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 07:04:36 +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 TerrainLightMapFeatHLSL );
|
||||
FEATUREMGR->registerFeature( MFT_TerrainSideProject, new NamedFeatureHLSL( "Terrain Side Projection" ) );
|
||||
FEATUREMGR->registerFeature( MFT_TerrainAdditive, new TerrainAdditiveFeatHLSL );
|
||||
FEATUREMGR->registerFeature( MFT_TerrainCompositeMap, new TerrainCompositeMapFeatHLSL );
|
||||
FEATUREMGR->registerFeature( MFT_TerrainORMMap, new TerrainORMMapFeatHLSL );
|
||||
FEATUREMGR->registerFeature( MFT_DeferredTerrainBlankInfoMap, new TerrainBlankInfoMapFeatHLSL );
|
||||
}
|
||||
};
|
||||
|
|
@ -141,22 +141,22 @@ Var* TerrainFeatHLSL::_getNormalMapTex()
|
|||
return normalMap;
|
||||
}
|
||||
|
||||
Var* TerrainFeatHLSL::_getCompositeMapTex()
|
||||
Var* TerrainFeatHLSL::_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("SamplerState");
|
||||
compositeMap->setName(name);
|
||||
compositeMap->uniform = true;
|
||||
compositeMap->sampler = true;
|
||||
compositeMap->constNum = Var::getTexUnitNum();
|
||||
ormConfigMap = new Var;
|
||||
ormConfigMap->setType("SamplerState");
|
||||
ormConfigMap->setName(name);
|
||||
ormConfigMap->uniform = true;
|
||||
ormConfigMap->sampler = true;
|
||||
ormConfigMap->constNum = Var::getTexUnitNum();
|
||||
}
|
||||
|
||||
return compositeMap;
|
||||
return ormConfigMap;
|
||||
}
|
||||
|
||||
Var* TerrainFeatHLSL::_getDetailIdStrengthParallax()
|
||||
|
|
@ -1148,7 +1148,7 @@ void TerrainAdditiveFeatHLSL::processPix( Vector<ShaderComponent*> &componentLis
|
|||
//standard matInfo map contains data of the form .r = bitflags, .g = (will contain AO),
|
||||
//.b = specular strength, a= spec power.
|
||||
|
||||
void TerrainCompositeMapFeatHLSL::processVert(Vector<ShaderComponent*> &componentList,
|
||||
void TerrainORMMapFeatHLSL::processVert(Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd)
|
||||
{
|
||||
const S32 detailIndex = getProcessIndex();
|
||||
|
|
@ -1238,12 +1238,12 @@ void TerrainCompositeMapFeatHLSL::processVert(Vector<ShaderComponent*> &componen
|
|||
output = meta;
|
||||
}
|
||||
|
||||
U32 TerrainCompositeMapFeatHLSL::getOutputTargets(const MaterialFeatureData &fd) const
|
||||
U32 TerrainORMMapFeatHLSL::getOutputTargets(const MaterialFeatureData &fd) const
|
||||
{
|
||||
return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
void TerrainCompositeMapFeatHLSL::processPix(Vector<ShaderComponent*> &componentList,
|
||||
void TerrainORMMapFeatHLSL::processPix(Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd)
|
||||
{
|
||||
/// Get the texture coord.
|
||||
|
|
@ -1251,48 +1251,48 @@ void TerrainCompositeMapFeatHLSL::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
|
||||
// side projection layers... else a single sample.
|
||||
LangElement *texOp;
|
||||
String name(String::ToString("compositeMapTex%d", getProcessIndex()));
|
||||
Var *compositeMapTex = (Var*)LangElement::find(name);
|
||||
if (!compositeMapTex)
|
||||
String name(String::ToString("ormConfigMapTex%d", getProcessIndex()));
|
||||
Var *ormConfigMapTex = (Var*)LangElement::find(name);
|
||||
if (!ormConfigMapTex)
|
||||
{
|
||||
compositeMapTex = new Var;
|
||||
compositeMapTex->setName(String::ToString("compositeMapTex%d", getProcessIndex()));
|
||||
compositeMapTex->setType("Texture2D");
|
||||
compositeMapTex->uniform = true;
|
||||
compositeMapTex->texture = true;
|
||||
compositeMapTex->constNum = compositeMap->constNum;
|
||||
ormConfigMapTex = new Var;
|
||||
ormConfigMapTex->setName(String::ToString("ormConfigMapTex%d", getProcessIndex()));
|
||||
ormConfigMapTex->setType("Texture2D");
|
||||
ormConfigMapTex->uniform = true;
|
||||
ormConfigMapTex->texture = true;
|
||||
ormConfigMapTex->constNum = ormConfigMap->constNum;
|
||||
}
|
||||
if (fd.features.hasFeature(MFT_TerrainSideProject, compositeIndex))
|
||||
{
|
||||
texOp = new GenOp("lerp( @.Sample( @, @.yz ), @.Sample( @, @.xz ), @.z )",
|
||||
compositeMapTex, compositeMap, inDet, compositeMapTex, compositeMap, inDet, inTex);
|
||||
ormConfigMapTex, ormConfigMap, inDet, ormConfigMapTex, ormConfigMap, inDet, inTex);
|
||||
}
|
||||
else
|
||||
texOp = new GenOp("@.Sample(@, @.xy)", compositeMapTex, compositeMap, inDet);
|
||||
texOp = new GenOp("@.Sample(@, @.xy)", ormConfigMapTex, ormConfigMap, inDet);
|
||||
|
||||
// search for material var
|
||||
Var * pbrConfig;
|
||||
Var * ormConfig;
|
||||
OutputTarget targ = DefaultTarget;
|
||||
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));
|
||||
|
|
@ -1305,23 +1305,23 @@ void TerrainCompositeMapFeatHLSL::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(float3(0,1,0),@.rgb,@);\r\n", new DecOp(matinfoCol), texOp, detailBlend));
|
||||
meta->addStatement(new GenOp(" @ = float4(0.0,@);\r\n", pbrConfig, matinfoCol));
|
||||
meta->addStatement(new GenOp(" @ = lerp(float3(1.0,1.0,0.0),@.rgb,@);\r\n", new DecOp(matinfoCol), texOp, detailBlend));
|
||||
meta->addStatement(new GenOp(" @ = float4(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 TerrainCompositeMapFeatHLSL::getResources(const MaterialFeatureData &fd)
|
||||
ShaderFeature::Resources TerrainORMMapFeatHLSL::getResources(const MaterialFeatureData &fd)
|
||||
{
|
||||
Resources res;
|
||||
res.numTex = 1;
|
||||
|
|
@ -1356,7 +1356,7 @@ void TerrainBlankInfoMapFeatHLSL::processPix(Vector<ShaderComponent*> &component
|
|||
material->setStructName("OUT");
|
||||
}
|
||||
|
||||
meta->addStatement(new GenOp(" @ = float4(0.0,0.0,1.0,0);\r\n", material));
|
||||
meta->addStatement(new GenOp(" @ = float4(0.0,1.0,1.0,0.0);\r\n", material));
|
||||
|
||||
output = meta;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue