diff --git a/code/nel/src/3d/driver/OpenGL3/driver_glsl_shader_generator.cpp b/code/nel/src/3d/driver/OpenGL3/driver_glsl_shader_generator.cpp index 1f40a01ab..76b433acd 100644 --- a/code/nel/src/3d/driver/OpenGL3/driver_glsl_shader_generator.cpp +++ b/code/nel/src/3d/driver/OpenGL3/driver_glsl_shader_generator.cpp @@ -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; diff --git a/code/nel/src/3d/driver/OpenGL3/driver_opengl_program.cpp b/code/nel/src/3d/driver/OpenGL3/driver_opengl_program.cpp index e6a3f1df4..8910b0f04 100644 --- a/code/nel/src/3d/driver/OpenGL3/driver_opengl_program.cpp +++ b/code/nel/src/3d/driver/OpenGL3/driver_opengl_program.cpp @@ -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 ) diff --git a/code/nel/src/3d/driver/OpenGL3/driver_opengl_shader_desc.h b/code/nel/src/3d/driver/OpenGL3/driver_opengl_shader_desc.h index ced7d724b..4f5a6a594 100644 --- a/code/nel/src/3d/driver/OpenGL3/driver_opengl_shader_desc.h +++ b/code/nel/src/3d/driver/OpenGL3/driver_opengl_shader_desc.h @@ -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; }; }