|
@@ -828,6 +828,12 @@ Var* ShaderFeatureGLSL::addOutDetailTexCoord( Vector<ShaderComponent*> &compon
|
|
|
// Base Texture
|
|
|
//****************************************************************************
|
|
|
|
|
|
+DiffuseMapFeatGLSL::DiffuseMapFeatGLSL()
|
|
|
+: mTorqueDep("shaders/common/gl/torque.glsl")
|
|
|
+{
|
|
|
+ addDependency(&mTorqueDep);
|
|
|
+}
|
|
|
+
|
|
|
void DiffuseMapFeatGLSL::processVert( Vector<ShaderComponent*> &componentList,
|
|
|
const MaterialFeatureData &fd )
|
|
|
{
|
|
@@ -855,20 +861,23 @@ void DiffuseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|
|
diffuseMap->sampler = true;
|
|
|
diffuseMap->constNum = Var::getTexUnitNum(); // used as texture unit num here
|
|
|
|
|
|
+ // create sample color var
|
|
|
+ Var *diffColor = new Var;
|
|
|
+ diffColor->setType("vec4");
|
|
|
+ diffColor->setName("diffuseColor");
|
|
|
+ LangElement *colorDecl = new DecOp( diffColor );
|
|
|
+
|
|
|
+ MultiLine * meta = new MultiLine;
|
|
|
+ output = meta;
|
|
|
+
|
|
|
if ( fd.features[MFT_CubeMap] )
|
|
|
{
|
|
|
- MultiLine * meta = new MultiLine;
|
|
|
-
|
|
|
- // create sample color
|
|
|
- Var *diffColor = new Var;
|
|
|
- diffColor->setType( "vec4" );
|
|
|
- diffColor->setName( "diffuseColor" );
|
|
|
- LangElement *colorDecl = new DecOp( diffColor );
|
|
|
-
|
|
|
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 ) ) );
|
|
|
output = meta;
|
|
@@ -877,8 +886,6 @@ void DiffuseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|
|
{
|
|
|
// Handle atlased textures
|
|
|
// http://www.infinity-universe.com/Infinity/index.php?option=com_content&task=view&id=65&Itemid=47
|
|
|
- MultiLine * meta = new MultiLine;
|
|
|
- output = meta;
|
|
|
|
|
|
Var *atlasedTex = new Var;
|
|
|
atlasedTex->setName("atlasedTexCoord");
|
|
@@ -934,11 +941,6 @@ void DiffuseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|
|
// For the rest of the feature...
|
|
|
inTex = atlasedTex;
|
|
|
|
|
|
- // create sample color var
|
|
|
- Var *diffColor = new Var;
|
|
|
- diffColor->setType("vec4");
|
|
|
- diffColor->setName("diffuseColor");
|
|
|
-
|
|
|
// To dump out UV coords...
|
|
|
//#define DEBUG_ATLASED_UV_COORDS
|
|
|
#ifdef DEBUG_ATLASED_UV_COORDS
|
|
@@ -954,21 +956,26 @@ void DiffuseMapFeatGLSL::processPix( Vector<ShaderComponent*> &componentList,
|
|
|
{
|
|
|
meta->addStatement(new GenOp( " @ = tex2Dlod(@, float4(@, 0.0, mipLod));\r\n",
|
|
|
new DecOp(diffColor), diffuseMap, inTex));
|
|
|
+ if (!fd.features[MFT_Imposter])
|
|
|
+ meta->addStatement(new GenOp(" @ = toLinear(@);\r\n", diffColor, diffColor));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
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)));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- LangElement *statement = new GenOp( "tex2D(@, @)", diffuseMap, inTex );
|
|
|
- output = new GenOp( " @;\r\n", assignColor( statement, Material::Mul ) );
|
|
|
+ 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)));
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
ShaderFeature::Resources DiffuseMapFeatGLSL::getResources( const MaterialFeatureData &fd )
|