Changes for get necesary sampler names for OpenGL shaders.

This commit is contained in:
LuisAntonRebollo 2014-11-08 01:57:28 +01:00
parent 79e158d528
commit 1ac8fab884
11 changed files with 155 additions and 23 deletions

View file

@ -46,6 +46,27 @@ AFTER_MODULE_INIT( MaterialManager )
Vector<TerrainCellMaterial*> TerrainCellMaterial::smAllMaterials;
Vector<String> _initSamplerNames()
{
Vector<String> samplerNames;
samplerNames.push_back("$baseTexMap");
samplerNames.push_back("$layerTex");
samplerNames.push_back("$macrolayerTex");
samplerNames.push_back("$lightMapTex");
samplerNames.push_back("$lightInfoBuffer");
for(int i = 0; i < 3; ++i)
{
samplerNames.push_back(avar("$normalMap%d",i));
samplerNames.push_back(avar("$detailMap%d",i));
samplerNames.push_back(avar("$macroMap%d",i));
}
return samplerNames;
}
const Vector<String> TerrainCellMaterial::mSamplerNames = _initSamplerNames();
TerrainCellMaterial::TerrainCellMaterial()
: mCurrPass( 0 ),
mTerrain( NULL ),
@ -460,7 +481,7 @@ bool TerrainCellMaterial::_createPass( Vector<MaterialInfo*> *materials,
const bool logErrors = matCount == 1;
GFXShader::setLogging( logErrors, true );
pass->shader = SHADERGEN->getShader( featureData, getGFXVertexFormat<TerrVertex>(), NULL );
pass->shader = SHADERGEN->getShader( featureData, getGFXVertexFormat<TerrVertex>(), NULL, mSamplerNames );
}
// If we got a shader then we can continue.
@ -499,14 +520,7 @@ bool TerrainCellMaterial::_createPass( Vector<MaterialInfo*> *materials,
pass->oneOverTerrainSize = pass->shader->getShaderConstHandle( "$oneOverTerrainSize" );
pass->squareSize = pass->shader->getShaderConstHandle( "$squareSize" );
// NOTE: We're assuming rtParams0 here as we know its the only
// render target we currently get in a terrain material and the
// DeferredRTLightingFeatHLSL will always use 0.
//
// This could change in the future and we would need to fix
// the ShaderFeature API to allow us to do this right.
//
pass->lightParamsConst = pass->shader->getShaderConstHandle( "$rtParams0" );
pass->lightParamsConst = pass->shader->getShaderConstHandle( "$rtParamslightInfoBuffer" );
// Now prepare the basic stateblock.
GFXStateBlockDesc desc;