Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Engine/source/materials/materialDefinition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ Material::Material()
mIgnoreLighting[i] = false;

mDetailScale[i].set(2.0f, 2.0f);

mTileScale[i].set(1.0f, 1.0f);
mDetailNormalMapStrength[i] = 1.0f;

mMinnaertConstant[i] = -1.0f;
Expand Down Expand Up @@ -257,6 +257,8 @@ void Material::initPersistFields()
"is present this is the material color.");
addField("diffuseMapSRGB", TypeBool, Offset(mDiffuseMapSRGB, Material), MAX_STAGES,
"Enable sRGB for the diffuse color texture map.");
addField("TileScale", TypePoint2F, Offset(mTileScale, Material), MAX_STAGES,
"The scale factor for the detail map.");

INITPERSISTFIELD_IMAGEASSET_ARRAY(NormalMap, MAX_STAGES, Material, "NormalMap");
endGroup("Basic Texture Maps");
Expand Down
1 change: 1 addition & 0 deletions Engine/source/materials/materialDefinition.h
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ class Material : public BaseMaterialDefinition
/// The repetition scale of the detail texture
/// over the base texture.
Point2F mDetailScale[MAX_STAGES];
Point2F mTileScale[MAX_STAGES];

U32 mAnimFlags[MAX_STAGES];
Point2F mScrollDir[MAX_STAGES];
Expand Down
3 changes: 3 additions & 0 deletions Engine/source/materials/processedShaderMaterial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
void ShaderConstHandles::init( GFXShader *shader, CustomMaterial* mat /*=NULL*/)
{
mDiffuseColorSC = shader->getShaderConstHandle("$diffuseMaterialColor");
mTileScaleSC = shader->getShaderConstHandle(ShaderGenVars::tileScale);
mTexMatSC = shader->getShaderConstHandle(ShaderGenVars::texMat);
mToneMapTexSC = shader->getShaderConstHandle(ShaderGenVars::toneMap);
mORMConfigSC = shader->getShaderConstHandle(ShaderGenVars::ormConfig);
Expand Down Expand Up @@ -1142,6 +1143,8 @@ void ProcessedShaderMaterial::_setShaderConstants(SceneRenderState * state, cons
shaderConsts->set( handles->mOneOverRTSizeSC, oneOverTargetSize );
}

shaderConsts->setSafe(handles->mTileScaleSC, mMaterial->mTileScale[stageNum]);

// set detail scale
shaderConsts->setSafe(handles->mDetailScaleSC, mMaterial->mDetailScale[stageNum]);
shaderConsts->setSafe(handles->mDetailBumpStrength, mMaterial->mDetailNormalMapStrength[stageNum]);
Expand Down
1 change: 1 addition & 0 deletions Engine/source/materials/processedShaderMaterial.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class ShaderConstHandles
public:
GFXShaderConstHandle* mDiffuseColorSC;
GFXShaderConstHandle* mToneMapTexSC;
GFXShaderConstHandle* mTileScaleSC;
GFXShaderConstHandle* mTexMatSC;
GFXShaderConstHandle* mORMConfigSC;
GFXShaderConstHandle* mRoughnessSC;
Expand Down
15 changes: 11 additions & 4 deletions Engine/source/shaderGen/GLSL/shaderFeatureGLSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,13 @@ Var* ShaderFeatureGLSL::getOutTexCoord( const char *name,
texCoord->setStructName( "OUT" );
texCoord->setType( type );

// create detail variable
Var* tileScale = new Var;
tileScale->setType("vec2");
tileScale->setName("tileScale");
tileScale->uniform = true;
tileScale->constSortPos = cspPotentialPrimitive;

if( useTexAnim )
{
inTex->setType( "vec4" );
Expand All @@ -377,15 +384,15 @@ Var* ShaderFeatureGLSL::getOutTexCoord( const char *name,

// Statement allows for casting of different types which
// eliminates vector truncation problems.
String statement = String::ToString( " @ = %s(tMul(@, @).xy);\r\n", type );
meta->addStatement( new GenOp( statement , texCoord, texMat, inTex ) );
String statement = String::ToString( " @ = %s(tMul(@, @).xy * @);\r\n", type );
meta->addStatement( new GenOp( statement , texCoord, texMat, inTex, tileScale) );
}
else
{
// Statement allows for casting of different types which
// eliminates vector truncation problems.
String statement = String::ToString( " @ = %s(@);\r\n", type );
meta->addStatement( new GenOp( statement, texCoord, inTex ) );
String statement = String::ToString( " @ = %s(@ * @);\r\n", type );
meta->addStatement( new GenOp( statement, texCoord, inTex, tileScale) );
}
}

Expand Down
15 changes: 11 additions & 4 deletions Engine/source/shaderGen/HLSL/shaderFeatureHLSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,13 @@ Var* ShaderFeatureHLSL::getOutTexCoord( const char *name,
texCoord->setStructName( "OUT" );
texCoord->setType( type );

// create detail variable
Var* tileScale = new Var;
tileScale->setType("float2");
tileScale->setName("tileScale");
tileScale->uniform = true;
tileScale->constSortPos = cspPotentialPrimitive;

if ( useTexAnim )
{
inTex->setType( "float2" );
Expand All @@ -377,15 +384,15 @@ Var* ShaderFeatureHLSL::getOutTexCoord( const char *name,

// Statement allows for casting of different types which
// eliminates vector truncation problems.
String statement = String::ToString(" @ = (%s)mul(@, float4(@,1,1));\r\n", type);
meta->addStatement( new GenOp( statement, texCoord, texMat, inTex ) );
String statement = String::ToString(" @ = (%s)mul(@, float4(@,1,1))*@;\r\n", type);
meta->addStatement( new GenOp( statement, texCoord, texMat, inTex, tileScale) );
}
else
{
// Statement allows for casting of different types which
// eliminates vector truncation problems.
String statement = String::ToString( " @ = (%s)@;\r\n", type );
meta->addStatement( new GenOp( statement, texCoord, inTex ) );
String statement = String::ToString( " @ = (%s)(@ * @);\r\n", type );
meta->addStatement( new GenOp( statement, texCoord, inTex, tileScale) );
}
}

Expand Down
1 change: 1 addition & 0 deletions Engine/source/shaderGen/shaderGenVars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const String ShaderGenVars::fogColor("$fogColor");
const String ShaderGenVars::detailScale("$detailScale");
const String ShaderGenVars::visibility("$visibility");
const String ShaderGenVars::colorMultiply("$colorMultiply");
const String ShaderGenVars::tileScale("$tileScale");
const String ShaderGenVars::alphaTestValue("$alphaTestValue");
const String ShaderGenVars::texMat("$texMat");
const String ShaderGenVars::accumTime("$accumTime");
Expand Down
1 change: 1 addition & 0 deletions Engine/source/shaderGen/shaderGenVars.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ struct ShaderGenVars
const static String detailScale;
const static String visibility;
const static String colorMultiply;
const static String tileScale;
const static String alphaTestValue;
const static String texMat;
const static String accumTime;
Expand Down
Loading