mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-30 09:31:00 +00:00
commit
fe3edb8ccf
|
|
@ -562,6 +562,7 @@ void GFXGLShader::initConstantDescs()
|
|||
|
||||
if(!maxNameLength)
|
||||
return;
|
||||
maxNameLength++;
|
||||
|
||||
FrameTemp<GLchar> uniformName(maxNameLength);
|
||||
|
||||
|
|
|
|||
|
|
@ -186,10 +186,8 @@ void ShadowMaterialHook::_overrideFeatures( ProcessedMaterial *mat,
|
|||
type == MFT_TexAnim ||
|
||||
type == MFT_DiffuseMap ||
|
||||
type == MFT_IsTranslucent ||
|
||||
type == MFT_Visibility ||
|
||||
type == MFT_UseInstancing ||
|
||||
type == MFT_EyeSpaceDepthOut ||
|
||||
type == MFT_DeferredConditioner)
|
||||
type == MFT_EyeSpaceDepthOut)
|
||||
newFeatures.addFeature(type);
|
||||
else if (type.getGroup() == MFG_PreTransform ||
|
||||
type.getGroup() == MFG_Transform ||
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ GFXTextureObject* PostEffectManager::getBackBufferTex()
|
|||
|
||||
mBackBufferCopyTex.set( targetSize.x, targetSize.y,
|
||||
targetFormat,
|
||||
&PostFxTargetProfile, "mBackBufferCopyTex" );
|
||||
&PostFxTextureSRGBProfile, "mBackBufferCopyTex" );
|
||||
|
||||
target->resolveTo( mBackBufferCopyTex );
|
||||
mLastBackBufferTarget = target;
|
||||
|
|
|
|||
|
|
@ -474,25 +474,11 @@ Var* ShaderFeatureGLSL::getInVpos( MultiLine *meta,
|
|||
return inVpos;
|
||||
|
||||
ShaderConnector *connectComp = dynamic_cast<ShaderConnector*>( componentList[C_CONNECTOR] );
|
||||
/*
|
||||
if ( GFX->getPixelShaderVersion() >= 3.0f )
|
||||
{
|
||||
inVpos = connectComp->getElement( RT_VPOS );
|
||||
inVpos->setName( "vpos" );
|
||||
inVpos->setStructName( "IN" );
|
||||
inVpos->setType( "vec2" );
|
||||
return inVpos;
|
||||
}
|
||||
*/
|
||||
inVpos = connectComp->getElement( RT_TEXCOORD );
|
||||
inVpos->setName( "inVpos" );
|
||||
inVpos->setStructName( "IN" );
|
||||
inVpos->setType( "vec4" );
|
||||
|
||||
Var *vpos = new Var( "vpos", "vec2" );
|
||||
meta->addStatement( new GenOp( " @ = @.xy / @.w;\r\n", new DecOp( vpos ), inVpos, inVpos ) );
|
||||
|
||||
return vpos;
|
||||
return inVpos;
|
||||
}
|
||||
|
||||
Var* ShaderFeatureGLSL::getInWorldToTangent( Vector<ShaderComponent*> &componentList )
|
||||
|
|
@ -779,6 +765,21 @@ Var* ShaderFeatureGLSL::getWsView( Var *wsPosition, MultiLine *meta )
|
|||
return wsView;
|
||||
}
|
||||
|
||||
Var* ShaderFeatureGLSL::getInWorldNormal(Vector<ShaderComponent*>& componentList)
|
||||
{
|
||||
Var* wsNormal = (Var*)LangElement::find("wsNormal");
|
||||
if (!wsNormal)
|
||||
{
|
||||
ShaderConnector* connectComp = dynamic_cast<ShaderConnector*>(componentList[C_CONNECTOR]);
|
||||
wsNormal = connectComp->getElement(RT_TEXCOORD);
|
||||
wsNormal->setName("wsNormal");
|
||||
wsNormal->setStructName("IN");
|
||||
wsNormal->setType("float3");
|
||||
}
|
||||
|
||||
return wsNormal;
|
||||
}
|
||||
|
||||
Var* ShaderFeatureGLSL::addOutDetailTexCoord( Vector<ShaderComponent*> &componentList,
|
||||
MultiLine *meta,
|
||||
bool useTexAnim,
|
||||
|
|
@ -865,21 +866,23 @@ Var* ShaderFeatureGLSL::getSurface(Vector<ShaderComponent*>& componentList, Mult
|
|||
meta->addStatement(new GenOp(" @ = vec4(0.0,1.0,@,@);\r\n", colorDecl, roughness, metalness)); //reconstruct ormConfig, no ao darkening
|
||||
}
|
||||
|
||||
Var* wsNormal = (Var*)LangElement::find("wsNormal");
|
||||
Var* normal = (Var*)LangElement::find("normal");
|
||||
if (!normal)
|
||||
{
|
||||
normal = new Var("normal", "vec3");
|
||||
meta->addStatement(new GenOp(" @;\r\n\n", new DecOp(normal)));
|
||||
|
||||
Var* wsNormal = (Var*)LangElement::find("wsNormal");
|
||||
if (!fd.features[MFT_NormalMap])
|
||||
{
|
||||
Var* worldToTangent = getInWorldToTangent(componentList);
|
||||
meta->addStatement(new GenOp(" @ = normalize(tMul(@,vec3(0,0,1.0f)));\r\n\n", normal, worldToTangent));
|
||||
if (!wsNormal)
|
||||
wsNormal = getInWorldNormal(componentList);
|
||||
meta->addStatement(new GenOp(" @ = normalize( @ );\r\n\n", normal, wsNormal));
|
||||
}
|
||||
else
|
||||
{
|
||||
meta->addStatement(new GenOp(" @ = normalize( half3( @ ) );\r\n", normal, wsNormal));
|
||||
}
|
||||
meta->addStatement(new GenOp(" @ = normalize( @ );\r\n", normal, wsNormal));
|
||||
}
|
||||
}
|
||||
|
||||
Var* wsEyePos = (Var*)LangElement::find("eyePosWorld");
|
||||
|
|
@ -1979,6 +1982,7 @@ void ReflectCubeFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
Var *envColor = new Var("envColor", "vec3");
|
||||
meta->addStatement(new GenOp(" @ = @.rgb - (@.rgb * @);\r\n", new DecOp(dColor), targ, targ, metalness));
|
||||
meta->addStatement(new GenOp(" @ = @.rgb*(@).rgb;\r\n", new DecOp(envColor), targ, texCube));
|
||||
meta->addStatement(new GenOp(" @.rgb = @+@;\r\n", targ, dColor, envColor));
|
||||
}
|
||||
else if (lerpVal)
|
||||
meta->addStatement(new GenOp(" @ *= vec4(@.rgb*@.a, @.a);\r\n", targ, texCube, lerpVal, targ));
|
||||
|
|
@ -2067,7 +2071,6 @@ RTLightingFeatGLSL::RTLightingFeatGLSL()
|
|||
void RTLightingFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
{
|
||||
if (fd.features[MFT_ImposterVert]) return;
|
||||
MultiLine *meta = new MultiLine;
|
||||
|
||||
ShaderConnector *connectComp = dynamic_cast<ShaderConnector *>( componentList[C_CONNECTOR] );
|
||||
|
|
@ -2104,12 +2107,15 @@ void RTLightingFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
addOutWsPosition( componentList, fd.features[MFT_UseInstancing], meta );
|
||||
getOutWorldToTangent(componentList, meta, fd);
|
||||
|
||||
output = meta;
|
||||
|
||||
// Find the incoming vertex normal.
|
||||
Var *inNormal = (Var*)LangElement::find( "normal" );
|
||||
|
||||
// Skip out on realtime lighting if we don't have a normal
|
||||
// or we're doing some sort of baked lighting.
|
||||
|
||||
if ( !inNormal ||
|
||||
fd.features[MFT_LightMap] ||
|
||||
fd.features[MFT_ToneMap] ||
|
||||
|
|
@ -2118,8 +2124,7 @@ void RTLightingFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|||
|
||||
// If there isn't a normal map then we need to pass
|
||||
// the world space normal to the pixel shader ourselves.
|
||||
//Temporarily disabled while we figure out how to better handle normals without a normal map
|
||||
/*if ( !fd.features[MFT_NormalMap] )
|
||||
if ( !fd.features[MFT_NormalMap] )
|
||||
{
|
||||
Var *outNormal = connectComp->getElement( RT_TEXCOORD );
|
||||
outNormal->setName( "wsNormal" );
|
||||
|
|
@ -2131,13 +2136,8 @@ void RTLightingFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|||
|
||||
// Transform the normal to world space.
|
||||
meta->addStatement( new GenOp( " @ = tMul( @, vec4( normalize( @ ), 0.0 ) ).xyz;\r\n", outNormal, objTrans, inNormal ) );
|
||||
}*/
|
||||
}
|
||||
|
||||
addOutWsPosition( componentList, fd.features[MFT_UseInstancing], meta );
|
||||
|
||||
getOutWorldToTangent(componentList, meta, fd);
|
||||
|
||||
output = meta;
|
||||
}
|
||||
|
||||
void RTLightingFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||
|
|
@ -2158,14 +2158,10 @@ void RTLightingFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
|
||||
// Now the wsPosition and wsView.
|
||||
Var *wsPosition = getInWsPosition( componentList );
|
||||
Var* worldToTangent = getInWorldToTangent(componentList);
|
||||
Var* wsNormal = getInWorldNormal(componentList);
|
||||
Var *wsView = getWsView( wsPosition, meta );
|
||||
|
||||
// Create temporaries to hold results of lighting.
|
||||
Var *rtShading = new Var( "rtShading", "vec4" );
|
||||
Var *specular = new Var( "specular", "vec4" );
|
||||
meta->addStatement( new GenOp( " @; @;\r\n",
|
||||
new DecOp( rtShading ), new DecOp( specular ) ) );
|
||||
|
||||
// Look for a light mask generated from a previous
|
||||
// feature (this is done for BL terrain lightmaps).
|
||||
LangElement *lightMask = LangElement::find( "lightMask" );
|
||||
|
|
@ -2473,7 +2469,7 @@ void VisibilityFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
|
||||
// Everything else does a fizzle.
|
||||
Var *vPos = getInVpos( meta, componentList );
|
||||
meta->addStatement( new GenOp( " fizzle( @, @ );\r\n", vPos, visibility ) );
|
||||
meta->addStatement( new GenOp( " fizzle( @.xy, @ );\r\n", vPos, visibility ) );
|
||||
}
|
||||
|
||||
ShaderFeature::Resources VisibilityFeatGLSL::getResources( const MaterialFeatureData &fd )
|
||||
|
|
@ -2616,7 +2612,7 @@ void FoliageFeatureGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|||
tangent->setType( "vec3" );
|
||||
tangent->setName( "T" );
|
||||
LangElement *tangentDec = new DecOp( tangent );
|
||||
meta->addStatement( new GenOp( " @;\n", tangentDec ) );
|
||||
meta->addStatement( new GenOp( " @ = vec3(1.0,0,0);\n", tangentDec ) );
|
||||
|
||||
// We add a float foliageFade to the OUT structure.
|
||||
ShaderConnector *connectComp = dynamic_cast<ShaderConnector *>( componentList[C_CONNECTOR] );
|
||||
|
|
@ -2978,6 +2974,8 @@ void ReflectionProbeFeatGLSL::processPix(Vector<ShaderComponent*>& componentList
|
|||
|
||||
// Now the wsPosition and wsView.
|
||||
Var *wsPosition = getInWsPosition(componentList);
|
||||
Var *worldToTangent = getInWorldToTangent(componentList);
|
||||
Var *wsNormal = getInWorldNormal(componentList);
|
||||
Var *wsView = getWsView(wsPosition, meta);
|
||||
|
||||
//Reflection Probe WIP
|
||||
|
|
|
|||
|
|
@ -137,6 +137,7 @@ public:
|
|||
MultiLine *meta );
|
||||
|
||||
Var* getSurface(Vector<ShaderComponent*>& componentList, MultiLine* meta, const MaterialFeatureData& fd);
|
||||
Var* getInWorldNormal(Vector<ShaderComponent*>& componentList);
|
||||
|
||||
// ShaderFeature
|
||||
Var* getVertTexCoord( const String &name );
|
||||
|
|
|
|||
|
|
@ -879,12 +879,10 @@ Var* ShaderFeatureHLSL::getSurface(Vector<ShaderComponent*>& componentList, Mult
|
|||
meta->addStatement(new GenOp(" @;\r\n\n", new DecOp(normal)));
|
||||
|
||||
Var* wsNormal = (Var*)LangElement::find("wsNormal");
|
||||
|
||||
if (!fd.features[MFT_NormalMap])
|
||||
{
|
||||
if (!wsNormal)
|
||||
wsNormal = getInWorldNormal(componentList);
|
||||
|
||||
meta->addStatement(new GenOp(" @ = normalize( @ );\r\n\n", normal, wsNormal));
|
||||
}
|
||||
else
|
||||
|
|
@ -894,6 +892,14 @@ Var* ShaderFeatureHLSL::getSurface(Vector<ShaderComponent*>& componentList, Mult
|
|||
}
|
||||
|
||||
Var* wsEyePos = (Var*)LangElement::find("eyePosWorld");
|
||||
|
||||
if (!wsEyePos)
|
||||
{
|
||||
wsEyePos = new Var("eyePosWorld", "float3");
|
||||
wsEyePos->uniform = true;
|
||||
wsEyePos->constSortPos = cspPass;
|
||||
}
|
||||
|
||||
Var* wsPosition = getInWsPosition(componentList);
|
||||
Var* wsView = getWsView(wsPosition, meta);
|
||||
|
||||
|
|
@ -2138,8 +2144,6 @@ RTLightingFeatHLSL::RTLightingFeatHLSL()
|
|||
void RTLightingFeatHLSL::processVert( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
{
|
||||
if (fd.features[MFT_ImposterVert]) return;
|
||||
|
||||
MultiLine *meta = new MultiLine;
|
||||
|
||||
ShaderConnector *connectComp = dynamic_cast<ShaderConnector *>( componentList[C_CONNECTOR] );
|
||||
|
|
@ -2178,11 +2182,14 @@ void RTLightingFeatHLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|||
return;
|
||||
}
|
||||
|
||||
addOutWsPosition( componentList, fd.features[MFT_UseInstancing], meta );
|
||||
getOutWorldToTangent(componentList, meta, fd);
|
||||
output = meta;
|
||||
|
||||
|
||||
// Find the incoming vertex normal.
|
||||
Var *inNormal = (Var*)LangElement::find( "normal" );
|
||||
|
||||
// Skip out on realtime lighting if we don't have a normal
|
||||
// or we're doing some sort of baked lighting.
|
||||
if ( !inNormal ||
|
||||
fd.features[MFT_LightMap] ||
|
||||
fd.features[MFT_ToneMap] ||
|
||||
|
|
@ -2191,7 +2198,6 @@ void RTLightingFeatHLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|||
|
||||
// If there isn't a normal map then we need to pass
|
||||
// the world space normal to the pixel shader ourselves.
|
||||
//Temporarily disabled while we figure out how to better handle normals without a normal map
|
||||
if ( !fd.features[MFT_NormalMap] )
|
||||
{
|
||||
Var *outNormal = connectComp->getElement( RT_TEXCOORD );
|
||||
|
|
@ -2205,11 +2211,6 @@ void RTLightingFeatHLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|||
// Transform the normal to world space.
|
||||
meta->addStatement( new GenOp( " @ = mul( @, float4( normalize( @ ), 0.0 ) ).xyz;\r\n", outNormal, objTrans, inNormal ) );
|
||||
}
|
||||
|
||||
addOutWsPosition( componentList, fd.features[MFT_UseInstancing], meta );
|
||||
getOutWorldToTangent(componentList, meta, fd);
|
||||
|
||||
output = meta;
|
||||
}
|
||||
|
||||
void RTLightingFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||
|
|
@ -2229,10 +2230,9 @@ void RTLightingFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
MultiLine *meta = new MultiLine;
|
||||
|
||||
// Now the wsPosition and wsView.
|
||||
Var* worldToTangent = getInWorldToTangent(componentList);
|
||||
Var* wsNormal = getInWorldNormal(componentList);
|
||||
Var *wsPosition = getInWsPosition( componentList );
|
||||
|
||||
Var* worldToTangent = getInWorldToTangent(componentList);
|
||||
Var* wsNormal = getInWorldNormal(componentList);
|
||||
Var *wsView = getWsView( wsPosition, meta );
|
||||
|
||||
// Look for a light mask generated from a previous
|
||||
|
|
@ -2686,7 +2686,7 @@ void FoliageFeatureHLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|||
tangent->setType( "float3" );
|
||||
tangent->setName( "T" );
|
||||
LangElement *tangentDec = new DecOp( tangent );
|
||||
meta->addStatement( new GenOp( " @;\n", tangentDec ) );
|
||||
meta->addStatement( new GenOp( " @ = float3(1.0,0,0);\n", tangentDec ) );
|
||||
|
||||
// We add a float foliageFade to the OUT structure.
|
||||
ShaderConnector *connectComp = dynamic_cast<ShaderConnector *>( componentList[C_CONNECTOR] );
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
ShaderFeature::OutputTarget target = (fd.features[MFT_isDeferred]) ? RenderTarget1 : DefaultTarget;
|
||||
meta->addStatement(new GenOp(" @;\r\n", assignColor(baseColor, Material::Mul, NULL, target)));
|
||||
|
||||
if(fd.features.hasFeature(MFT_isDeferred))
|
||||
{
|
||||
target= ShaderFeature::RenderTarget1;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -174,7 +174,6 @@ public:
|
|||
virtual void processPix(Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd);
|
||||
|
||||
virtual U32 getOutputTargets(const MaterialFeatureData &fd) const;
|
||||
virtual String getName() { return "Blank Matinfo map"; }
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -337,27 +337,27 @@ void TerrainBaseMapFeatHLSL::processVert( Vector<ShaderComponent*> &componentLis
|
|||
new DecOp( inTanget ), squareSize, inTangentZ ) );
|
||||
}
|
||||
|
||||
void TerrainBaseMapFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
void TerrainBaseMapFeatHLSL::processPix(Vector<ShaderComponent*>& componentList,
|
||||
const MaterialFeatureData& fd)
|
||||
{
|
||||
// grab connector texcoord register
|
||||
Var *texCoord = getInTexCoord( "texCoord", "float3", componentList );
|
||||
Var* texCoord = getInTexCoord("texCoord", "float3", componentList);
|
||||
|
||||
// create texture var
|
||||
Var *diffuseMap = new Var;
|
||||
diffuseMap->setType( "SamplerState" );
|
||||
diffuseMap->setName( "baseTexMap" );
|
||||
Var* diffuseMap = new Var;
|
||||
diffuseMap->setType("SamplerState");
|
||||
diffuseMap->setName("baseTexMap");
|
||||
diffuseMap->uniform = true;
|
||||
diffuseMap->sampler = true;
|
||||
diffuseMap->constNum = Var::getTexUnitNum(); // used as texture unit num here
|
||||
|
||||
MultiLine *meta = new MultiLine;
|
||||
MultiLine* meta = new MultiLine;
|
||||
|
||||
Var *baseColor = new Var;
|
||||
baseColor->setType( "float4" );
|
||||
baseColor->setName( "baseColor" );
|
||||
Var* baseColor = new Var;
|
||||
baseColor->setType("float4");
|
||||
baseColor->setName("baseColor");
|
||||
|
||||
Var *diffuseTex = new Var;
|
||||
Var* diffuseTex = new Var;
|
||||
diffuseTex->setType("Texture2D");
|
||||
diffuseTex->setName("baseTexture");
|
||||
diffuseTex->uniform = true;
|
||||
|
|
@ -365,33 +365,31 @@ void TerrainBaseMapFeatHLSL::processPix( Vector<ShaderComponent*> &componentLis
|
|||
diffuseTex->constNum = diffuseMap->constNum;
|
||||
meta->addStatement(new GenOp(" @ = @.Sample( @, @.xy );\r\n", new DecOp(baseColor), diffuseTex, diffuseMap, texCoord));
|
||||
|
||||
ShaderFeature::OutputTarget target = ShaderFeature::DefaultTarget;
|
||||
ShaderFeature::OutputTarget target = (fd.features[MFT_isDeferred]) ? RenderTarget1 : DefaultTarget;
|
||||
meta->addStatement(new GenOp(" @;\r\n", assignColor(baseColor, Material::Mul, NULL, target)));
|
||||
|
||||
if (fd.features.hasFeature(MFT_isDeferred))
|
||||
{
|
||||
target= ShaderFeature::RenderTarget1;
|
||||
}
|
||||
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( baseColor, Material::Mul,NULL,target ) ) );
|
||||
|
||||
if (fd.features[MFT_isDeferred])
|
||||
Var* ormConfig;
|
||||
if ((fd.features[MFT_isDeferred]))
|
||||
{
|
||||
// Set base ORM info
|
||||
Var* ormConfig;
|
||||
OutputTarget targ = RenderTarget1;
|
||||
targ = RenderTarget2;
|
||||
ormConfig = (Var*)LangElement::find(getOutputTargetVarName(targ));
|
||||
ormConfig = (Var*)LangElement::find(getOutputTargetVarName(RenderTarget2));
|
||||
|
||||
if (!ormConfig)
|
||||
{
|
||||
// create color var
|
||||
ormConfig = new Var;
|
||||
ormConfig->setType("fragout");
|
||||
ormConfig->setName(getOutputTargetVarName(targ));
|
||||
ormConfig->setName(getOutputTargetVarName(RenderTarget2));
|
||||
ormConfig->setStructName("OUT");
|
||||
}
|
||||
|
||||
meta->addStatement(new GenOp(" @ = float4(0.0, 1.0, 1.0, 0.0);\r\n", ormConfig));
|
||||
}
|
||||
else
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
|
@ -407,7 +405,7 @@ ShaderFeature::Resources TerrainBaseMapFeatHLSL::getResources( const MaterialFea
|
|||
|
||||
U32 TerrainBaseMapFeatHLSL::getOutputTargets( const MaterialFeatureData &fd ) const
|
||||
{
|
||||
return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget1 | ShaderFeature::RenderTarget2 : ShaderFeature::DefaultTarget;
|
||||
return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 | ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
TerrainDetailMapFeatHLSL::TerrainDetailMapFeatHLSL()
|
||||
|
|
@ -1259,23 +1257,35 @@ void TerrainORMMapFeatHLSL::processPix(Vector<ShaderComponent*> &componentList,
|
|||
else
|
||||
texOp = new GenOp("@.Sample(@, float3(@.xy, @.x))", ormMapArray, ormMapSampler, inDet, new IndexOp(detailInfo, compositeIndex));
|
||||
|
||||
MultiLine* meta = new MultiLine;
|
||||
// search for material var
|
||||
Var * ormConfig;
|
||||
OutputTarget targ = RenderTarget1;
|
||||
if (fd.features[MFT_isDeferred])
|
||||
Var* ormConfig;
|
||||
if ((fd.features[MFT_isDeferred]))
|
||||
{
|
||||
targ = RenderTarget2;
|
||||
}
|
||||
ormConfig = (Var*)LangElement::find(getOutputTargetVarName(targ));
|
||||
// Set base ORM info
|
||||
ormConfig = (Var*)LangElement::find(getOutputTargetVarName(RenderTarget2));
|
||||
|
||||
MultiLine * meta = new MultiLine;
|
||||
if (!ormConfig)
|
||||
if (!ormConfig)
|
||||
{
|
||||
// create color var
|
||||
ormConfig = new Var;
|
||||
ormConfig->setType("fragout");
|
||||
ormConfig->setName(getOutputTargetVarName(RenderTarget2));
|
||||
ormConfig->setStructName("OUT");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// create color var
|
||||
ormConfig = new Var;
|
||||
ormConfig->setType("fragout");
|
||||
ormConfig->setName(getOutputTargetVarName(targ));
|
||||
ormConfig->setStructName("OUT");
|
||||
ormConfig = (Var*)LangElement::find("ORMConfig");
|
||||
if (!ormConfig)
|
||||
{
|
||||
ormConfig = new Var("ORMConfig", "float4");
|
||||
meta->addStatement(new GenOp(" @;\r\n", new DecOp(ormConfig)));
|
||||
}
|
||||
}
|
||||
if (compositeIndex == 0)
|
||||
{
|
||||
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));
|
||||
|
|
@ -1284,11 +1294,6 @@ void TerrainORMMapFeatHLSL::processPix(Vector<ShaderComponent*> &componentList,
|
|||
String matinfoName(String::ToString("matinfoCol%d", compositeIndex));
|
||||
Var *matinfoCol = new Var(matinfoName, "float3");
|
||||
|
||||
if (compositeIndex == 0)
|
||||
{
|
||||
meta->addStatement(new GenOp(" @ = float4(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))
|
||||
|
|
@ -1313,39 +1318,39 @@ ShaderFeature::Resources TerrainORMMapFeatHLSL::getResources(const MaterialFeatu
|
|||
return res;
|
||||
}
|
||||
|
||||
// reminder, the matinfo buffer is flags, smooth, ao, metal
|
||||
U32 TerrainBlankInfoMapFeatHLSL::getOutputTargets(const MaterialFeatureData &fd) const
|
||||
{
|
||||
return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget2 : ShaderFeature::RenderTarget1;
|
||||
}
|
||||
|
||||
void TerrainBlankInfoMapFeatHLSL::processPix(Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd)
|
||||
{
|
||||
S32 compositeIndex = getProcessIndex();
|
||||
|
||||
// search for material var
|
||||
Var *material;
|
||||
OutputTarget ormConfig = RenderTarget1;
|
||||
if (fd.features[MFT_isDeferred])
|
||||
MultiLine * meta = new MultiLine; Var* ormConfig;
|
||||
if ((fd.features[MFT_isDeferred]))
|
||||
{
|
||||
ormConfig = RenderTarget2;
|
||||
}
|
||||
material = (Var*)LangElement::find(getOutputTargetVarName(ormConfig));
|
||||
// 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("fragout");
|
||||
material->setName(getOutputTargetVarName(ormConfig));
|
||||
material->setStructName("OUT");
|
||||
ormConfig = (Var*)LangElement::find("ORMConfig");
|
||||
if (!ormConfig)
|
||||
{
|
||||
ormConfig = new Var("ORMConfig", "float4");
|
||||
meta->addStatement(new GenOp(" @;\r\n", new DecOp(ormConfig)));
|
||||
}
|
||||
}
|
||||
|
||||
if (compositeIndex == 0)
|
||||
{
|
||||
meta->addStatement(new GenOp(" @ = float4(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));
|
||||
|
|
@ -1355,7 +1360,7 @@ void TerrainBlankInfoMapFeatHLSL::processPix(Vector<ShaderComponent*> &component
|
|||
|
||||
if (!fd.features.hasFeature(MFT_TerrainHeightBlend))
|
||||
{
|
||||
meta->addStatement(new GenOp(" @.gba += float3(@, @, 0.0);\r\n", material, detailBlend, detailBlend));
|
||||
meta->addStatement(new GenOp(" @.gba += float3(@, @, 0.0);\r\n", ormConfig, detailBlend, detailBlend));
|
||||
}
|
||||
|
||||
output = meta;
|
||||
|
|
|
|||
|
|
@ -179,8 +179,6 @@ public:
|
|||
|
||||
virtual void processPix(Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd);
|
||||
|
||||
virtual U32 getOutputTargets(const MaterialFeatureData &fd) const;
|
||||
virtual String getName() { return "Blank Matinfo map"; }
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -59,8 +59,8 @@ function initRenderManager()
|
|||
DiffuseRenderPassManager.addManager( new RenderObjectMgr(ObjectBin) { bintype = "Object"; renderOrder = 0.6; processAddOrder = 0.6; } );
|
||||
|
||||
DiffuseRenderPassManager.addManager( new RenderObjectMgr(ShadowBin) { bintype = "Shadow"; renderOrder = 0.7; processAddOrder = 0.7; } );
|
||||
DiffuseRenderPassManager.addManager( new RenderMeshMgr(DecalRoadBin) { bintype = "DecalRoad"; renderOrder = 0.8; processAddOrder = 0.8; basicOnly = true;} );
|
||||
DiffuseRenderPassManager.addManager( new RenderMeshMgr(DecalBin) { bintype = "Decal"; renderOrder = 0.81; processAddOrder = 0.81; basicOnly = true;} );
|
||||
DiffuseRenderPassManager.addManager( new RenderMeshMgr(DecalRoadBin) { bintype = "DecalRoad"; renderOrder = 0.8; processAddOrder = 0.8; } );
|
||||
DiffuseRenderPassManager.addManager( new RenderMeshMgr(DecalBin) { bintype = "Decal"; renderOrder = 0.81; processAddOrder = 0.81;} );
|
||||
DiffuseRenderPassManager.addManager( new RenderOcclusionMgr(OccluderBin){ bintype = "Occluder"; renderOrder = 0.9; processAddOrder = 0.9; } );
|
||||
|
||||
// Render the sky last
|
||||
|
|
|
|||
|
|
@ -291,8 +291,8 @@ void fizzle(vec2 vpos, float visibility)
|
|||
// I'm sure there are many more patterns here to
|
||||
// discover for different effects.
|
||||
|
||||
mat2x2 m = mat2x2( vpos.x, vpos.y, 0.916, 0.350 );
|
||||
if( (visibility - fract( determinant( m ) )) < 0 ) //if(a < 0) discard;
|
||||
mat2x2 m = mat2x2( vpos.x, 0.916, vpos.y, 0.350 );
|
||||
if( (visibility - fract( determinant( m ) )) < 0 )
|
||||
discard;
|
||||
}
|
||||
#endif //TORQUE_PIXEL_SHADER
|
||||
|
|
|
|||
Loading…
Reference in a new issue