Generate samplers for Lightmap shader, based on the number of lightmaps. This fixes the weird display of some lightmapped shapes.

--HG--
branch : gsoc2013-dfighter
hg/feature/gsoc2013-dfighter
dfighter1985 11 years ago
parent 36a30e83a0
commit 300cd284d1

@ -853,6 +853,9 @@ namespace NL3D
void CGLSLShaderGenerator::generateLightMapPS()
{
int ls = material->_LightMaps.size();
ls++; // lightmaps + color texture
int ntextures = 0;
for( int i = TexCoord0; i < TexCoord4; i++ )
{
@ -860,6 +863,8 @@ namespace NL3D
ntextures++;
}
ntextures = std::max( ntextures, ls );
for( int i = 0; i < ntextures; i++ )
ss << "uniform sampler2D sampler" << i << ";" << std::endl;

@ -156,6 +156,9 @@ namespace NL3D
desc.setShaderType( mat.getShader() );
desc.setVBFlags( _CurrentVertexBufferHard->VB->getVertexFormat() );
if( mat.getShader() == CMaterial::LightMap )
desc.setNLightMaps( mat._LightMaps.size() );
int i = 0;
if( mat.getShader() == CMaterial::Normal )

@ -34,6 +34,7 @@ namespace NL3D
shaderType = 0;
program = NULL;
vbFlags = 0;
nlightmaps = 0;
}
~CShaderDesc(){
@ -47,6 +48,9 @@ namespace NL3D
if( vbFlags != o.vbFlags )
return false;
if( nlightmaps != o.nlightmaps )
return false;
for( int i = 0; i < MAX_TEXTURES; i++ )
if( texEnvMode[ i ] != o.texEnvMode[ i ] )
return false;
@ -58,12 +62,14 @@ namespace NL3D
void setVBFlags( uint32 flags ){ vbFlags = flags; }
void setShaderType( uint32 type ){ shaderType = type; }
void setProgram( IProgramObject *p ){ program = p; }
void setNLightMaps( uint32 n ){ nlightmaps = n; }
IProgramObject* getProgram() const{ return program; }
private:
uint32 texEnvMode[ MAX_TEXTURES ];
uint32 vbFlags;
uint32 shaderType;
uint32 nlightmaps;
IProgramObject *program;
};
}

Loading…
Cancel
Save