mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-11 22:54:34 +00:00
commit
908be4818f
112 changed files with 2645 additions and 680 deletions
|
|
@ -56,7 +56,7 @@ void AccuTexFeatGLSL::processPix(Vector<ShaderComponent*> &componentList,
|
|||
output = meta;
|
||||
|
||||
// OUT.col
|
||||
Var *color = (Var*) LangElement::find( "col" );
|
||||
Var *color = (Var*) LangElement::find( "col1" );
|
||||
if (!color)
|
||||
{
|
||||
output = new GenOp(" //NULL COLOR!");
|
||||
|
|
@ -144,8 +144,6 @@ void AccuTexFeatGLSL::processPix(Vector<ShaderComponent*> &componentList,
|
|||
|
||||
// get the accu pixel color
|
||||
meta->addStatement( new GenOp( " @ = tex2D(@, @ * @);\r\n", colorAccuDecl, accuMap, inTex, accuScale ) );
|
||||
if (!fd.features[MFT_Imposter])
|
||||
meta->addStatement(new GenOp(" @ = toLinear(@);\r\n", accuColor, accuColor));
|
||||
|
||||
// scale up normals
|
||||
meta->addStatement( new GenOp( " @.xyz = @.xyz * 2.0 - 0.5;\r\n", bumpNorm, bumpNorm ) );
|
||||
|
|
|
|||
|
|
@ -156,10 +156,10 @@ LangElement *ShaderFeatureGLSL::expandNormalMap( LangElement *sampleNormalOp,
|
|||
}
|
||||
else
|
||||
{
|
||||
// DXT Swizzle trick
|
||||
meta->addStatement( new GenOp( " @ = float4( @.ag * 2.0 - 1.0, 0.0, 0.0 ); // DXTnm\r\n", normalDecl, sampleNormalOp ) );
|
||||
meta->addStatement( new GenOp( " @.z = sqrt( 1.0 - dot( @.xy, @.xy ) ); // DXTnm\r\n", normalVar, normalVar, normalVar ) );
|
||||
}
|
||||
// DXT Swizzle trick
|
||||
meta->addStatement( new GenOp( " @ = float4( @.ag * 2.0 - 1.0, 0.0, 0.0 ); // DXTnm\r\n", normalDecl, sampleNormalOp ) );
|
||||
meta->addStatement( new GenOp( " @.z = sqrt( 1.0 - dot( @.xy, @.xy ) ); // DXTnm\r\n", normalVar, normalVar, normalVar ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -365,7 +365,7 @@ Var* ShaderFeatureGLSL::getOutTexCoord( const char *name,
|
|||
|
||||
// Statement allows for casting of different types which
|
||||
// eliminates vector truncation problems.
|
||||
String statement = String::ToString( " @ = %s(tMul(@, @));\r\n", type );
|
||||
String statement = String::ToString( " @ = %s(tMul(@, @).xy);\r\n", type );
|
||||
meta->addStatement( new GenOp( statement , texCoord, texMat, inTex ) );
|
||||
}
|
||||
else
|
||||
|
|
@ -708,7 +708,7 @@ void ShaderFeatureGLSL::getWsPosition( Vector<ShaderComponent*> &componentList,
|
|||
|
||||
Var *objTrans = getObjTrans( componentList, useInstancing, meta );
|
||||
|
||||
meta->addStatement( new GenOp( " @ = tMul( @, float4( @.xyz, 1 ) ).xyz;\r\n",
|
||||
meta->addStatement( new GenOp( " @ = tMul( @, vec4( @.xyz, 1 ) ).xyz;\r\n",
|
||||
wsPosition, objTrans, inPosition ) );
|
||||
}
|
||||
|
||||
|
|
@ -813,7 +813,7 @@ Var* ShaderFeatureGLSL::addOutDetailTexCoord( Vector<ShaderComponent*> &compon
|
|||
texMat->constSortPos = cspPass;
|
||||
}
|
||||
|
||||
meta->addStatement( new GenOp( " @ = tMul(@, @) * @;\r\n", outTex, texMat, inTex, detScale ) );
|
||||
meta->addStatement( new GenOp( " @ = tMul(@, @).xy * @;\r\n", outTex, texMat, inTex, detScale ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -847,12 +847,22 @@ void DiffuseMapFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|||
output = meta;
|
||||
}
|
||||
|
||||
U32 DiffuseMapFeatGLSL::getOutputTargets(const MaterialFeatureData &fd) const
|
||||
{
|
||||
return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
void DiffuseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
{
|
||||
// grab connector texcoord register
|
||||
Var *inTex = getInTexCoord( "texCoord", "vec2", true, componentList );
|
||||
|
||||
//determine output target
|
||||
ShaderFeature::OutputTarget targ = ShaderFeature::DefaultTarget;
|
||||
if (fd.features[MFT_isDeferred])
|
||||
targ = ShaderFeature::RenderTarget1;
|
||||
|
||||
// create texture var
|
||||
Var *diffuseMap = new Var;
|
||||
diffuseMap->setType( "sampler2D" );
|
||||
|
|
@ -869,7 +879,6 @@ void DiffuseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
|
||||
MultiLine * meta = new MultiLine;
|
||||
output = meta;
|
||||
|
||||
if ( fd.features[MFT_CubeMap] )
|
||||
{
|
||||
meta->addStatement( new GenOp( " @ = tex2D(@, @);\r\n",
|
||||
|
|
@ -878,9 +887,8 @@ void DiffuseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
inTex ) );
|
||||
if (!fd.features[MFT_Imposter])
|
||||
meta->addStatement( new GenOp(" @ = toLinear(@);\r\n", diffColor, diffColor) );
|
||||
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( diffColor, Material::Mul ) ) );
|
||||
output = meta;
|
||||
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( diffColor, Material::Mul, NULL, targ) ) );
|
||||
}
|
||||
else if(fd.features[MFT_DiffuseMapAtlas])
|
||||
{
|
||||
|
|
@ -946,8 +954,8 @@ void DiffuseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
#ifdef DEBUG_ATLASED_UV_COORDS
|
||||
if(!fd.features[MFT_PrePassConditioner])
|
||||
{
|
||||
meta->addStatement(new GenOp(" @ = float4(@.xy, mipLod / @.w, 1.0);\r\n", new DecOp(diffColor), inTex, atParams));
|
||||
meta->addStatement(new GenOp(" @; return OUT;\r\n", assignColor(diffColor, Material::Mul)));
|
||||
meta->addStatement(new GenOp(" @ = vec4(@.xy, mipLod / @.w, 1.0);\r\n", new DecOp(diffColor), inTex, atParams));
|
||||
meta->addStatement(new GenOp(" @; return OUT;\r\n", assignColor(diffColor, Material::Mul, NULL, targ) ) );
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -961,20 +969,20 @@ void DiffuseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
}
|
||||
else
|
||||
{
|
||||
meta->addStatement(new GenOp( " @ = tex2D(@, @);\r\n",
|
||||
new DecOp(diffColor), diffuseMap, inTex));
|
||||
meta->addStatement(new GenOp( " @ = tex2D(@, @);\r\n",
|
||||
new DecOp(diffColor), diffuseMap, inTex));
|
||||
if (!fd.features[MFT_Imposter])
|
||||
meta->addStatement(new GenOp(" @ = toLinear(@);\r\n", diffColor, diffColor));
|
||||
}
|
||||
|
||||
meta->addStatement(new GenOp( " @;\r\n", assignColor(diffColor, Material::Mul)));
|
||||
meta->addStatement(new GenOp( " @;\r\n", assignColor(diffColor, Material::Mul, NULL, targ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
meta->addStatement(new GenOp("@ = tex2D(@, @);\r\n", colorDecl, diffuseMap, inTex));
|
||||
if (!fd.features[MFT_Imposter])
|
||||
meta->addStatement(new GenOp(" @ = toLinear(@);\r\n", diffColor, diffColor));
|
||||
meta->addStatement(new GenOp(" @;\r\n", assignColor(diffColor, Material::Mul)));
|
||||
meta->addStatement(new GenOp(" @;\r\n", assignColor(diffColor, Material::Mul, NULL, targ)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1089,6 +1097,11 @@ void OverlayTexFeatGLSL::setTexData( Material::StageData &stageDat,
|
|||
// Diffuse color
|
||||
//****************************************************************************
|
||||
|
||||
U32 DiffuseFeatureGLSL::getOutputTargets(const MaterialFeatureData &fd) const
|
||||
{
|
||||
return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
void DiffuseFeatureGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
{
|
||||
|
|
@ -1099,7 +1112,33 @@ void DiffuseFeatureGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
diffuseMaterialColor->constSortPos = cspPotentialPrimitive;
|
||||
|
||||
MultiLine* meta = new MultiLine;
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( diffuseMaterialColor, Material::Mul ) ) );
|
||||
Var *col = (Var*)LangElement::find("col");
|
||||
ShaderFeature::OutputTarget targ = ShaderFeature::DefaultTarget;
|
||||
if (fd.features[MFT_isDeferred])
|
||||
{
|
||||
targ = ShaderFeature::RenderTarget1;
|
||||
|
||||
col = (Var*)LangElement::find("col1");
|
||||
MultiLine * meta = new MultiLine;
|
||||
if (!col)
|
||||
{
|
||||
// create color var
|
||||
col = new Var;
|
||||
col->setType("vec4");
|
||||
col->setName(getOutputTargetVarName(targ));
|
||||
col->setStructName("OUT");
|
||||
meta->addStatement(new GenOp(" @ = vec4(1.0);\r\n", col));
|
||||
}
|
||||
}
|
||||
|
||||
Material::BlendOp op;
|
||||
|
||||
if (fd.features[MFT_DiffuseMap])
|
||||
op = Material::Mul;
|
||||
else
|
||||
op = Material::None;
|
||||
|
||||
meta->addStatement(new GenOp(" @;\r\n", assignColor(diffuseMaterialColor, op, NULL, targ)));
|
||||
output = meta;
|
||||
}
|
||||
|
||||
|
|
@ -1231,9 +1270,9 @@ void LightmapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
// Lightmap has already been included in the advanced light bin, so
|
||||
// no need to do any sampling or anything
|
||||
if(bPreProcessedLighting)
|
||||
statement = new GenOp( "float4(@, 1.0)", inColor );
|
||||
statement = new GenOp( "vec4(@, 1.0)", inColor );
|
||||
else
|
||||
statement = new GenOp( "tex2D(@, @) + float4(@.rgb, 0.0)", lightMap, inTex, inColor );
|
||||
statement = new GenOp( "tex2D(@, @) + vec4(@.rgb, 0.0)", lightMap, inTex, inColor );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1245,8 +1284,8 @@ void LightmapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
MultiLine *meta = new MultiLine;
|
||||
if( fd.features[MFT_LightbufferMRT] )
|
||||
{
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( statement, Material::None, NULL, ShaderFeature::RenderTarget1 ) ) );
|
||||
meta->addStatement( new GenOp( " @.a = 0.0001;\r\n", LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget1) ) ) );
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( statement, Material::None, NULL, ShaderFeature::RenderTarget3 ) ) );
|
||||
meta->addStatement( new GenOp( " @.a = 0.0001;\r\n", LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget3) ) ) );
|
||||
}
|
||||
else
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( statement, Material::Mul ) ) );
|
||||
|
|
@ -1278,7 +1317,7 @@ void LightmapFeatGLSL::setTexData( Material::StageData &stageDat,
|
|||
|
||||
U32 LightmapFeatGLSL::getOutputTargets( const MaterialFeatureData &fd ) const
|
||||
{
|
||||
return fd.features[MFT_LightbufferMRT] ? ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
||||
return fd.features[MFT_LightbufferMRT] ? ShaderFeature::RenderTarget3 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
//****************************************************************************
|
||||
|
|
@ -1372,8 +1411,8 @@ void TonemapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
// Assign to proper render target
|
||||
if( fd.features[MFT_LightbufferMRT] )
|
||||
{
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( toneMapColor, Material::None, NULL, ShaderFeature::RenderTarget1 ) ) );
|
||||
meta->addStatement( new GenOp( " @.a = 0.0001;\r\n", LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget1) ) ) );
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( toneMapColor, Material::None, NULL, ShaderFeature::RenderTarget3 ) ) );
|
||||
meta->addStatement( new GenOp( " @.a = 0.0001;\r\n", LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget3) ) ) );
|
||||
}
|
||||
else
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( toneMapColor, blendOp ) ) );
|
||||
|
|
@ -1406,7 +1445,7 @@ void TonemapFeatGLSL::setTexData( Material::StageData &stageDat,
|
|||
|
||||
U32 TonemapFeatGLSL::getOutputTargets( const MaterialFeatureData &fd ) const
|
||||
{
|
||||
return fd.features[MFT_LightbufferMRT] ? ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
||||
return fd.features[MFT_LightbufferMRT] ? ShaderFeature::RenderTarget3 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
//****************************************************************************
|
||||
|
|
@ -1512,17 +1551,17 @@ void VertLitGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
// the dynamic light buffer, and it already has the baked-vertex-color
|
||||
// included in it
|
||||
if(bPreProcessedLighting)
|
||||
outColor = new GenOp( "float4(@.rgb, 1.0)", rtLightingColor );
|
||||
outColor = new GenOp( "vec4(@.rgb, 1.0)", rtLightingColor );
|
||||
else
|
||||
outColor = new GenOp( "float4(@.rgb + @.rgb, 1.0)", rtLightingColor, outColor );
|
||||
outColor = new GenOp( "vec4(@.rgb + @.rgb, 1.0)", rtLightingColor, outColor );
|
||||
}
|
||||
}
|
||||
|
||||
// Output the color
|
||||
if ( fd.features[MFT_LightbufferMRT] )
|
||||
{
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( outColor, Material::None, NULL, ShaderFeature::RenderTarget1 ) ) );
|
||||
meta->addStatement( new GenOp( " @.a = 0.0001;\r\n", LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget1) ) ) );
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( outColor, Material::None, NULL, ShaderFeature::RenderTarget3 ) ) );
|
||||
meta->addStatement( new GenOp( " @.a = 0.0001;\r\n", LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget3) ) ) );
|
||||
}
|
||||
else
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( outColor, blendOp ) ) );
|
||||
|
|
@ -1532,7 +1571,7 @@ void VertLitGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
|
||||
U32 VertLitGLSL::getOutputTargets( const MaterialFeatureData &fd ) const
|
||||
{
|
||||
return fd.features[MFT_LightbufferMRT] ? ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
||||
return fd.features[MFT_LightbufferMRT] ? ShaderFeature::RenderTarget3 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
//****************************************************************************
|
||||
|
|
@ -1571,7 +1610,10 @@ void DetailFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
// and a simple multiplication with the detail map.
|
||||
|
||||
LangElement *statement = new GenOp( "( tex2D(@, @) * 2.0 ) - 1.0", detailMap, inTex );
|
||||
output = new GenOp( " @;\r\n", assignColor( statement, Material::Add ) );
|
||||
if ( fd.features[MFT_isDeferred])
|
||||
output = new GenOp( " @;\r\n", assignColor( statement, Material::Add, NULL, ShaderFeature::RenderTarget1 ) );
|
||||
else
|
||||
output = new GenOp( " @;\r\n", assignColor( statement, Material::Add ) );
|
||||
}
|
||||
|
||||
ShaderFeature::Resources DetailFeatGLSL::getResources( const MaterialFeatureData &fd )
|
||||
|
|
@ -1630,7 +1672,7 @@ void VertPositionGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|||
|
||||
Var *modelview = getModelView( componentList, fd.features[MFT_UseInstancing], meta );
|
||||
|
||||
meta->addStatement( new GenOp( " @ = tMul(@, float4(@.xyz,1));\r\n",
|
||||
meta->addStatement( new GenOp( " @ = tMul(@, vec4(@.xyz,1));\r\n",
|
||||
outPosition, modelview, inPosition ) );
|
||||
|
||||
output = meta;
|
||||
|
|
@ -1694,8 +1736,8 @@ void ReflectCubeFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|||
cubeNormal->setName( "cubeNormal" );
|
||||
cubeNormal->setType( "vec3" );
|
||||
LangElement *cubeNormDecl = new DecOp( cubeNormal );
|
||||
|
||||
meta->addStatement( new GenOp( " @ = ( tMul( (@), vec4(@, 0) ) ).xyz;\r\n",
|
||||
|
||||
meta->addStatement( new GenOp( " @ = ( tMul( (@), vec4(@, 0) ) ).xyz;\r\n",
|
||||
cubeNormDecl, cubeTrans, inNormal ) );
|
||||
|
||||
meta->addStatement( new GenOp( " @ = bool(length(@)) ? normalize(@) : @;\r\n",
|
||||
|
|
@ -1771,9 +1813,14 @@ void ReflectCubeFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
}
|
||||
else
|
||||
{
|
||||
glossColor = (Var*) LangElement::find( "diffuseColor" );
|
||||
if( !glossColor )
|
||||
glossColor = (Var*) LangElement::find( "bumpNormal" );
|
||||
if (fd.features[MFT_isDeferred])
|
||||
glossColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget1));
|
||||
if (!glossColor)
|
||||
glossColor = (Var*)LangElement::find("specularColor");
|
||||
if (!glossColor)
|
||||
glossColor = (Var*)LangElement::find("diffuseColor");
|
||||
if (!glossColor)
|
||||
glossColor = (Var*)LangElement::find("bumpNormal");
|
||||
}
|
||||
|
||||
// grab connector texcoord register
|
||||
|
|
@ -1786,7 +1833,7 @@ void ReflectCubeFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
|
||||
// create cubemap var
|
||||
Var *cubeMap = new Var;
|
||||
cubeMap->setType( "samplerCUBE" );
|
||||
cubeMap->setType( "samplerCube" );
|
||||
cubeMap->setName( "cubeMap" );
|
||||
cubeMap->uniform = true;
|
||||
cubeMap->sampler = true;
|
||||
|
|
@ -1800,14 +1847,36 @@ void ReflectCubeFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
if ( fd.materialFeatures[MFT_RTLighting] )
|
||||
attn =(Var*)LangElement::find("d_NL_Att");
|
||||
|
||||
LangElement *texCube = new GenOp( "texCUBE( @, @ )", cubeMap, reflectVec );
|
||||
LangElement *texCube = NULL;
|
||||
Var* matinfo = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
|
||||
//first try and grab the gbuffer
|
||||
if (fd.features[MFT_isDeferred] && matinfo)
|
||||
{
|
||||
|
||||
if (fd.features[MFT_DeferredSpecMap])
|
||||
texCube = new GenOp("textureLod( @, @, (@.a*5) )", cubeMap, reflectVec, matinfo);
|
||||
else
|
||||
texCube = new GenOp("textureLod( @, @, (@.a/4) )", cubeMap, reflectVec, matinfo);
|
||||
}
|
||||
else if(glossColor) //failing that, rtry and find color data
|
||||
texCube = new GenOp("textureLod( @, @, @.a*5)", cubeMap, reflectVec, glossColor);
|
||||
else
|
||||
texCube = new GenOp("texture( @, @)", cubeMap, reflectVec);
|
||||
|
||||
LangElement *lerpVal = NULL;
|
||||
Material::BlendOp blendOp = Material::LerpAlpha;
|
||||
|
||||
// Note that the lerpVal needs to be a float4 so that
|
||||
// it will work with the LerpAlpha blend.
|
||||
|
||||
if ( glossColor )
|
||||
|
||||
if (matinfo)
|
||||
{
|
||||
if (attn)
|
||||
lerpVal = new GenOp("@ * saturate( @ )", matinfo, attn);
|
||||
else
|
||||
lerpVal = new GenOp("@", matinfo);
|
||||
}
|
||||
else if ( glossColor )
|
||||
{
|
||||
if ( attn )
|
||||
lerpVal = new GenOp( "@ * saturate( @ )", glossColor, attn );
|
||||
|
|
@ -1821,8 +1890,16 @@ void ReflectCubeFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
else
|
||||
blendOp = Material::Mul;
|
||||
}
|
||||
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( texCube, blendOp, lerpVal ) ) );
|
||||
if (fd.features[MFT_isDeferred])
|
||||
{
|
||||
Var* targ = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget1));
|
||||
if (fd.features[MFT_DeferredSpecMap])
|
||||
meta->addStatement(new GenOp(" @.rgb = lerp( @.rgb, (@).rgb, (@.b));\r\n", targ, targ, texCube, lerpVal));
|
||||
else
|
||||
meta->addStatement(new GenOp(" @.rgb = lerp( @.rgb, (@).rgb, (@.b*128/5));\r\n", targ, targ, texCube, lerpVal));
|
||||
}
|
||||
else
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( texCube, blendOp, lerpVal ) ) );
|
||||
output = meta;
|
||||
}
|
||||
|
||||
|
|
@ -1967,7 +2044,7 @@ void RTLightingFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|||
Var *objTrans = getObjTrans( componentList, fd.features[MFT_UseInstancing], meta );
|
||||
|
||||
// Transform the normal to world space.
|
||||
meta->addStatement( new GenOp( " @ = tMul( @, float4( 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 );
|
||||
|
|
@ -2025,7 +2102,7 @@ void RTLightingFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
// feature (this is done for BL terrain lightmaps).
|
||||
LangElement *lightMask = LangElement::find( "lightMask" );
|
||||
if ( !lightMask )
|
||||
lightMask = new GenOp( "float4( 1, 1, 1, 1 )" );
|
||||
lightMask = new GenOp( "vec4( 1, 1, 1, 1 )" );
|
||||
|
||||
// Get all the light constants.
|
||||
Var *inLightPos = new Var( "inLightPos", "vec4" );
|
||||
|
|
@ -2080,7 +2157,7 @@ void RTLightingFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
rtShading, specular ) );
|
||||
|
||||
// Apply the lighting to the diffuse color.
|
||||
LangElement *lighting = new GenOp( "float4( @.rgb + @.rgb, 1 )", rtShading, ambient );
|
||||
LangElement *lighting = new GenOp( "vec4( @.rgb + @.rgb, 1 )", rtShading, ambient );
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( lighting, Material::Mul ) ) );
|
||||
output = meta;
|
||||
}
|
||||
|
|
@ -2351,7 +2428,9 @@ void AlphaTestGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
}
|
||||
|
||||
// If we don't have a color var then we cannot do an alpha test.
|
||||
Var *color = (Var*)LangElement::find( "col" );
|
||||
Var *color = (Var*)LangElement::find( "col1" );
|
||||
if ( !color )
|
||||
color = (Var*)LangElement::find("col");
|
||||
if ( !color )
|
||||
{
|
||||
output = NULL;
|
||||
|
|
@ -2718,3 +2797,16 @@ void ImposterVertFeatureGLSL::determineFeature( Material *material,
|
|||
outFeatureData->features.addFeature( MFT_ImposterVert );
|
||||
}
|
||||
|
||||
//****************************************************************************
|
||||
// Vertex position
|
||||
//****************************************************************************
|
||||
void DeferredSkyGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
{
|
||||
Var *outPosition = (Var*)LangElement::find( "gl_Position" );
|
||||
MultiLine *meta = new MultiLine;
|
||||
meta->addStatement( new GenOp( " @.w = @.z;\r\n", outPosition, outPosition ) );
|
||||
|
||||
output = meta;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -248,6 +248,8 @@ public:
|
|||
virtual void processPix( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd );
|
||||
|
||||
virtual U32 getOutputTargets(const MaterialFeatureData &fd) const;
|
||||
|
||||
virtual Material::BlendOp getBlendOp(){ return Material::LerpAlpha; }
|
||||
|
||||
virtual Resources getResources( const MaterialFeatureData &fd );
|
||||
|
|
@ -301,6 +303,8 @@ public:
|
|||
|
||||
virtual Material::BlendOp getBlendOp(){ return Material::None; }
|
||||
|
||||
virtual U32 getOutputTargets(const MaterialFeatureData &fd) const;
|
||||
|
||||
virtual String getName()
|
||||
{
|
||||
return "Diffuse Color";
|
||||
|
|
@ -656,4 +660,11 @@ public:
|
|||
};
|
||||
|
||||
|
||||
class DeferredSkyGLSL : public ShaderFeatureGLSL
|
||||
{
|
||||
public:
|
||||
virtual String getName() { return "Deferred Shading: Sky"; }
|
||||
virtual void processVert( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd );
|
||||
};
|
||||
#endif // _SHADERGEN_GLSL_SHADERFEATUREGLSL_H_
|
||||
|
|
|
|||
|
|
@ -30,8 +30,11 @@
|
|||
|
||||
class ShaderGenPrinterGLSL : public ShaderGenPrinter
|
||||
{
|
||||
bool extraRTs[3];
|
||||
|
||||
public:
|
||||
|
||||
ShaderGenPrinterGLSL() { for (int i = 0; i < 3; i++) extraRTs[i] = false; }
|
||||
|
||||
// ShaderGenPrinter
|
||||
virtual void printShaderHeader(Stream& stream);
|
||||
virtual void printMainComment(Stream& stream);
|
||||
|
|
|
|||
|
|
@ -34,6 +34,8 @@
|
|||
#include "core/module.h"
|
||||
#include "shaderGen/GLSL/accuFeatureGLSL.h"
|
||||
|
||||
// Deferred Shading
|
||||
#include "lighting/advanced/glsl/deferredShadingFeaturesGLSL.h"
|
||||
|
||||
static ShaderGen::ShaderGenInitDelegate sInitDelegate;
|
||||
|
||||
|
|
@ -66,8 +68,13 @@ void _initShaderGenGLSL( ShaderGen *shaderGen )
|
|||
FEATUREMGR->registerFeature( MFT_AccuMap, new AccuTexFeatGLSL );
|
||||
FEATUREMGR->registerFeature( MFT_GlossMap, new NamedFeatureGLSL( "Gloss Map" ) );
|
||||
FEATUREMGR->registerFeature( MFT_IsTranslucent, new NamedFeatureGLSL( "Translucent" ) );
|
||||
FEATUREMGR->registerFeature( MFT_IsTranslucentZWrite, new NamedFeatureGLSL( "Translucent ZWrite" ) );
|
||||
FEATUREMGR->registerFeature( MFT_Visibility, new VisibilityFeatGLSL );
|
||||
FEATUREMGR->registerFeature( MFT_Fog, new FogFeatGLSL );
|
||||
FEATUREMGR->registerFeature( MFT_LightbufferMRT, new NamedFeatureGLSL( "Lightbuffer MRT" ) );
|
||||
FEATUREMGR->registerFeature( MFT_RenderTarget1_Zero, new RenderTargetZeroGLSL( ShaderFeature::RenderTarget1 ) );
|
||||
FEATUREMGR->registerFeature( MFT_RenderTarget2_Zero, new RenderTargetZeroGLSL( ShaderFeature::RenderTarget2 ) );
|
||||
FEATUREMGR->registerFeature( MFT_RenderTarget3_Zero, new RenderTargetZeroGLSL( ShaderFeature::RenderTarget3 ) );
|
||||
FEATUREMGR->registerFeature( MFT_Imposter, new NamedFeatureGLSL( "Imposter" ) );
|
||||
|
||||
FEATUREMGR->registerFeature( MFT_NormalsOut, new NormalsOutFeatGLSL );
|
||||
|
|
@ -80,9 +87,6 @@ void _initShaderGenGLSL( ShaderGen *shaderGen )
|
|||
FEATUREMGR->registerFeature( MFT_ParaboloidVertTransform, new ParaboloidVertTransformGLSL );
|
||||
FEATUREMGR->registerFeature( MFT_IsSinglePassParaboloid, new NamedFeatureGLSL( "Single Pass Paraboloid" ) );
|
||||
FEATUREMGR->registerFeature( MFT_UseInstancing, new NamedFeatureGLSL( "Hardware Instancing" ) );
|
||||
|
||||
FEATUREMGR->registerFeature( MFT_RenderTarget1_Zero, new RenderTargetZeroGLSL
|
||||
( ShaderFeature::RenderTarget1 ) );
|
||||
|
||||
FEATUREMGR->registerFeature( MFT_DiffuseMapAtlas, new NamedFeatureGLSL( "Diffuse Map Atlas" ) );
|
||||
FEATUREMGR->registerFeature( MFT_NormalMapAtlas, new NamedFeatureGLSL( "Normal Map Atlas" ) );
|
||||
|
|
@ -94,10 +98,13 @@ void _initShaderGenGLSL( ShaderGen *shaderGen )
|
|||
|
||||
FEATUREMGR->registerFeature( MFT_ImposterVert, new ImposterVertFeatureGLSL );
|
||||
|
||||
FEATUREMGR->registerFeature( MFT_LightbufferMRT, new NamedFeatureGLSL( "Lightbuffer MRT" ) );
|
||||
//FEATUREMGR->registerFeature( MFT_IsTranslucentZWrite, new NamedFeatureGLSL( "Translucent ZWrite" ) );
|
||||
//FEATUREMGR->registerFeature( MFT_InterlacedPrePass, new NamedFeatureGLSL( "Interlaced Pre Pass" ) );
|
||||
|
||||
// Deferred Shading
|
||||
FEATUREMGR->registerFeature( MFT_isDeferred, new NamedFeatureGLSL( "Deferred Material" ) );
|
||||
FEATUREMGR->registerFeature( MFT_DeferredSpecMap, new DeferredSpecMapGLSL );
|
||||
FEATUREMGR->registerFeature( MFT_DeferredSpecVars, new DeferredSpecVarsGLSL );
|
||||
FEATUREMGR->registerFeature( MFT_DeferredMatInfoFlags, new DeferredMatInfoFlagsGLSL );
|
||||
FEATUREMGR->registerFeature( MFT_DeferredEmptySpec, new DeferredEmptySpecGLSL );
|
||||
FEATUREMGR->registerFeature( MFT_SkyBox, new DeferredSkyGLSL );
|
||||
}
|
||||
|
||||
MODULE_BEGIN( ShaderGenGLSL )
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ void AccuTexFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
output = meta;
|
||||
|
||||
// OUT.col
|
||||
Var *color = (Var*) LangElement::find( "col" );
|
||||
Var *color = (Var*) LangElement::find( "col1" );
|
||||
if (!color)
|
||||
{
|
||||
output = new GenOp(" //NULL COLOR!");
|
||||
|
|
@ -141,8 +141,6 @@ void AccuTexFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
|
||||
// get the accu pixel color
|
||||
meta->addStatement( new GenOp( " @ = tex2D(@, @ * @);\r\n", colorAccuDecl, accuMap, inTex, accuScale ) );
|
||||
if (!fd.features[MFT_Imposter])
|
||||
meta->addStatement(new GenOp(" @ = toLinear(@);\r\n", accuColor, accuColor));
|
||||
|
||||
// scale up normals
|
||||
meta->addStatement( new GenOp( " @.xyz = @.xyz * 2.0 - 0.5;\r\n", bumpNorm, bumpNorm ) );
|
||||
|
|
|
|||
|
|
@ -365,7 +365,7 @@ Var* ShaderFeatureHLSL::getOutTexCoord( const char *name,
|
|||
|
||||
// Statement allows for casting of different types which
|
||||
// eliminates vector truncation problems.
|
||||
String statement = String::ToString( " @ = (%s)mul(@, @);\r\n", type );
|
||||
String statement = String::ToString( " @ = (%s)mul(@, @).xy;\r\n", type );
|
||||
meta->addStatement( new GenOp( statement, texCoord, texMat, inTex ) );
|
||||
}
|
||||
else
|
||||
|
|
@ -811,7 +811,7 @@ Var* ShaderFeatureHLSL::addOutDetailTexCoord( Vector<ShaderComponent*> &compon
|
|||
texMat->constSortPos = cspPass;
|
||||
}
|
||||
|
||||
meta->addStatement( new GenOp( " @ = mul(@, @) * @;\r\n", outTex, texMat, inTex, detScale ) );
|
||||
meta->addStatement( new GenOp( " @ = mul(@, @).xy * @;\r\n", outTex, texMat, inTex, detScale ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -845,12 +845,22 @@ void DiffuseMapFeatHLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|||
output = meta;
|
||||
}
|
||||
|
||||
U32 DiffuseMapFeatHLSL::getOutputTargets(const MaterialFeatureData &fd) const
|
||||
{
|
||||
return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
void DiffuseMapFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
{
|
||||
// grab connector texcoord register
|
||||
Var *inTex = getInTexCoord( "texCoord", "float2", true, componentList );
|
||||
|
||||
//determine output target
|
||||
ShaderFeature::OutputTarget targ = ShaderFeature::DefaultTarget;
|
||||
if (fd.features[MFT_isDeferred])
|
||||
targ = ShaderFeature::RenderTarget1;
|
||||
|
||||
// create texture var
|
||||
Var *diffuseMap = new Var;
|
||||
diffuseMap->setType( "sampler2D" );
|
||||
|
|
@ -877,7 +887,7 @@ void DiffuseMapFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
if (!fd.features[MFT_Imposter])
|
||||
meta->addStatement(new GenOp(" @ = toLinear(@);\r\n", diffColor, diffColor));
|
||||
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( diffColor, Material::Mul ) ) );
|
||||
meta->addStatement(new GenOp(" @;\r\n", assignColor(diffColor, Material::Mul, NULL, targ)));
|
||||
}
|
||||
else if(fd.features[MFT_DiffuseMapAtlas])
|
||||
{
|
||||
|
|
@ -944,7 +954,7 @@ void DiffuseMapFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
if(!fd.features[MFT_PrePassConditioner])
|
||||
{
|
||||
meta->addStatement(new GenOp(" @ = float4(@.xy, mipLod / @.w, 1.0);\r\n", new DecOp(diffColor), inTex, atParams));
|
||||
meta->addStatement(new GenOp(" @; return OUT;\r\n", assignColor(diffColor, Material::Mul)));
|
||||
meta->addStatement(new GenOp(" @; return OUT;\r\n", assignColor(diffColor, Material::Mul, NULL, targ) ) );
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -962,15 +972,15 @@ void DiffuseMapFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
if (!fd.features[MFT_Imposter])
|
||||
meta->addStatement(new GenOp(" @ = toLinear(@);\r\n", diffColor, diffColor));
|
||||
|
||||
meta->addStatement(new GenOp( " @;\r\n", assignColor(diffColor, Material::Mul)));
|
||||
meta->addStatement(new GenOp(" @;\r\n", assignColor(diffColor, Material::Mul, NULL, targ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
meta->addStatement(new GenOp("@ = tex2D(@, @);\r\n", colorDecl, diffuseMap, inTex));
|
||||
if (!fd.features[MFT_Imposter])
|
||||
meta->addStatement(new GenOp(" @ = toLinear(@);\r\n", diffColor, diffColor));
|
||||
meta->addStatement(new GenOp(" @;\r\n", assignColor(diffColor, Material::Mul)));
|
||||
}
|
||||
meta->addStatement(new GenOp(" @;\r\n", assignColor(diffColor, Material::Mul, NULL, targ)));
|
||||
}
|
||||
}
|
||||
|
||||
ShaderFeature::Resources DiffuseMapFeatHLSL::getResources( const MaterialFeatureData &fd )
|
||||
|
|
@ -1087,6 +1097,11 @@ void OverlayTexFeatHLSL::setTexData( Material::StageData &stageDat,
|
|||
// Diffuse color
|
||||
//****************************************************************************
|
||||
|
||||
U32 DiffuseFeatureHLSL::getOutputTargets(const MaterialFeatureData &fd) const
|
||||
{
|
||||
return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
void DiffuseFeatureHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
{
|
||||
|
|
@ -1096,8 +1111,34 @@ void DiffuseFeatureHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
diffuseMaterialColor->uniform = true;
|
||||
diffuseMaterialColor->constSortPos = cspPotentialPrimitive;
|
||||
|
||||
MultiLine * meta = new MultiLine;
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( diffuseMaterialColor, Material::Mul ) ) );
|
||||
MultiLine* meta = new MultiLine;
|
||||
Var *col = (Var*)LangElement::find("col");
|
||||
ShaderFeature::OutputTarget targ = ShaderFeature::DefaultTarget;
|
||||
if (fd.features[MFT_isDeferred])
|
||||
{
|
||||
targ = ShaderFeature::RenderTarget1;
|
||||
|
||||
col = (Var*)LangElement::find("col1");
|
||||
MultiLine * meta = new MultiLine;
|
||||
if (!col)
|
||||
{
|
||||
// create color var
|
||||
col = new Var;
|
||||
col->setType("fragout");
|
||||
col->setName(getOutputTargetVarName(targ));
|
||||
col->setStructName("OUT");
|
||||
meta->addStatement(new GenOp(" @ = float4(1.0);\r\n", col));
|
||||
}
|
||||
}
|
||||
|
||||
Material::BlendOp op;
|
||||
|
||||
if (fd.features[MFT_DiffuseMap])
|
||||
op = Material::Mul;
|
||||
else
|
||||
op = Material::None;
|
||||
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( diffuseMaterialColor, op, NULL, targ ) ) );
|
||||
output = meta;
|
||||
}
|
||||
|
||||
|
|
@ -1243,8 +1284,8 @@ void LightmapFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
MultiLine *meta = new MultiLine;
|
||||
if( fd.features[MFT_LightbufferMRT] )
|
||||
{
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( statement, Material::None, NULL, ShaderFeature::RenderTarget1 ) ) );
|
||||
meta->addStatement( new GenOp( " @.a = 0.0001;\r\n", LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget1) ) ) );
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( statement, Material::None, NULL, ShaderFeature::RenderTarget3 ) ) );
|
||||
meta->addStatement( new GenOp( " @.a = 0.0001;\r\n", LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget3) ) ) );
|
||||
}
|
||||
else
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( statement, Material::Mul ) ) );
|
||||
|
|
@ -1276,7 +1317,7 @@ void LightmapFeatHLSL::setTexData( Material::StageData &stageDat,
|
|||
|
||||
U32 LightmapFeatHLSL::getOutputTargets( const MaterialFeatureData &fd ) const
|
||||
{
|
||||
return fd.features[MFT_LightbufferMRT] ? ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
||||
return fd.features[MFT_LightbufferMRT] ? ShaderFeature::RenderTarget3 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
//****************************************************************************
|
||||
|
|
@ -1370,8 +1411,8 @@ void TonemapFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
// Assign to proper render target
|
||||
if( fd.features[MFT_LightbufferMRT] )
|
||||
{
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( toneMapColor, Material::None, NULL, ShaderFeature::RenderTarget1 ) ) );
|
||||
meta->addStatement( new GenOp( " @.a = 0.0001;\r\n", LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget1) ) ) );
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( toneMapColor, Material::None, NULL, ShaderFeature::RenderTarget3 ) ) );
|
||||
meta->addStatement( new GenOp( " @.a = 0.0001;\r\n", LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget3) ) ) );
|
||||
}
|
||||
else
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( toneMapColor, blendOp ) ) );
|
||||
|
|
@ -1404,7 +1445,7 @@ void TonemapFeatHLSL::setTexData( Material::StageData &stageDat,
|
|||
|
||||
U32 TonemapFeatHLSL::getOutputTargets( const MaterialFeatureData &fd ) const
|
||||
{
|
||||
return fd.features[MFT_LightbufferMRT] ? ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
||||
return fd.features[MFT_LightbufferMRT] ? ShaderFeature::RenderTarget3 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
//****************************************************************************
|
||||
|
|
@ -1519,8 +1560,8 @@ void VertLitHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
// Output the color
|
||||
if ( fd.features[MFT_LightbufferMRT] )
|
||||
{
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( outColor, Material::None, NULL, ShaderFeature::RenderTarget1 ) ) );
|
||||
meta->addStatement( new GenOp( " @.a = 0.0001;\r\n", LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget1) ) ) );
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( outColor, Material::None, NULL, ShaderFeature::RenderTarget3 ) ) );
|
||||
meta->addStatement( new GenOp( " @.a = 0.0001;\r\n", LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget3) ) ) );
|
||||
}
|
||||
else
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( outColor, blendOp ) ) );
|
||||
|
|
@ -1530,7 +1571,7 @@ void VertLitHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
|
||||
U32 VertLitHLSL::getOutputTargets( const MaterialFeatureData &fd ) const
|
||||
{
|
||||
return fd.features[MFT_LightbufferMRT] ? ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
||||
return fd.features[MFT_LightbufferMRT] ? ShaderFeature::RenderTarget3 : ShaderFeature::DefaultTarget;
|
||||
}
|
||||
|
||||
//****************************************************************************
|
||||
|
|
@ -1569,7 +1610,10 @@ void DetailFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
// and a simple multiplication with the detail map.
|
||||
|
||||
LangElement *statement = new GenOp( "( tex2D(@, @) * 2.0 ) - 1.0", detailMap, inTex );
|
||||
output = new GenOp( " @;\r\n", assignColor( statement, Material::Add ) );
|
||||
if ( fd.features[MFT_isDeferred])
|
||||
output = new GenOp( " @;\r\n", assignColor( statement, Material::Add, NULL, ShaderFeature::RenderTarget1 ) );
|
||||
else
|
||||
output = new GenOp( " @;\r\n", assignColor( statement, Material::Add ) );
|
||||
}
|
||||
|
||||
ShaderFeature::Resources DetailFeatHLSL::getResources( const MaterialFeatureData &fd )
|
||||
|
|
@ -1694,7 +1738,7 @@ void ReflectCubeFeatHLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|||
cubeNormal->setType( "float3" );
|
||||
LangElement *cubeNormDecl = new DecOp( cubeNormal );
|
||||
|
||||
meta->addStatement( new GenOp( " @ = normalize( mul(@, float4(normalize(@),0.0)).xyz );\r\n",
|
||||
meta->addStatement( new GenOp( " @ = normalize( mul(@, float4(normalize(@),0.0)).xyz );\r\n",
|
||||
cubeNormDecl, cubeTrans, inNormal ) );
|
||||
|
||||
// grab the eye position
|
||||
|
|
@ -1767,9 +1811,14 @@ void ReflectCubeFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
}
|
||||
else
|
||||
{
|
||||
glossColor = (Var*) LangElement::find( "diffuseColor" );
|
||||
if( !glossColor )
|
||||
glossColor = (Var*) LangElement::find( "bumpNormal" );
|
||||
if (fd.features[MFT_isDeferred])
|
||||
glossColor = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget1));
|
||||
if (!glossColor)
|
||||
glossColor = (Var*)LangElement::find("specularColor");
|
||||
if (!glossColor)
|
||||
glossColor = (Var*)LangElement::find("diffuseColor");
|
||||
if (!glossColor)
|
||||
glossColor = (Var*)LangElement::find("bumpNormal");
|
||||
}
|
||||
|
||||
// grab connector texcoord register
|
||||
|
|
@ -1795,15 +1844,41 @@ void ReflectCubeFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
//else
|
||||
if ( fd.materialFeatures[MFT_RTLighting] )
|
||||
attn =(Var*)LangElement::find("d_NL_Att");
|
||||
|
||||
LangElement *texCube = NULL;
|
||||
Var* matinfo = (Var*) LangElement::find( getOutputTargetVarName(ShaderFeature::RenderTarget2) );
|
||||
//first try and grab the gbuffer
|
||||
if (fd.features[MFT_isDeferred] && matinfo)
|
||||
{
|
||||
// Cube LOD level = (1.0 - Roughness) * 8
|
||||
// mip_levle = min((1.0 - u_glossiness)*11.0 + 1.0, 8.0)
|
||||
//LangElement *texCube = new GenOp( "texCUBElod( @, float4(@, min((1.0 - (@ / 128.0)) * 11.0 + 1.0, 8.0)) )", cubeMap, reflectVec, specPower );
|
||||
|
||||
if (fd.features[MFT_DeferredSpecMap])
|
||||
texCube = new GenOp("texCUBElod( @, float4(@, (@.a*5)) )", cubeMap, reflectVec, matinfo);
|
||||
else
|
||||
texCube = new GenOp("texCUBElod( @, float4(@, (@.a/4)) )", cubeMap, reflectVec, matinfo);
|
||||
}
|
||||
else
|
||||
if (glossColor) //failing that, rtry and find color data
|
||||
texCube = new GenOp("texCUBElod( @, float4(@, @.a*5))", cubeMap, reflectVec, glossColor);
|
||||
else //failing *that*, just draw the cubemap
|
||||
texCube = new GenOp("texCUBE( @, @)", cubeMap, reflectVec);
|
||||
|
||||
LangElement *texCube = new GenOp( "texCUBE( @, @ )", cubeMap, reflectVec );
|
||||
LangElement *lerpVal = NULL;
|
||||
Material::BlendOp blendOp = Material::LerpAlpha;
|
||||
|
||||
// Note that the lerpVal needs to be a float4 so that
|
||||
// it will work with the LerpAlpha blend.
|
||||
|
||||
if ( glossColor )
|
||||
if (matinfo)
|
||||
{
|
||||
if (attn)
|
||||
lerpVal = new GenOp("@ * saturate( @ )", matinfo, attn);
|
||||
else
|
||||
lerpVal = new GenOp("@", matinfo);
|
||||
}
|
||||
else if ( glossColor )
|
||||
{
|
||||
if ( attn )
|
||||
lerpVal = new GenOp( "@ * saturate( @ )", glossColor, attn );
|
||||
|
|
@ -1817,8 +1892,16 @@ void ReflectCubeFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
else
|
||||
blendOp = Material::Mul;
|
||||
}
|
||||
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( texCube, blendOp, lerpVal ) ) );
|
||||
if (fd.features[MFT_isDeferred])
|
||||
{
|
||||
Var* targ = (Var*)LangElement::find(getOutputTargetVarName(ShaderFeature::RenderTarget1));
|
||||
if (fd.features[MFT_DeferredSpecMap])
|
||||
meta->addStatement(new GenOp(" @.rgb = lerp( @.rgb, (@).rgb, (@.b));\r\n", targ, targ, texCube, lerpVal));
|
||||
else
|
||||
meta->addStatement(new GenOp(" @.rgb = lerp( @.rgb, (@).rgb, (@.b*128/5));\r\n", targ, targ, texCube, lerpVal));
|
||||
}
|
||||
else
|
||||
meta->addStatement( new GenOp( " @;\r\n", assignColor( texCube, blendOp, lerpVal ) ) );
|
||||
output = meta;
|
||||
}
|
||||
|
||||
|
|
@ -1865,9 +1948,9 @@ void ReflectCubeFeatHLSL::setTexData( Material::StageData &stageDat,
|
|||
{
|
||||
passData.mSamplerNames[ texIndex ] = "bumpMap";
|
||||
passData.mTexSlot[ texIndex++ ].texObject = tex;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( stageDat.getCubemap() )
|
||||
{
|
||||
|
|
@ -2347,7 +2430,9 @@ void AlphaTestHLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|||
}
|
||||
|
||||
// If we don't have a color var then we cannot do an alpha test.
|
||||
Var *color = (Var*)LangElement::find( "col" );
|
||||
Var *color = (Var*)LangElement::find( "col1" );
|
||||
if (!color)
|
||||
color = (Var*)LangElement::find("col");
|
||||
if ( !color )
|
||||
{
|
||||
output = NULL;
|
||||
|
|
@ -2714,3 +2799,16 @@ void ImposterVertFeatureHLSL::determineFeature( Material *material,
|
|||
outFeatureData->features.addFeature( MFT_ImposterVert );
|
||||
}
|
||||
|
||||
|
||||
//****************************************************************************
|
||||
// Vertex position
|
||||
//****************************************************************************
|
||||
void DeferredSkyHLSL::processVert( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd )
|
||||
{
|
||||
Var *outPosition = (Var*)LangElement::find( "hpos" );
|
||||
MultiLine *meta = new MultiLine;
|
||||
meta->addStatement( new GenOp( " @.w = @.z;\r\n", outPosition, outPosition ) );
|
||||
|
||||
output = meta;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -248,6 +248,8 @@ public:
|
|||
virtual void processPix( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd );
|
||||
|
||||
virtual U32 getOutputTargets(const MaterialFeatureData &fd) const;
|
||||
|
||||
virtual Material::BlendOp getBlendOp(){ return Material::LerpAlpha; }
|
||||
|
||||
virtual Resources getResources( const MaterialFeatureData &fd );
|
||||
|
|
@ -301,6 +303,7 @@ public:
|
|||
|
||||
virtual Material::BlendOp getBlendOp(){ return Material::None; }
|
||||
|
||||
virtual U32 getOutputTargets(const MaterialFeatureData &fd) const;
|
||||
virtual String getName()
|
||||
{
|
||||
return "Diffuse Color";
|
||||
|
|
@ -656,4 +659,12 @@ public:
|
|||
};
|
||||
|
||||
|
||||
class DeferredSkyHLSL : public ShaderFeatureHLSL
|
||||
{
|
||||
public:
|
||||
virtual String getName() { return "Deferred Shading: Sky"; }
|
||||
virtual void processVert( Vector<ShaderComponent*> &componentList,
|
||||
const MaterialFeatureData &fd );
|
||||
};
|
||||
|
||||
#endif // _SHADERGEN_HLSL_SHADERFEATUREHLSL_H_
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@
|
|||
#include "shaderGen/HLSL/paraboloidHLSL.h"
|
||||
#include "materials/materialFeatureTypes.h"
|
||||
#include "core/module.h"
|
||||
// Deferred Shading
|
||||
#include "lighting/advanced/hlsl/deferredShadingFeaturesHLSL.h"
|
||||
#include "shaderGen/HLSL/accuFeatureHLSL.h"
|
||||
|
||||
static ShaderGen::ShaderGenInitDelegate sInitDelegate;
|
||||
|
|
@ -70,6 +72,8 @@ void _initShaderGenHLSL( ShaderGen *shaderGen )
|
|||
FEATUREMGR->registerFeature( MFT_GlossMap, new NamedFeatureHLSL( "Gloss Map" ) );
|
||||
FEATUREMGR->registerFeature( MFT_LightbufferMRT, new NamedFeatureHLSL( "Lightbuffer MRT" ) );
|
||||
FEATUREMGR->registerFeature( MFT_RenderTarget1_Zero, new RenderTargetZeroHLSL( ShaderFeature::RenderTarget1 ) );
|
||||
FEATUREMGR->registerFeature( MFT_RenderTarget2_Zero, new RenderTargetZeroHLSL( ShaderFeature::RenderTarget2 ) );
|
||||
FEATUREMGR->registerFeature( MFT_RenderTarget3_Zero, new RenderTargetZeroHLSL( ShaderFeature::RenderTarget3 ) );
|
||||
FEATUREMGR->registerFeature( MFT_Imposter, new NamedFeatureHLSL( "Imposter" ) );
|
||||
|
||||
FEATUREMGR->registerFeature( MFT_DiffuseMapAtlas, new NamedFeatureHLSL( "Diffuse Map Atlas" ) );
|
||||
|
|
@ -95,6 +99,14 @@ void _initShaderGenHLSL( ShaderGen *shaderGen )
|
|||
FEATUREMGR->registerFeature( MFT_ForwardShading, new NamedFeatureHLSL( "Forward Shaded Material" ) );
|
||||
|
||||
FEATUREMGR->registerFeature( MFT_ImposterVert, new ImposterVertFeatureHLSL );
|
||||
|
||||
// Deferred Shading
|
||||
FEATUREMGR->registerFeature( MFT_isDeferred, new NamedFeatureHLSL( "Deferred Material" ) );
|
||||
FEATUREMGR->registerFeature( MFT_DeferredSpecMap, new DeferredSpecMapHLSL );
|
||||
FEATUREMGR->registerFeature( MFT_DeferredSpecVars, new DeferredSpecVarsHLSL );
|
||||
FEATUREMGR->registerFeature( MFT_DeferredMatInfoFlags, new DeferredMatInfoFlagsHLSL );
|
||||
FEATUREMGR->registerFeature( MFT_DeferredEmptySpec, new DeferredEmptySpecHLSL );
|
||||
FEATUREMGR->registerFeature( MFT_SkyBox, new DeferredSkyHLSL );
|
||||
}
|
||||
|
||||
MODULE_BEGIN( ShaderGenHLSL )
|
||||
|
|
|
|||
|
|
@ -47,10 +47,24 @@ ShaderFeature::Resources ShaderFeature::getResources( const MaterialFeatureData
|
|||
const char* ShaderFeature::getOutputTargetVarName( OutputTarget target ) const
|
||||
{
|
||||
const char* targName = "col";
|
||||
if ( target != DefaultTarget )
|
||||
|
||||
switch(target)
|
||||
{
|
||||
case DefaultTarget:
|
||||
targName = "col";
|
||||
break;
|
||||
|
||||
case RenderTarget1:
|
||||
targName = "col1";
|
||||
AssertFatal(target == RenderTarget1, "yeah Pat is lame and didn't want to do bit math stuff, TODO");
|
||||
break;
|
||||
|
||||
case RenderTarget2:
|
||||
targName = "col2";
|
||||
break;
|
||||
|
||||
case RenderTarget3:
|
||||
targName = "col3";
|
||||
break;
|
||||
}
|
||||
|
||||
return targName;
|
||||
|
|
|
|||
|
|
@ -80,4 +80,7 @@ const String ShaderGenVars::cubeMap("$cubeMap");
|
|||
const String ShaderGenVars::dLightMap("$dlightMap");
|
||||
const String ShaderGenVars::dLightMapSec("$dlightMapSec");
|
||||
const String ShaderGenVars::dLightMask("$dlightMask");
|
||||
const String ShaderGenVars::toneMap("$toneMap");
|
||||
const String ShaderGenVars::toneMap("$toneMap");
|
||||
|
||||
// Deferred shading
|
||||
const String ShaderGenVars::matInfoFlags("$matInfoFlags");
|
||||
|
|
@ -94,6 +94,9 @@ struct ShaderGenVars
|
|||
const static String dLightMapSec;
|
||||
const static String dLightMask;
|
||||
const static String toneMap;
|
||||
|
||||
// Deferred Shading
|
||||
const static String matInfoFlags;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue