|
@@ -281,6 +281,8 @@ void TerrainBaseMapFeatGLSL::processVert( Vector<ShaderComponent*> &componentLis
|
|
|
Var *squareSize = _getUniformVar( "squareSize", "float", cspPass );
|
|
|
meta->addStatement( new GenOp( " @ = normalize( vec3( @, 0, @ ) );\r\n",
|
|
|
new DecOp( inTanget ), squareSize, inTangentZ ) );
|
|
|
+
|
|
|
+ getOutViewToTangent(componentList, meta, fd);
|
|
|
}
|
|
|
|
|
|
void TerrainBaseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|
@@ -304,34 +306,35 @@ void TerrainBaseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentLis
|
|
|
baseColor->setName( "baseColor" );
|
|
|
meta->addStatement( new GenOp( " @ = tex2D( @, @.xy );\r\n", new DecOp( baseColor ), diffuseMap, texCoord ) );
|
|
|
|
|
|
- ShaderFeature::OutputTarget target = ShaderFeature::DefaultTarget;
|
|
|
-
|
|
|
- if(fd.features.hasFeature(MFT_isDeferred))
|
|
|
- {
|
|
|
- target= ShaderFeature::RenderTarget1;
|
|
|
- }
|
|
|
- meta->addStatement( new GenOp( " @;\r\n", assignColor( baseColor, Material::Mul,NULL,target ) ) );
|
|
|
+ ShaderFeature::OutputTarget target = (fd.features[MFT_isDeferred]) ? RenderTarget1 : DefaultTarget;
|
|
|
+ meta->addStatement(new GenOp(" @;\r\n", assignColor(baseColor, Material::Mul, NULL, target)));
|
|
|
|
|
|
- // Set base ORM info
|
|
|
Var* ormConfig;
|
|
|
- OutputTarget targ = RenderTarget1;
|
|
|
- if (fd.features[MFT_isDeferred])
|
|
|
+ if ((fd.features[MFT_isDeferred]))
|
|
|
{
|
|
|
- targ = RenderTarget2;
|
|
|
+ // Set base ORM info
|
|
|
+ ormConfig = (Var*)LangElement::find(getOutputTargetVarName(RenderTarget2));
|
|
|
+
|
|
|
+ if (!ormConfig)
|
|
|
+ {
|
|
|
+ // create color var
|
|
|
+ ormConfig = new Var;
|
|
|
+ ormConfig->setType("fragout");
|
|
|
+ ormConfig->setName(getOutputTargetVarName(RenderTarget2));
|
|
|
+ ormConfig->setStructName("OUT");
|
|
|
+ }
|
|
|
}
|
|
|
- ormConfig = (Var*)LangElement::find(getOutputTargetVarName(targ));
|
|
|
- if (!ormConfig)
|
|
|
+ else
|
|
|
{
|
|
|
- // create color var
|
|
|
- ormConfig = new Var;
|
|
|
- ormConfig->setType("fragout");
|
|
|
- ormConfig->setName(getOutputTargetVarName(targ));
|
|
|
- ormConfig->setStructName("OUT");
|
|
|
+ ormConfig = new Var("ORMConfig", "float4");
|
|
|
+ meta->addStatement(new GenOp(" @;\r\n", new DecOp(ormConfig)));
|
|
|
}
|
|
|
|
|
|
meta->addStatement(new GenOp(" @ = float4(0.0, 1.0, 1.0, 0.0);\r\n", ormConfig));
|
|
|
|
|
|
output = meta;
|
|
|
+
|
|
|
+ Var* viewToTangent = getInViewToTangent(componentList);
|
|
|
}
|
|
|
|
|
|
ShaderFeature::Resources TerrainBaseMapFeatGLSL::getResources( const MaterialFeatureData &fd )
|
|
@@ -347,7 +350,7 @@ ShaderFeature::Resources TerrainBaseMapFeatGLSL::getResources( const MaterialFea
|
|
|
|
|
|
U32 TerrainBaseMapFeatGLSL::getOutputTargets( const MaterialFeatureData &fd ) const
|
|
|
{
|
|
|
- return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget1 | ShaderFeature::RenderTarget2 : ShaderFeature::DefaultTarget | ShaderFeature::RenderTarget1;
|
|
|
+ return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 | ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
|
|
}
|
|
|
|
|
|
TerrainDetailMapFeatGLSL::TerrainDetailMapFeatGLSL()
|
|
@@ -782,6 +785,22 @@ void TerrainMacroMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentL
|
|
|
meta->addStatement( new GenOp( " @ = calcBlend( @.x, @.xy, @, @ );\r\n",
|
|
|
new DecOp( detailBlend ), detailInfo, inTex, layerSize, layerSample ) );
|
|
|
|
|
|
+ // Check to see if we have a gbuffer normal.
|
|
|
+ Var* gbNormal = (Var*)LangElement::find("gbNormal");
|
|
|
+
|
|
|
+ // If we have a gbuffer normal and we don't have a
|
|
|
+ // normal map feature then we need to lerp in a
|
|
|
+ // default normal else the normals below this layer
|
|
|
+ // will show thru.
|
|
|
+ if (gbNormal &&
|
|
|
+ !fd.features.hasFeature(MFT_TerrainNormalMap, detailIndex))
|
|
|
+ {
|
|
|
+ Var* viewToTangent = getInViewToTangent(componentList);
|
|
|
+
|
|
|
+ meta->addStatement(new GenOp(" @ = lerp( @, @[2], min( @, @.w ) );\r\n",
|
|
|
+ gbNormal, gbNormal, viewToTangent, detailBlend, inDet));
|
|
|
+ }
|
|
|
+
|
|
|
Var *detailColor = (Var*)LangElement::find( "macroColor" );
|
|
|
if ( !detailColor )
|
|
|
{
|
|
@@ -1167,24 +1186,36 @@ void TerrainORMMapFeatGLSL::processPix(Vector<ShaderComponent*> &componentList,
|
|
|
else
|
|
|
texOp = new GenOp("tex2D(@, vec3(@.xy, @.x))", ormConfigMap, inDet, new IndexOp(detailInfo, compositeIndex));
|
|
|
|
|
|
- // search for material var
|
|
|
- Var * ormConfig;
|
|
|
- OutputTarget targ = RenderTarget1;
|
|
|
- if (fd.features[MFT_isDeferred])
|
|
|
- {
|
|
|
- targ = RenderTarget2;
|
|
|
- }
|
|
|
- ormConfig = (Var*)LangElement::find(getOutputTargetVarName(targ));
|
|
|
+ MultiLine* meta = new MultiLine;
|
|
|
+ // search for material var
|
|
|
+ Var* ormConfig;
|
|
|
+ if ((fd.features[MFT_isDeferred]))
|
|
|
+ {
|
|
|
+ // Set base ORM info
|
|
|
+ ormConfig = (Var*)LangElement::find(getOutputTargetVarName(RenderTarget2));
|
|
|
|
|
|
- MultiLine * meta = new MultiLine;
|
|
|
- if (!ormConfig)
|
|
|
- {
|
|
|
- // create color var
|
|
|
- ormConfig = new Var;
|
|
|
- ormConfig->setType("fragout");
|
|
|
- ormConfig->setName(getOutputTargetVarName(targ));
|
|
|
- ormConfig->setStructName("OUT");
|
|
|
- }
|
|
|
+ if (!ormConfig)
|
|
|
+ {
|
|
|
+ // create color var
|
|
|
+ ormConfig = new Var;
|
|
|
+ ormConfig->setType("fragout");
|
|
|
+ ormConfig->setName(getOutputTargetVarName(RenderTarget2));
|
|
|
+ ormConfig->setStructName("OUT");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ormConfig = (Var*)LangElement::find("ORMConfig");
|
|
|
+ if (!ormConfig)
|
|
|
+ {
|
|
|
+ ormConfig = new Var("ORMConfig", "vec4");
|
|
|
+ meta->addStatement(new GenOp(" @;\r\n", new DecOp(ormConfig)));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (compositeIndex == 0)
|
|
|
+ {
|
|
|
+ meta->addStatement(new GenOp(" @ = vec4(0.0, 0.0, 0.0, 0.0);\r\n", ormConfig));
|
|
|
+ }
|
|
|
|
|
|
Var *detailBlend = (Var*)LangElement::find(String::ToString("detailBlend%d", compositeIndex));
|
|
|
AssertFatal(detailBlend, "The detail blend is missing!");
|
|
@@ -1192,11 +1223,6 @@ void TerrainORMMapFeatGLSL::processPix(Vector<ShaderComponent*> &componentList,
|
|
|
String matinfoName(String::ToString("matinfoCol%d", compositeIndex));
|
|
|
Var *matinfoCol = new Var(matinfoName, "vec3");
|
|
|
|
|
|
- if (compositeIndex == 0)
|
|
|
- {
|
|
|
- meta->addStatement(new GenOp(" @ = vec4(0.0, 0.0, 0.0, 0.0);\r\n", ormConfig));
|
|
|
- }
|
|
|
-
|
|
|
meta->addStatement(new GenOp(" @ = @.rgb;\r\n", new DecOp(matinfoCol), texOp));
|
|
|
|
|
|
if (fd.features.hasFeature(MFT_InvertRoughness, compositeIndex))
|
|
@@ -1218,58 +1244,44 @@ void TerrainORMMapFeatGLSL::processPix(Vector<ShaderComponent*> &componentList,
|
|
|
ShaderFeature::Resources TerrainORMMapFeatGLSL::getResources(const MaterialFeatureData &fd)
|
|
|
{
|
|
|
Resources res;
|
|
|
-
|
|
|
- S32 featureIndex = 0, firstOrmMapIndex = 0;
|
|
|
- for (int idx = 0; idx < fd.features.getCount(); ++idx) {
|
|
|
- const FeatureType& type = fd.features.getAt(idx, &featureIndex);
|
|
|
- if (type == MFT_TerrainORMMap) {
|
|
|
- firstOrmMapIndex = getMin(firstOrmMapIndex, featureIndex);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // We only need to process normals during the deferred.
|
|
|
- if (getProcessIndex() == firstOrmMapIndex)
|
|
|
- {
|
|
|
- res.numTexReg = 1;
|
|
|
- res.numTex = 1;
|
|
|
- }
|
|
|
+ res.numTex = 1;
|
|
|
return res;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-U32 TerrainBlankInfoMapFeatGLSL::getOutputTargets(const MaterialFeatureData &fd) const
|
|
|
-{
|
|
|
- return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::RenderTarget1;
|
|
|
-}
|
|
|
-
|
|
|
// reminder, the matinfo buffer is flags, smooth, ao, metal
|
|
|
void TerrainBlankInfoMapFeatGLSL::processPix(Vector<ShaderComponent*> &componentList,
|
|
|
const MaterialFeatureData &fd)
|
|
|
{
|
|
|
S32 compositeIndex = getProcessIndex();
|
|
|
|
|
|
- // search for material var
|
|
|
- Var *material;
|
|
|
- OutputTarget targ = DefaultTarget;
|
|
|
- if (fd.features[MFT_isDeferred])
|
|
|
+ MultiLine* meta = new MultiLine; Var* ormConfig;
|
|
|
+ if ((fd.features[MFT_isDeferred]))
|
|
|
{
|
|
|
- targ = RenderTarget2;
|
|
|
- }
|
|
|
- material = (Var*)LangElement::find(getOutputTargetVarName(targ));
|
|
|
+ // Set base ORM info
|
|
|
+ ormConfig = (Var*)LangElement::find(getOutputTargetVarName(RenderTarget2));
|
|
|
|
|
|
- MultiLine * meta = new MultiLine;
|
|
|
- if (!material)
|
|
|
+ if (!ormConfig)
|
|
|
+ {
|
|
|
+ // create color var
|
|
|
+ ormConfig = new Var;
|
|
|
+ ormConfig->setType("fragout");
|
|
|
+ ormConfig->setName(getOutputTargetVarName(RenderTarget2));
|
|
|
+ ormConfig->setStructName("OUT");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
{
|
|
|
- // create color var
|
|
|
- material = new Var;
|
|
|
- material->setType("vec4");
|
|
|
- material->setName(getOutputTargetVarName(targ));
|
|
|
- material->setStructName("OUT");
|
|
|
+ ormConfig = (Var*)LangElement::find("ORMConfig");
|
|
|
+ if (!ormConfig)
|
|
|
+ {
|
|
|
+ ormConfig = new Var("ORMConfig", "vec4");
|
|
|
+ meta->addStatement(new GenOp(" @;\r\n", new DecOp(ormConfig)));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (compositeIndex == 0)
|
|
|
{
|
|
|
- meta->addStatement(new GenOp(" @ = vec4(0.0, 0.0, 0.0, 0.0);\r\n", material));
|
|
|
+ meta->addStatement(new GenOp(" @ = float4(0.0, 0.0, 0.0, 0.0);\r\n", ormConfig));
|
|
|
}
|
|
|
|
|
|
Var* detailBlend = (Var*)LangElement::find(String::ToString("detailBlend%d", compositeIndex));
|
|
@@ -1277,7 +1289,10 @@ void TerrainBlankInfoMapFeatGLSL::processPix(Vector<ShaderComponent*> &component
|
|
|
|
|
|
String matinfoName(String::ToString("matinfoCol%d", compositeIndex));
|
|
|
|
|
|
- meta->addStatement(new GenOp(" @.gba += vec3(@, @, 0.0);\r\n", material, detailBlend, detailBlend));
|
|
|
+ if (!fd.features.hasFeature(MFT_TerrainHeightBlend))
|
|
|
+ {
|
|
|
+ meta->addStatement(new GenOp(" @.gba += vec3(@, @, 0.0);\r\n", ormConfig, detailBlend, detailBlend));
|
|
|
+ }
|
|
|
|
|
|
output = meta;
|
|
|
}
|