|
@@ -156,10 +156,10 @@ LangElement *ShaderFeatureGLSL::expandNormalMap( LangElement *sampleNormalOp,
|
|
}
|
|
}
|
|
else
|
|
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
|
|
else
|
|
{
|
|
{
|
|
@@ -708,7 +708,7 @@ void ShaderFeatureGLSL::getWsPosition( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
|
Var *objTrans = getObjTrans( componentList, useInstancing, meta );
|
|
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 ) );
|
|
wsPosition, objTrans, inPosition ) );
|
|
}
|
|
}
|
|
|
|
|
|
@@ -847,12 +847,22 @@ void DiffuseMapFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|
output = meta;
|
|
output = meta;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+U32 DiffuseMapFeatGLSL::getOutputTargets(const MaterialFeatureData &fd) const
|
|
|
|
+{
|
|
|
|
+ return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
|
|
|
+}
|
|
|
|
+
|
|
void DiffuseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|
void DiffuseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|
const MaterialFeatureData &fd )
|
|
const MaterialFeatureData &fd )
|
|
{
|
|
{
|
|
// grab connector texcoord register
|
|
// grab connector texcoord register
|
|
Var *inTex = getInTexCoord( "texCoord", "vec2", true, componentList );
|
|
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
|
|
// create texture var
|
|
Var *diffuseMap = new Var;
|
|
Var *diffuseMap = new Var;
|
|
diffuseMap->setType( "sampler2D" );
|
|
diffuseMap->setType( "sampler2D" );
|
|
@@ -869,7 +879,6 @@ void DiffuseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
|
MultiLine * meta = new MultiLine;
|
|
MultiLine * meta = new MultiLine;
|
|
output = meta;
|
|
output = meta;
|
|
-
|
|
|
|
if ( fd.features[MFT_CubeMap] )
|
|
if ( fd.features[MFT_CubeMap] )
|
|
{
|
|
{
|
|
meta->addStatement( new GenOp( " @ = tex2D(@, @);\r\n",
|
|
meta->addStatement( new GenOp( " @ = tex2D(@, @);\r\n",
|
|
@@ -878,9 +887,8 @@ void DiffuseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|
inTex ) );
|
|
inTex ) );
|
|
if (!fd.features[MFT_Imposter])
|
|
if (!fd.features[MFT_Imposter])
|
|
meta->addStatement( new GenOp(" @ = toLinear(@);\r\n", diffColor, diffColor) );
|
|
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])
|
|
else if(fd.features[MFT_DiffuseMapAtlas])
|
|
{
|
|
{
|
|
@@ -946,8 +954,8 @@ void DiffuseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|
#ifdef DEBUG_ATLASED_UV_COORDS
|
|
#ifdef DEBUG_ATLASED_UV_COORDS
|
|
if(!fd.features[MFT_PrePassConditioner])
|
|
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;
|
|
return;
|
|
}
|
|
}
|
|
#endif
|
|
#endif
|
|
@@ -961,20 +969,20 @@ void DiffuseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|
}
|
|
}
|
|
else
|
|
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])
|
|
if (!fd.features[MFT_Imposter])
|
|
meta->addStatement(new GenOp(" @ = toLinear(@);\r\n", diffColor, diffColor));
|
|
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
|
|
else
|
|
{
|
|
{
|
|
meta->addStatement(new GenOp("@ = tex2D(@, @);\r\n", colorDecl, diffuseMap, inTex));
|
|
meta->addStatement(new GenOp("@ = tex2D(@, @);\r\n", colorDecl, diffuseMap, inTex));
|
|
if (!fd.features[MFT_Imposter])
|
|
if (!fd.features[MFT_Imposter])
|
|
meta->addStatement(new GenOp(" @ = toLinear(@);\r\n", diffColor, diffColor));
|
|
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
|
|
// Diffuse color
|
|
//****************************************************************************
|
|
//****************************************************************************
|
|
|
|
|
|
|
|
+U32 DiffuseFeatureGLSL::getOutputTargets(const MaterialFeatureData &fd) const
|
|
|
|
+{
|
|
|
|
+ return fd.features[MFT_isDeferred] ? ShaderFeature::RenderTarget1 : ShaderFeature::DefaultTarget;
|
|
|
|
+}
|
|
|
|
+
|
|
void DiffuseFeatureGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|
void DiffuseFeatureGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|
const MaterialFeatureData &fd )
|
|
const MaterialFeatureData &fd )
|
|
{
|
|
{
|
|
@@ -1099,7 +1112,33 @@ void DiffuseFeatureGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|
diffuseMaterialColor->constSortPos = cspPotentialPrimitive;
|
|
diffuseMaterialColor->constSortPos = cspPotentialPrimitive;
|
|
|
|
|
|
MultiLine* meta = new MultiLine;
|
|
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;
|
|
output = meta;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1231,9 +1270,9 @@ void LightmapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|
// Lightmap has already been included in the advanced light bin, so
|
|
// Lightmap has already been included in the advanced light bin, so
|
|
// no need to do any sampling or anything
|
|
// no need to do any sampling or anything
|
|
if(bPreProcessedLighting)
|
|
if(bPreProcessedLighting)
|
|
- statement = new GenOp( "float4(@, 1.0)", inColor );
|
|
|
|
|
|
+ statement = new GenOp( "vec4(@, 1.0)", inColor );
|
|
else
|
|
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;
|
|
MultiLine *meta = new MultiLine;
|
|
if( fd.features[MFT_LightbufferMRT] )
|
|
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
|
|
else
|
|
meta->addStatement( new GenOp( " @;\r\n", assignColor( statement, Material::Mul ) ) );
|
|
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
|
|
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
|
|
// Assign to proper render target
|
|
if( fd.features[MFT_LightbufferMRT] )
|
|
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
|
|
else
|
|
meta->addStatement( new GenOp( " @;\r\n", assignColor( toneMapColor, blendOp ) ) );
|
|
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
|
|
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
|
|
// the dynamic light buffer, and it already has the baked-vertex-color
|
|
// included in it
|
|
// included in it
|
|
if(bPreProcessedLighting)
|
|
if(bPreProcessedLighting)
|
|
- outColor = new GenOp( "float4(@.rgb, 1.0)", rtLightingColor );
|
|
|
|
|
|
+ outColor = new GenOp( "vec4(@.rgb, 1.0)", rtLightingColor );
|
|
else
|
|
else
|
|
- outColor = new GenOp( "float4(@.rgb + @.rgb, 1.0)", rtLightingColor, outColor );
|
|
|
|
|
|
+ outColor = new GenOp( "vec4(@.rgb + @.rgb, 1.0)", rtLightingColor, outColor );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// Output the color
|
|
// Output the color
|
|
if ( fd.features[MFT_LightbufferMRT] )
|
|
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
|
|
else
|
|
meta->addStatement( new GenOp( " @;\r\n", assignColor( outColor, blendOp ) ) );
|
|
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
|
|
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.
|
|
// and a simple multiplication with the detail map.
|
|
|
|
|
|
LangElement *statement = new GenOp( "( tex2D(@, @) * 2.0 ) - 1.0", detailMap, inTex );
|
|
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 )
|
|
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 );
|
|
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 ) );
|
|
outPosition, modelview, inPosition ) );
|
|
|
|
|
|
output = meta;
|
|
output = meta;
|
|
@@ -1694,8 +1736,8 @@ void ReflectCubeFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|
cubeNormal->setName( "cubeNormal" );
|
|
cubeNormal->setName( "cubeNormal" );
|
|
cubeNormal->setType( "vec3" );
|
|
cubeNormal->setType( "vec3" );
|
|
LangElement *cubeNormDecl = new DecOp( cubeNormal );
|
|
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 ) );
|
|
cubeNormDecl, cubeTrans, inNormal ) );
|
|
|
|
|
|
meta->addStatement( new GenOp( " @ = bool(length(@)) ? normalize(@) : @;\r\n",
|
|
meta->addStatement( new GenOp( " @ = bool(length(@)) ? normalize(@) : @;\r\n",
|
|
@@ -1771,9 +1813,14 @@ void ReflectCubeFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|
}
|
|
}
|
|
else
|
|
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
|
|
// grab connector texcoord register
|
|
@@ -1786,7 +1833,7 @@ void ReflectCubeFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|
|
|
|
|
// create cubemap var
|
|
// create cubemap var
|
|
Var *cubeMap = new Var;
|
|
Var *cubeMap = new Var;
|
|
- cubeMap->setType( "samplerCUBE" );
|
|
|
|
|
|
+ cubeMap->setType( "samplerCube" );
|
|
cubeMap->setName( "cubeMap" );
|
|
cubeMap->setName( "cubeMap" );
|
|
cubeMap->uniform = true;
|
|
cubeMap->uniform = true;
|
|
cubeMap->sampler = true;
|
|
cubeMap->sampler = true;
|
|
@@ -1800,14 +1847,36 @@ void ReflectCubeFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|
if ( fd.materialFeatures[MFT_RTLighting] )
|
|
if ( fd.materialFeatures[MFT_RTLighting] )
|
|
attn =(Var*)LangElement::find("d_NL_Att");
|
|
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;
|
|
LangElement *lerpVal = NULL;
|
|
Material::BlendOp blendOp = Material::LerpAlpha;
|
|
Material::BlendOp blendOp = Material::LerpAlpha;
|
|
|
|
|
|
// Note that the lerpVal needs to be a float4 so that
|
|
// Note that the lerpVal needs to be a float4 so that
|
|
// it will work with the LerpAlpha blend.
|
|
// 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 )
|
|
if ( attn )
|
|
lerpVal = new GenOp( "@ * saturate( @ )", glossColor, attn );
|
|
lerpVal = new GenOp( "@ * saturate( @ )", glossColor, attn );
|
|
@@ -1821,8 +1890,16 @@ void ReflectCubeFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|
else
|
|
else
|
|
blendOp = Material::Mul;
|
|
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;
|
|
output = meta;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1967,7 +2044,7 @@ void RTLightingFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|
Var *objTrans = getObjTrans( componentList, fd.features[MFT_UseInstancing], meta );
|
|
Var *objTrans = getObjTrans( componentList, fd.features[MFT_UseInstancing], meta );
|
|
|
|
|
|
// Transform the normal to world space.
|
|
// 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 );
|
|
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).
|
|
// feature (this is done for BL terrain lightmaps).
|
|
LangElement *lightMask = LangElement::find( "lightMask" );
|
|
LangElement *lightMask = LangElement::find( "lightMask" );
|
|
if ( !lightMask )
|
|
if ( !lightMask )
|
|
- lightMask = new GenOp( "float4( 1, 1, 1, 1 )" );
|
|
|
|
|
|
+ lightMask = new GenOp( "vec4( 1, 1, 1, 1 )" );
|
|
|
|
|
|
// Get all the light constants.
|
|
// Get all the light constants.
|
|
Var *inLightPos = new Var( "inLightPos", "vec4" );
|
|
Var *inLightPos = new Var( "inLightPos", "vec4" );
|
|
@@ -2080,7 +2157,7 @@ void RTLightingFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|
rtShading, specular ) );
|
|
rtShading, specular ) );
|
|
|
|
|
|
// Apply the lighting to the diffuse color.
|
|
// 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 ) ) );
|
|
meta->addStatement( new GenOp( " @;\r\n", assignColor( lighting, Material::Mul ) ) );
|
|
output = meta;
|
|
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.
|
|
// 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 )
|
|
if ( !color )
|
|
{
|
|
{
|
|
output = NULL;
|
|
output = NULL;
|
|
@@ -2718,3 +2797,16 @@ void ImposterVertFeatureGLSL::determineFeature( Material *material,
|
|
outFeatureData->features.addFeature( MFT_ImposterVert );
|
|
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;
|
|
|
|
+}
|
|
|
|
+
|