mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 15:14:35 +00:00
commit
fe3edb8ccf
12 changed files with 229 additions and 214 deletions
|
|
@ -562,6 +562,7 @@ void GFXGLShader::initConstantDescs()
|
||||||
|
|
||||||
if(!maxNameLength)
|
if(!maxNameLength)
|
||||||
return;
|
return;
|
||||||
|
maxNameLength++;
|
||||||
|
|
||||||
FrameTemp<GLchar> uniformName(maxNameLength);
|
FrameTemp<GLchar> uniformName(maxNameLength);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -186,10 +186,8 @@ void ShadowMaterialHook::_overrideFeatures( ProcessedMaterial *mat,
|
||||||
type == MFT_TexAnim ||
|
type == MFT_TexAnim ||
|
||||||
type == MFT_DiffuseMap ||
|
type == MFT_DiffuseMap ||
|
||||||
type == MFT_IsTranslucent ||
|
type == MFT_IsTranslucent ||
|
||||||
type == MFT_Visibility ||
|
|
||||||
type == MFT_UseInstancing ||
|
type == MFT_UseInstancing ||
|
||||||
type == MFT_EyeSpaceDepthOut ||
|
type == MFT_EyeSpaceDepthOut)
|
||||||
type == MFT_DeferredConditioner)
|
|
||||||
newFeatures.addFeature(type);
|
newFeatures.addFeature(type);
|
||||||
else if (type.getGroup() == MFG_PreTransform ||
|
else if (type.getGroup() == MFG_PreTransform ||
|
||||||
type.getGroup() == MFG_Transform ||
|
type.getGroup() == MFG_Transform ||
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,7 @@ GFXTextureObject* PostEffectManager::getBackBufferTex()
|
||||||
|
|
||||||
mBackBufferCopyTex.set( targetSize.x, targetSize.y,
|
mBackBufferCopyTex.set( targetSize.x, targetSize.y,
|
||||||
targetFormat,
|
targetFormat,
|
||||||
&PostFxTargetProfile, "mBackBufferCopyTex" );
|
&PostFxTextureSRGBProfile, "mBackBufferCopyTex" );
|
||||||
|
|
||||||
target->resolveTo( mBackBufferCopyTex );
|
target->resolveTo( mBackBufferCopyTex );
|
||||||
mLastBackBufferTarget = target;
|
mLastBackBufferTarget = target;
|
||||||
|
|
|
||||||
|
|
@ -474,25 +474,11 @@ Var* ShaderFeatureGLSL::getInVpos( MultiLine *meta,
|
||||||
return inVpos;
|
return inVpos;
|
||||||
|
|
||||||
ShaderConnector *connectComp = dynamic_cast<ShaderConnector*>( componentList[C_CONNECTOR] );
|
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 = connectComp->getElement( RT_TEXCOORD );
|
||||||
inVpos->setName( "inVpos" );
|
inVpos->setName( "inVpos" );
|
||||||
inVpos->setStructName( "IN" );
|
inVpos->setStructName( "IN" );
|
||||||
inVpos->setType( "vec4" );
|
inVpos->setType( "vec4" );
|
||||||
|
return inVpos;
|
||||||
Var *vpos = new Var( "vpos", "vec2" );
|
|
||||||
meta->addStatement( new GenOp( " @ = @.xy / @.w;\r\n", new DecOp( vpos ), inVpos, inVpos ) );
|
|
||||||
|
|
||||||
return vpos;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Var* ShaderFeatureGLSL::getInWorldToTangent( Vector<ShaderComponent*> &componentList )
|
Var* ShaderFeatureGLSL::getInWorldToTangent( Vector<ShaderComponent*> &componentList )
|
||||||
|
|
@ -779,6 +765,21 @@ Var* ShaderFeatureGLSL::getWsView( Var *wsPosition, MultiLine *meta )
|
||||||
return wsView;
|
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,
|
Var* ShaderFeatureGLSL::addOutDetailTexCoord( Vector<ShaderComponent*> &componentList,
|
||||||
MultiLine *meta,
|
MultiLine *meta,
|
||||||
bool useTexAnim,
|
bool useTexAnim,
|
||||||
|
|
@ -865,20 +866,22 @@ 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
|
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");
|
Var* normal = (Var*)LangElement::find("normal");
|
||||||
if (!normal)
|
if (!normal)
|
||||||
{
|
{
|
||||||
normal = new Var("normal", "vec3");
|
normal = new Var("normal", "vec3");
|
||||||
meta->addStatement(new GenOp(" @;\r\n\n", new DecOp(normal)));
|
meta->addStatement(new GenOp(" @;\r\n\n", new DecOp(normal)));
|
||||||
|
|
||||||
|
Var* wsNormal = (Var*)LangElement::find("wsNormal");
|
||||||
if (!fd.features[MFT_NormalMap])
|
if (!fd.features[MFT_NormalMap])
|
||||||
{
|
{
|
||||||
Var* worldToTangent = getInWorldToTangent(componentList);
|
if (!wsNormal)
|
||||||
meta->addStatement(new GenOp(" @ = normalize(tMul(@,vec3(0,0,1.0f)));\r\n\n", normal, worldToTangent));
|
wsNormal = getInWorldNormal(componentList);
|
||||||
|
meta->addStatement(new GenOp(" @ = normalize( @ );\r\n\n", normal, wsNormal));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
meta->addStatement(new GenOp(" @ = normalize( half3( @ ) );\r\n", normal, wsNormal));
|
meta->addStatement(new GenOp(" @ = normalize( @ );\r\n", normal, wsNormal));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1979,6 +1982,7 @@ void ReflectCubeFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||||
Var *envColor = new Var("envColor", "vec3");
|
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(dColor), targ, targ, metalness));
|
||||||
meta->addStatement(new GenOp(" @ = @.rgb*(@).rgb;\r\n", new DecOp(envColor), targ, texCube));
|
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)
|
else if (lerpVal)
|
||||||
meta->addStatement(new GenOp(" @ *= vec4(@.rgb*@.a, @.a);\r\n", targ, texCube, lerpVal, targ));
|
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,
|
void RTLightingFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
||||||
const MaterialFeatureData &fd )
|
const MaterialFeatureData &fd )
|
||||||
{
|
{
|
||||||
if (fd.features[MFT_ImposterVert]) return;
|
|
||||||
MultiLine *meta = new MultiLine;
|
MultiLine *meta = new MultiLine;
|
||||||
|
|
||||||
ShaderConnector *connectComp = dynamic_cast<ShaderConnector *>( componentList[C_CONNECTOR] );
|
ShaderConnector *connectComp = dynamic_cast<ShaderConnector *>( componentList[C_CONNECTOR] );
|
||||||
|
|
@ -2105,11 +2108,14 @@ void RTLightingFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addOutWsPosition( componentList, fd.features[MFT_UseInstancing], meta );
|
||||||
|
getOutWorldToTangent(componentList, meta, fd);
|
||||||
|
|
||||||
|
output = meta;
|
||||||
|
|
||||||
// Find the incoming vertex normal.
|
// Find the incoming vertex normal.
|
||||||
Var *inNormal = (Var*)LangElement::find( "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 ||
|
if ( !inNormal ||
|
||||||
fd.features[MFT_LightMap] ||
|
fd.features[MFT_LightMap] ||
|
||||||
fd.features[MFT_ToneMap] ||
|
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
|
// If there isn't a normal map then we need to pass
|
||||||
// the world space normal to the pixel shader ourselves.
|
// 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 );
|
Var *outNormal = connectComp->getElement( RT_TEXCOORD );
|
||||||
outNormal->setName( "wsNormal" );
|
outNormal->setName( "wsNormal" );
|
||||||
|
|
@ -2131,13 +2136,8 @@ void RTLightingFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
||||||
|
|
||||||
// Transform the normal to world space.
|
// Transform the normal to world space.
|
||||||
meta->addStatement( new GenOp( " @ = tMul( @, vec4( normalize( @ ), 0.0 ) ).xyz;\r\n", outNormal, objTrans, inNormal ) );
|
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,
|
void RTLightingFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||||
|
|
@ -2158,14 +2158,10 @@ void RTLightingFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||||
|
|
||||||
// Now the wsPosition and wsView.
|
// Now the wsPosition and wsView.
|
||||||
Var *wsPosition = getInWsPosition( componentList );
|
Var *wsPosition = getInWsPosition( componentList );
|
||||||
|
Var* worldToTangent = getInWorldToTangent(componentList);
|
||||||
|
Var* wsNormal = getInWorldNormal(componentList);
|
||||||
Var *wsView = getWsView( wsPosition, meta );
|
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
|
// Look for a light mask generated from a previous
|
||||||
// feature (this is done for BL terrain lightmaps).
|
// feature (this is done for BL terrain lightmaps).
|
||||||
LangElement *lightMask = LangElement::find( "lightMask" );
|
LangElement *lightMask = LangElement::find( "lightMask" );
|
||||||
|
|
@ -2473,7 +2469,7 @@ void VisibilityFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||||
|
|
||||||
// Everything else does a fizzle.
|
// Everything else does a fizzle.
|
||||||
Var *vPos = getInVpos( meta, componentList );
|
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 )
|
ShaderFeature::Resources VisibilityFeatGLSL::getResources( const MaterialFeatureData &fd )
|
||||||
|
|
@ -2616,7 +2612,7 @@ void FoliageFeatureGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
||||||
tangent->setType( "vec3" );
|
tangent->setType( "vec3" );
|
||||||
tangent->setName( "T" );
|
tangent->setName( "T" );
|
||||||
LangElement *tangentDec = new DecOp( tangent );
|
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.
|
// We add a float foliageFade to the OUT structure.
|
||||||
ShaderConnector *connectComp = dynamic_cast<ShaderConnector *>( componentList[C_CONNECTOR] );
|
ShaderConnector *connectComp = dynamic_cast<ShaderConnector *>( componentList[C_CONNECTOR] );
|
||||||
|
|
@ -2978,6 +2974,8 @@ void ReflectionProbeFeatGLSL::processPix(Vector<ShaderComponent*>& componentList
|
||||||
|
|
||||||
// Now the wsPosition and wsView.
|
// Now the wsPosition and wsView.
|
||||||
Var *wsPosition = getInWsPosition(componentList);
|
Var *wsPosition = getInWsPosition(componentList);
|
||||||
|
Var *worldToTangent = getInWorldToTangent(componentList);
|
||||||
|
Var *wsNormal = getInWorldNormal(componentList);
|
||||||
Var *wsView = getWsView(wsPosition, meta);
|
Var *wsView = getWsView(wsPosition, meta);
|
||||||
|
|
||||||
//Reflection Probe WIP
|
//Reflection Probe WIP
|
||||||
|
|
|
||||||
|
|
@ -137,6 +137,7 @@ public:
|
||||||
MultiLine *meta );
|
MultiLine *meta );
|
||||||
|
|
||||||
Var* getSurface(Vector<ShaderComponent*>& componentList, MultiLine* meta, const MaterialFeatureData& fd);
|
Var* getSurface(Vector<ShaderComponent*>& componentList, MultiLine* meta, const MaterialFeatureData& fd);
|
||||||
|
Var* getInWorldNormal(Vector<ShaderComponent*>& componentList);
|
||||||
|
|
||||||
// ShaderFeature
|
// ShaderFeature
|
||||||
Var* getVertTexCoord( const String &name );
|
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)));
|
meta->addStatement(new GenOp(" @;\r\n\n", new DecOp(normal)));
|
||||||
|
|
||||||
Var* wsNormal = (Var*)LangElement::find("wsNormal");
|
Var* wsNormal = (Var*)LangElement::find("wsNormal");
|
||||||
|
|
||||||
if (!fd.features[MFT_NormalMap])
|
if (!fd.features[MFT_NormalMap])
|
||||||
{
|
{
|
||||||
if (!wsNormal)
|
if (!wsNormal)
|
||||||
wsNormal = getInWorldNormal(componentList);
|
wsNormal = getInWorldNormal(componentList);
|
||||||
|
|
||||||
meta->addStatement(new GenOp(" @ = normalize( @ );\r\n\n", normal, wsNormal));
|
meta->addStatement(new GenOp(" @ = normalize( @ );\r\n\n", normal, wsNormal));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -894,6 +892,14 @@ Var* ShaderFeatureHLSL::getSurface(Vector<ShaderComponent*>& componentList, Mult
|
||||||
}
|
}
|
||||||
|
|
||||||
Var* wsEyePos = (Var*)LangElement::find("eyePosWorld");
|
Var* wsEyePos = (Var*)LangElement::find("eyePosWorld");
|
||||||
|
|
||||||
|
if (!wsEyePos)
|
||||||
|
{
|
||||||
|
wsEyePos = new Var("eyePosWorld", "float3");
|
||||||
|
wsEyePos->uniform = true;
|
||||||
|
wsEyePos->constSortPos = cspPass;
|
||||||
|
}
|
||||||
|
|
||||||
Var* wsPosition = getInWsPosition(componentList);
|
Var* wsPosition = getInWsPosition(componentList);
|
||||||
Var* wsView = getWsView(wsPosition, meta);
|
Var* wsView = getWsView(wsPosition, meta);
|
||||||
|
|
||||||
|
|
@ -2138,8 +2144,6 @@ RTLightingFeatHLSL::RTLightingFeatHLSL()
|
||||||
void RTLightingFeatHLSL::processVert( Vector<ShaderComponent*> &componentList,
|
void RTLightingFeatHLSL::processVert( Vector<ShaderComponent*> &componentList,
|
||||||
const MaterialFeatureData &fd )
|
const MaterialFeatureData &fd )
|
||||||
{
|
{
|
||||||
if (fd.features[MFT_ImposterVert]) return;
|
|
||||||
|
|
||||||
MultiLine *meta = new MultiLine;
|
MultiLine *meta = new MultiLine;
|
||||||
|
|
||||||
ShaderConnector *connectComp = dynamic_cast<ShaderConnector *>( componentList[C_CONNECTOR] );
|
ShaderConnector *connectComp = dynamic_cast<ShaderConnector *>( componentList[C_CONNECTOR] );
|
||||||
|
|
@ -2178,11 +2182,14 @@ void RTLightingFeatHLSL::processVert( Vector<ShaderComponent*> &componentList,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addOutWsPosition( componentList, fd.features[MFT_UseInstancing], meta );
|
||||||
|
getOutWorldToTangent(componentList, meta, fd);
|
||||||
|
output = meta;
|
||||||
|
|
||||||
|
|
||||||
// Find the incoming vertex normal.
|
// Find the incoming vertex normal.
|
||||||
Var *inNormal = (Var*)LangElement::find( "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 ||
|
if ( !inNormal ||
|
||||||
fd.features[MFT_LightMap] ||
|
fd.features[MFT_LightMap] ||
|
||||||
fd.features[MFT_ToneMap] ||
|
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
|
// If there isn't a normal map then we need to pass
|
||||||
// the world space normal to the pixel shader ourselves.
|
// 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 );
|
Var *outNormal = connectComp->getElement( RT_TEXCOORD );
|
||||||
|
|
@ -2205,11 +2211,6 @@ void RTLightingFeatHLSL::processVert( Vector<ShaderComponent*> &componentList,
|
||||||
// Transform the normal to world space.
|
// Transform the normal to world space.
|
||||||
meta->addStatement( new GenOp( " @ = mul( @, float4( normalize( @ ), 0.0 ) ).xyz;\r\n", outNormal, objTrans, inNormal ) );
|
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,
|
void RTLightingFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||||
|
|
@ -2229,10 +2230,9 @@ void RTLightingFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||||
MultiLine *meta = new MultiLine;
|
MultiLine *meta = new MultiLine;
|
||||||
|
|
||||||
// Now the wsPosition and wsView.
|
// Now the wsPosition and wsView.
|
||||||
|
Var *wsPosition = getInWsPosition( componentList );
|
||||||
Var* worldToTangent = getInWorldToTangent(componentList);
|
Var* worldToTangent = getInWorldToTangent(componentList);
|
||||||
Var* wsNormal = getInWorldNormal(componentList);
|
Var* wsNormal = getInWorldNormal(componentList);
|
||||||
Var *wsPosition = getInWsPosition( componentList );
|
|
||||||
|
|
||||||
Var *wsView = getWsView( wsPosition, meta );
|
Var *wsView = getWsView( wsPosition, meta );
|
||||||
|
|
||||||
// Look for a light mask generated from a previous
|
// Look for a light mask generated from a previous
|
||||||
|
|
@ -2686,7 +2686,7 @@ void FoliageFeatureHLSL::processVert( Vector<ShaderComponent*> &componentList,
|
||||||
tangent->setType( "float3" );
|
tangent->setType( "float3" );
|
||||||
tangent->setName( "T" );
|
tangent->setName( "T" );
|
||||||
LangElement *tangentDec = new DecOp( tangent );
|
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.
|
// We add a float foliageFade to the OUT structure.
|
||||||
ShaderConnector *connectComp = dynamic_cast<ShaderConnector *>( componentList[C_CONNECTOR] );
|
ShaderConnector *connectComp = dynamic_cast<ShaderConnector *>( componentList[C_CONNECTOR] );
|
||||||
|
|
|
||||||
|
|
@ -281,6 +281,8 @@ void TerrainBaseMapFeatGLSL::processVert( Vector<ShaderComponent*> &componentLis
|
||||||
Var *squareSize = _getUniformVar( "squareSize", "float", cspPass );
|
Var *squareSize = _getUniformVar( "squareSize", "float", cspPass );
|
||||||
meta->addStatement( new GenOp( " @ = normalize( vec3( @, 0, @ ) );\r\n",
|
meta->addStatement( new GenOp( " @ = normalize( vec3( @, 0, @ ) );\r\n",
|
||||||
new DecOp( inTanget ), squareSize, inTangentZ ) );
|
new DecOp( inTanget ), squareSize, inTangentZ ) );
|
||||||
|
|
||||||
|
getOutViewToTangent(componentList, meta, fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TerrainBaseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
void TerrainBaseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||||
|
|
@ -304,34 +306,35 @@ void TerrainBaseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentLis
|
||||||
baseColor->setName( "baseColor" );
|
baseColor->setName( "baseColor" );
|
||||||
meta->addStatement( new GenOp( " @ = tex2D( @, @.xy );\r\n", new DecOp( baseColor ), diffuseMap, texCoord ) );
|
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;
|
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));
|
else
|
||||||
if (!ormConfig)
|
|
||||||
{
|
{
|
||||||
// create color var
|
ormConfig = new Var("ORMConfig", "float4");
|
||||||
ormConfig = new Var;
|
meta->addStatement(new GenOp(" @;\r\n", new DecOp(ormConfig)));
|
||||||
ormConfig->setType("fragout");
|
|
||||||
ormConfig->setName(getOutputTargetVarName(targ));
|
|
||||||
ormConfig->setStructName("OUT");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
meta->addStatement(new GenOp(" @ = float4(0.0, 1.0, 1.0, 0.0);\r\n", ormConfig));
|
meta->addStatement(new GenOp(" @ = float4(0.0, 1.0, 1.0, 0.0);\r\n", ormConfig));
|
||||||
|
|
||||||
output = meta;
|
output = meta;
|
||||||
|
|
||||||
|
Var* viewToTangent = getInViewToTangent(componentList);
|
||||||
}
|
}
|
||||||
|
|
||||||
ShaderFeature::Resources TerrainBaseMapFeatGLSL::getResources( const MaterialFeatureData &fd )
|
ShaderFeature::Resources TerrainBaseMapFeatGLSL::getResources( const MaterialFeatureData &fd )
|
||||||
|
|
@ -347,7 +350,7 @@ ShaderFeature::Resources TerrainBaseMapFeatGLSL::getResources( const MaterialFea
|
||||||
|
|
||||||
U32 TerrainBaseMapFeatGLSL::getOutputTargets( const MaterialFeatureData &fd ) const
|
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()
|
TerrainDetailMapFeatGLSL::TerrainDetailMapFeatGLSL()
|
||||||
|
|
@ -782,6 +785,22 @@ void TerrainMacroMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentL
|
||||||
meta->addStatement( new GenOp( " @ = calcBlend( @.x, @.xy, @, @ );\r\n",
|
meta->addStatement( new GenOp( " @ = calcBlend( @.x, @.xy, @, @ );\r\n",
|
||||||
new DecOp( detailBlend ), detailInfo, inTex, layerSize, layerSample ) );
|
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" );
|
Var *detailColor = (Var*)LangElement::find( "macroColor" );
|
||||||
if ( !detailColor )
|
if ( !detailColor )
|
||||||
{
|
{
|
||||||
|
|
@ -1167,24 +1186,36 @@ void TerrainORMMapFeatGLSL::processPix(Vector<ShaderComponent*> &componentList,
|
||||||
else
|
else
|
||||||
texOp = new GenOp("tex2D(@, vec3(@.xy, @.x))", ormConfigMap, inDet, new IndexOp(detailInfo, compositeIndex));
|
texOp = new GenOp("tex2D(@, vec3(@.xy, @.x))", ormConfigMap, inDet, new IndexOp(detailInfo, compositeIndex));
|
||||||
|
|
||||||
// search for material var
|
MultiLine* meta = new MultiLine;
|
||||||
Var * ormConfig;
|
// search for material var
|
||||||
OutputTarget targ = RenderTarget1;
|
Var* ormConfig;
|
||||||
if (fd.features[MFT_isDeferred])
|
if ((fd.features[MFT_isDeferred]))
|
||||||
{
|
{
|
||||||
targ = RenderTarget2;
|
// Set base ORM info
|
||||||
}
|
ormConfig = (Var*)LangElement::find(getOutputTargetVarName(RenderTarget2));
|
||||||
ormConfig = (Var*)LangElement::find(getOutputTargetVarName(targ));
|
|
||||||
|
|
||||||
MultiLine * meta = new MultiLine;
|
if (!ormConfig)
|
||||||
if (!ormConfig)
|
{
|
||||||
{
|
// create color var
|
||||||
// create color var
|
ormConfig = new Var;
|
||||||
ormConfig = new Var;
|
ormConfig->setType("fragout");
|
||||||
ormConfig->setType("fragout");
|
ormConfig->setName(getOutputTargetVarName(RenderTarget2));
|
||||||
ormConfig->setName(getOutputTargetVarName(targ));
|
ormConfig->setStructName("OUT");
|
||||||
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));
|
Var *detailBlend = (Var*)LangElement::find(String::ToString("detailBlend%d", compositeIndex));
|
||||||
AssertFatal(detailBlend, "The detail blend is missing!");
|
AssertFatal(detailBlend, "The detail blend is missing!");
|
||||||
|
|
@ -1192,11 +1223,6 @@ void TerrainORMMapFeatGLSL::processPix(Vector<ShaderComponent*> &componentList,
|
||||||
String matinfoName(String::ToString("matinfoCol%d", compositeIndex));
|
String matinfoName(String::ToString("matinfoCol%d", compositeIndex));
|
||||||
Var *matinfoCol = new Var(matinfoName, "vec3");
|
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));
|
meta->addStatement(new GenOp(" @ = @.rgb;\r\n", new DecOp(matinfoCol), texOp));
|
||||||
|
|
||||||
if (fd.features.hasFeature(MFT_InvertRoughness, compositeIndex))
|
if (fd.features.hasFeature(MFT_InvertRoughness, compositeIndex))
|
||||||
|
|
@ -1218,58 +1244,44 @@ void TerrainORMMapFeatGLSL::processPix(Vector<ShaderComponent*> &componentList,
|
||||||
ShaderFeature::Resources TerrainORMMapFeatGLSL::getResources(const MaterialFeatureData &fd)
|
ShaderFeature::Resources TerrainORMMapFeatGLSL::getResources(const MaterialFeatureData &fd)
|
||||||
{
|
{
|
||||||
Resources res;
|
Resources res;
|
||||||
|
res.numTex = 1;
|
||||||
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;
|
|
||||||
}
|
|
||||||
return res;
|
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
|
// reminder, the matinfo buffer is flags, smooth, ao, metal
|
||||||
void TerrainBlankInfoMapFeatGLSL::processPix(Vector<ShaderComponent*> &componentList,
|
void TerrainBlankInfoMapFeatGLSL::processPix(Vector<ShaderComponent*> &componentList,
|
||||||
const MaterialFeatureData &fd)
|
const MaterialFeatureData &fd)
|
||||||
{
|
{
|
||||||
S32 compositeIndex = getProcessIndex();
|
S32 compositeIndex = getProcessIndex();
|
||||||
|
|
||||||
// search for material var
|
MultiLine* meta = new MultiLine; Var* ormConfig;
|
||||||
Var *material;
|
if ((fd.features[MFT_isDeferred]))
|
||||||
OutputTarget targ = DefaultTarget;
|
|
||||||
if (fd.features[MFT_isDeferred])
|
|
||||||
{
|
{
|
||||||
targ = RenderTarget2;
|
// Set base ORM info
|
||||||
}
|
ormConfig = (Var*)LangElement::find(getOutputTargetVarName(RenderTarget2));
|
||||||
material = (Var*)LangElement::find(getOutputTargetVarName(targ));
|
|
||||||
|
|
||||||
MultiLine * meta = new MultiLine;
|
if (!ormConfig)
|
||||||
if (!material)
|
{
|
||||||
|
// create color var
|
||||||
|
ormConfig = new Var;
|
||||||
|
ormConfig->setType("fragout");
|
||||||
|
ormConfig->setName(getOutputTargetVarName(RenderTarget2));
|
||||||
|
ormConfig->setStructName("OUT");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
// create color var
|
ormConfig = (Var*)LangElement::find("ORMConfig");
|
||||||
material = new Var;
|
if (!ormConfig)
|
||||||
material->setType("vec4");
|
{
|
||||||
material->setName(getOutputTargetVarName(targ));
|
ormConfig = new Var("ORMConfig", "vec4");
|
||||||
material->setStructName("OUT");
|
meta->addStatement(new GenOp(" @;\r\n", new DecOp(ormConfig)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (compositeIndex == 0)
|
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));
|
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));
|
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;
|
output = meta;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -174,7 +174,6 @@ public:
|
||||||
virtual void processPix(Vector<ShaderComponent*> &componentList,
|
virtual void processPix(Vector<ShaderComponent*> &componentList,
|
||||||
const MaterialFeatureData &fd);
|
const MaterialFeatureData &fd);
|
||||||
|
|
||||||
virtual U32 getOutputTargets(const MaterialFeatureData &fd) const;
|
|
||||||
virtual String getName() { return "Blank Matinfo map"; }
|
virtual String getName() { return "Blank Matinfo map"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -337,27 +337,27 @@ void TerrainBaseMapFeatHLSL::processVert( Vector<ShaderComponent*> &componentLis
|
||||||
new DecOp( inTanget ), squareSize, inTangentZ ) );
|
new DecOp( inTanget ), squareSize, inTangentZ ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void TerrainBaseMapFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
void TerrainBaseMapFeatHLSL::processPix(Vector<ShaderComponent*>& componentList,
|
||||||
const MaterialFeatureData &fd )
|
const MaterialFeatureData& fd)
|
||||||
{
|
{
|
||||||
// grab connector texcoord register
|
// grab connector texcoord register
|
||||||
Var *texCoord = getInTexCoord( "texCoord", "float3", componentList );
|
Var* texCoord = getInTexCoord("texCoord", "float3", componentList);
|
||||||
|
|
||||||
// create texture var
|
// create texture var
|
||||||
Var *diffuseMap = new Var;
|
Var* diffuseMap = new Var;
|
||||||
diffuseMap->setType( "SamplerState" );
|
diffuseMap->setType("SamplerState");
|
||||||
diffuseMap->setName( "baseTexMap" );
|
diffuseMap->setName("baseTexMap");
|
||||||
diffuseMap->uniform = true;
|
diffuseMap->uniform = true;
|
||||||
diffuseMap->sampler = true;
|
diffuseMap->sampler = true;
|
||||||
diffuseMap->constNum = Var::getTexUnitNum(); // used as texture unit num here
|
diffuseMap->constNum = Var::getTexUnitNum(); // used as texture unit num here
|
||||||
|
|
||||||
MultiLine *meta = new MultiLine;
|
MultiLine* meta = new MultiLine;
|
||||||
|
|
||||||
Var *baseColor = new Var;
|
Var* baseColor = new Var;
|
||||||
baseColor->setType( "float4" );
|
baseColor->setType("float4");
|
||||||
baseColor->setName( "baseColor" );
|
baseColor->setName("baseColor");
|
||||||
|
|
||||||
Var *diffuseTex = new Var;
|
Var* diffuseTex = new Var;
|
||||||
diffuseTex->setType("Texture2D");
|
diffuseTex->setType("Texture2D");
|
||||||
diffuseTex->setName("baseTexture");
|
diffuseTex->setName("baseTexture");
|
||||||
diffuseTex->uniform = true;
|
diffuseTex->uniform = true;
|
||||||
|
|
@ -365,33 +365,31 @@ void TerrainBaseMapFeatHLSL::processPix( Vector<ShaderComponent*> &componentLis
|
||||||
diffuseTex->constNum = diffuseMap->constNum;
|
diffuseTex->constNum = diffuseMap->constNum;
|
||||||
meta->addStatement(new GenOp(" @ = @.Sample( @, @.xy );\r\n", new DecOp(baseColor), diffuseTex, diffuseMap, texCoord));
|
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))
|
Var* ormConfig;
|
||||||
{
|
if ((fd.features[MFT_isDeferred]))
|
||||||
target= ShaderFeature::RenderTarget1;
|
|
||||||
}
|
|
||||||
|
|
||||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( baseColor, Material::Mul,NULL,target ) ) );
|
|
||||||
|
|
||||||
if (fd.features[MFT_isDeferred])
|
|
||||||
{
|
{
|
||||||
// Set base ORM info
|
// Set base ORM info
|
||||||
Var* ormConfig;
|
ormConfig = (Var*)LangElement::find(getOutputTargetVarName(RenderTarget2));
|
||||||
OutputTarget targ = RenderTarget1;
|
|
||||||
targ = RenderTarget2;
|
|
||||||
ormConfig = (Var*)LangElement::find(getOutputTargetVarName(targ));
|
|
||||||
if (!ormConfig)
|
if (!ormConfig)
|
||||||
{
|
{
|
||||||
// create color var
|
// create color var
|
||||||
ormConfig = new Var;
|
ormConfig = new Var;
|
||||||
ormConfig->setType("fragout");
|
ormConfig->setType("fragout");
|
||||||
ormConfig->setName(getOutputTargetVarName(targ));
|
ormConfig->setName(getOutputTargetVarName(RenderTarget2));
|
||||||
ormConfig->setStructName("OUT");
|
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;
|
output = meta;
|
||||||
}
|
}
|
||||||
|
|
@ -407,7 +405,7 @@ ShaderFeature::Resources TerrainBaseMapFeatHLSL::getResources( const MaterialFea
|
||||||
|
|
||||||
U32 TerrainBaseMapFeatHLSL::getOutputTargets( const MaterialFeatureData &fd ) const
|
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()
|
TerrainDetailMapFeatHLSL::TerrainDetailMapFeatHLSL()
|
||||||
|
|
@ -1259,23 +1257,35 @@ void TerrainORMMapFeatHLSL::processPix(Vector<ShaderComponent*> &componentList,
|
||||||
else
|
else
|
||||||
texOp = new GenOp("@.Sample(@, float3(@.xy, @.x))", ormMapArray, ormMapSampler, inDet, new IndexOp(detailInfo, compositeIndex));
|
texOp = new GenOp("@.Sample(@, float3(@.xy, @.x))", ormMapArray, ormMapSampler, inDet, new IndexOp(detailInfo, compositeIndex));
|
||||||
|
|
||||||
|
MultiLine* meta = new MultiLine;
|
||||||
// search for material var
|
// search for material var
|
||||||
Var * ormConfig;
|
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));
|
||||||
ormConfig = (Var*)LangElement::find(getOutputTargetVarName(targ));
|
|
||||||
|
|
||||||
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 = (Var*)LangElement::find("ORMConfig");
|
||||||
ormConfig = new Var;
|
if (!ormConfig)
|
||||||
ormConfig->setType("fragout");
|
{
|
||||||
ormConfig->setName(getOutputTargetVarName(targ));
|
ormConfig = new Var("ORMConfig", "float4");
|
||||||
ormConfig->setStructName("OUT");
|
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));
|
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));
|
String matinfoName(String::ToString("matinfoCol%d", compositeIndex));
|
||||||
Var *matinfoCol = new Var(matinfoName, "float3");
|
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));
|
meta->addStatement(new GenOp(" @ = @.rgb;\r\n", new DecOp(matinfoCol), texOp));
|
||||||
|
|
||||||
if (fd.features.hasFeature(MFT_InvertRoughness, compositeIndex))
|
if (fd.features.hasFeature(MFT_InvertRoughness, compositeIndex))
|
||||||
|
|
@ -1313,39 +1318,39 @@ ShaderFeature::Resources TerrainORMMapFeatHLSL::getResources(const MaterialFeatu
|
||||||
return res;
|
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,
|
void TerrainBlankInfoMapFeatHLSL::processPix(Vector<ShaderComponent*> &componentList,
|
||||||
const MaterialFeatureData &fd)
|
const MaterialFeatureData &fd)
|
||||||
{
|
{
|
||||||
S32 compositeIndex = getProcessIndex();
|
S32 compositeIndex = getProcessIndex();
|
||||||
|
|
||||||
// search for material var
|
MultiLine * meta = new MultiLine; Var* ormConfig;
|
||||||
Var *material;
|
if ((fd.features[MFT_isDeferred]))
|
||||||
OutputTarget ormConfig = RenderTarget1;
|
|
||||||
if (fd.features[MFT_isDeferred])
|
|
||||||
{
|
{
|
||||||
ormConfig = RenderTarget2;
|
// Set base ORM info
|
||||||
}
|
ormConfig = (Var*)LangElement::find(getOutputTargetVarName(RenderTarget2));
|
||||||
material = (Var*)LangElement::find(getOutputTargetVarName(ormConfig));
|
|
||||||
|
|
||||||
MultiLine * meta = new MultiLine;
|
if (!ormConfig)
|
||||||
if (!material)
|
{
|
||||||
|
// create color var
|
||||||
|
ormConfig = new Var;
|
||||||
|
ormConfig->setType("fragout");
|
||||||
|
ormConfig->setName(getOutputTargetVarName(RenderTarget2));
|
||||||
|
ormConfig->setStructName("OUT");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
// create color var
|
ormConfig = (Var*)LangElement::find("ORMConfig");
|
||||||
material = new Var;
|
if (!ormConfig)
|
||||||
material->setType("fragout");
|
{
|
||||||
material->setName(getOutputTargetVarName(ormConfig));
|
ormConfig = new Var("ORMConfig", "float4");
|
||||||
material->setStructName("OUT");
|
meta->addStatement(new GenOp(" @;\r\n", new DecOp(ormConfig)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (compositeIndex == 0)
|
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));
|
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))
|
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;
|
output = meta;
|
||||||
|
|
|
||||||
|
|
@ -179,8 +179,6 @@ public:
|
||||||
|
|
||||||
virtual void processPix(Vector<ShaderComponent*> &componentList,
|
virtual void processPix(Vector<ShaderComponent*> &componentList,
|
||||||
const MaterialFeatureData &fd);
|
const MaterialFeatureData &fd);
|
||||||
|
|
||||||
virtual U32 getOutputTargets(const MaterialFeatureData &fd) const;
|
|
||||||
virtual String getName() { return "Blank Matinfo map"; }
|
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(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 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(DecalRoadBin) { bintype = "DecalRoad"; renderOrder = 0.8; processAddOrder = 0.8; } );
|
||||||
DiffuseRenderPassManager.addManager( new RenderMeshMgr(DecalBin) { bintype = "Decal"; renderOrder = 0.81; processAddOrder = 0.81; basicOnly = true;} );
|
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; } );
|
DiffuseRenderPassManager.addManager( new RenderOcclusionMgr(OccluderBin){ bintype = "Occluder"; renderOrder = 0.9; processAddOrder = 0.9; } );
|
||||||
|
|
||||||
// Render the sky last
|
// Render the sky last
|
||||||
|
|
|
||||||
|
|
@ -291,8 +291,8 @@ void fizzle(vec2 vpos, float visibility)
|
||||||
// I'm sure there are many more patterns here to
|
// I'm sure there are many more patterns here to
|
||||||
// discover for different effects.
|
// discover for different effects.
|
||||||
|
|
||||||
mat2x2 m = mat2x2( vpos.x, vpos.y, 0.916, 0.350 );
|
mat2x2 m = mat2x2( vpos.x, 0.916, vpos.y, 0.350 );
|
||||||
if( (visibility - fract( determinant( m ) )) < 0 ) //if(a < 0) discard;
|
if( (visibility - fract( determinant( m ) )) < 0 )
|
||||||
discard;
|
discard;
|
||||||
}
|
}
|
||||||
#endif //TORQUE_PIXEL_SHADER
|
#endif //TORQUE_PIXEL_SHADER
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue