mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-19 06:33:49 +00:00
backend support for isSRGB and invSmooth flags, general cleanup HLSL side. left GLSL alone for sxs comparrison while we work out the kinks
This commit is contained in:
parent
f007700646
commit
29a8d5d36c
3 changed files with 26 additions and 17 deletions
|
|
@ -1112,11 +1112,9 @@ void TerrainAdditiveFeatHLSL::processPix( Vector<ShaderComponent*> &componentLis
|
|||
const MaterialFeatureData &fd )
|
||||
{
|
||||
Var *color = NULL;
|
||||
Var *normal = NULL;
|
||||
if (fd.features[MFT_isDeferred])
|
||||
{
|
||||
color = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget1) );
|
||||
normal = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::DefaultTarget) );
|
||||
}
|
||||
else
|
||||
color = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::DefaultTarget) );
|
||||
|
|
@ -1130,9 +1128,6 @@ void TerrainAdditiveFeatHLSL::processPix( Vector<ShaderComponent*> &componentLis
|
|||
meta->addStatement( new GenOp( " clip( @ - 0.0001 );\r\n", blendTotal ) );
|
||||
meta->addStatement( new GenOp( " @.a = @;\r\n", color, blendTotal ) );
|
||||
|
||||
if (normal)
|
||||
meta->addStatement(new GenOp(" @.a = @;\r\n", normal, blendTotal));
|
||||
|
||||
output = meta;
|
||||
}
|
||||
|
||||
|
|
@ -1268,22 +1263,22 @@ void TerrainCompositeMapFeatHLSL::processPix(Vector<ShaderComponent*> &component
|
|||
texOp = new GenOp("@.Sample(@, @.xy)", compositeMapTex, compositeMap, inDet);
|
||||
|
||||
// search for material var
|
||||
Var *material;
|
||||
Var * pbrConfig;
|
||||
OutputTarget targ = RenderTarget1;
|
||||
if (fd.features[MFT_isDeferred])
|
||||
{
|
||||
targ = RenderTarget2;
|
||||
}
|
||||
material = (Var*)LangElement::find(getOutputTargetVarName(targ));
|
||||
pbrConfig = (Var*)LangElement::find(getOutputTargetVarName(targ));
|
||||
|
||||
MultiLine * meta = new MultiLine;
|
||||
if (!material)
|
||||
if (!pbrConfig)
|
||||
{
|
||||
// create color var
|
||||
material = new Var;
|
||||
material->setType("fragout");
|
||||
material->setName(getOutputTargetVarName(targ));
|
||||
material->setStructName("OUT");
|
||||
pbrConfig = new Var;
|
||||
pbrConfig->setType("fragout");
|
||||
pbrConfig->setName(getOutputTargetVarName(targ));
|
||||
pbrConfig->setStructName("OUT");
|
||||
}
|
||||
|
||||
Var *detailBlend = (Var*)LangElement::find(String::ToString("detailBlend%d", compositeIndex));
|
||||
|
|
@ -1295,15 +1290,19 @@ void TerrainCompositeMapFeatHLSL::processPix(Vector<ShaderComponent*> &component
|
|||
Var *priorComp = (Var*)LangElement::find(String::ToString("matinfoCol%d", compositeIndex - 1));
|
||||
if (priorComp)
|
||||
{
|
||||
meta->addStatement(new GenOp(" @ = @.grb*@;\r\n", new DecOp(matinfoCol), texOp, detailBlend));
|
||||
meta->addStatement(new GenOp(" @.gba += @;\r\n", material, matinfoCol));
|
||||
meta->addStatement(new GenOp(" @ = @.rgb*@;\r\n", new DecOp(matinfoCol), texOp, detailBlend));
|
||||
meta->addStatement(new GenOp(" @.bga += @;\r\n", pbrConfig, matinfoCol));
|
||||
}
|
||||
else
|
||||
{
|
||||
meta->addStatement(new GenOp(" @ = lerp(float3(1,0,0),@.grb,@);\r\n", new DecOp(matinfoCol), texOp, detailBlend));
|
||||
meta->addStatement(new GenOp(" @ = float4(0.0,@);\r\n", material, matinfoCol));
|
||||
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));
|
||||
}
|
||||
|
||||
if (!fd.features[MFT_InvertSmoothness])
|
||||
{
|
||||
meta->addStatement(new GenOp(" @.b = 1.0-@.b;\r\n", pbrConfig, pbrConfig));
|
||||
}
|
||||
|
||||
output = meta;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -445,6 +445,8 @@ bool TerrainCellMaterial::_createPass( Vector<MaterialInfo*> *materials,
|
|||
features.addFeature(MFT_TerrainCompositeMap, featureIndex);
|
||||
features.removeFeature(MFT_DeferredTerrainBlankInfoMap);
|
||||
}
|
||||
if (mat->getInvertSmoothness())
|
||||
features.addFeature(MFT_InvertSmoothness);
|
||||
|
||||
pass->materials.push_back( (*materials)[i] );
|
||||
normalMaps.increment();
|
||||
|
|
@ -640,8 +642,12 @@ bool TerrainCellMaterial::_createPass( Vector<MaterialInfo*> *materials,
|
|||
matInfo->compositeTexConst = pass->shader->getShaderConstHandle(avar("$compositeMap%d", i));
|
||||
if (matInfo->compositeTexConst->isValid())
|
||||
{
|
||||
GFXTextureProfile* profile = &GFXStaticTextureProfile;
|
||||
if (matInfo->mat->getIsSRGB())
|
||||
profile = &GFXStaticTextureSRGBProfile;
|
||||
|
||||
matInfo->compositeTex.set(matInfo->mat->getCompositeMap(),
|
||||
&GFXStaticTextureProfile, "TerrainCellMaterial::_createPass() - CompositeMap");
|
||||
profile, "TerrainCellMaterial::_createPass() - CompositeMap");
|
||||
const S32 sampler = matInfo->compositeTexConst->getSamplerRegister();
|
||||
|
||||
desc.samplers[sampler] = GFXSamplerStateDesc::getWrapLinear();
|
||||
|
|
|
|||
|
|
@ -127,6 +127,10 @@ public:
|
|||
|
||||
F32 getParallaxScale() const { return mParallaxScale; }
|
||||
|
||||
bool getIsSRGB() const { return mIsSRGB; }
|
||||
|
||||
bool getInvertSmoothness() const { return mInvertSmoothness; }
|
||||
|
||||
};
|
||||
|
||||
#endif // _TERRMATERIAL_H_
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue