diff --git a/code/nel/include/nel/3d/i_program_object.h b/code/nel/include/nel/3d/i_program_object.h index 071303ac1..caf610865 100644 --- a/code/nel/include/nel/3d/i_program_object.h +++ b/code/nel/include/nel/3d/i_program_object.h @@ -66,6 +66,14 @@ namespace NL3D Light5ColDiff, Light6ColDiff, Light7ColDiff, + Light0ColAmb, + Light1ColAmb, + Light2ColAmb, + Light3ColAmb, + Light4ColAmb, + Light5ColAmb, + Light6ColAmb, + Light7ColAmb, NUM_UNIFORMS }; diff --git a/code/nel/src/3d/driver/OpenGL3/driver_glsl_program.cpp b/code/nel/src/3d/driver/OpenGL3/driver_glsl_program.cpp index 12637beca..e78ec9bac 100644 --- a/code/nel/src/3d/driver/OpenGL3/driver_glsl_program.cpp +++ b/code/nel/src/3d/driver/OpenGL3/driver_glsl_program.cpp @@ -212,6 +212,14 @@ namespace NL3D "light5ColDiff", "light6ColDiff", "light7ColDiff", + "light0ColAmb", + "light1ColAmb", + "light2ColAmb", + "light3ColAmb", + "light4ColAmb", + "light5ColAmb", + "light6ColAmb", + "light7ColAmb" }; void CGLSLProgram::cacheUniformIndices() 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 aae12318c..89ec89c58 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 @@ -360,6 +360,7 @@ namespace NL3D case CShaderDesc::Directional: ss << "uniform vec4 light" << i << "ColDiff;" << std::endl; + ss << "uniform vec4 light" << i << "ColAmb;" << std::endl; break; } } @@ -440,7 +441,13 @@ namespace NL3D { ss << "vec4 applyLights( vec4 col )" << std::endl; ss << "{" << std::endl; - ss << "col = col * intensity0 * light0ColDiff;" << std::endl; + + for( int i = 0; i < SHADER_MAX_LIGHTS; i++ ) + { + if( desc->getLight( i ) != CShaderDesc::Nolight ) + ss << "col = col * ( intensity" << i << " * light" << i << "ColDiff + light" << i << "ColAmb );" << std::endl; + } + ss << "return col;" << std::endl; ss << "}" << 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 e1eabcd22..f8574b17b 100644 --- a/code/nel/src/3d/driver/OpenGL3/driver_opengl_program.cpp +++ b/code/nel/src/3d/driver/OpenGL3/driver_opengl_program.cpp @@ -391,10 +391,16 @@ namespace NL3D setUniform3f( ld, d.direction[ 0 ], d.direction[ 1 ], d.direction[ 2 ] ); } - int lc = currentProgram->getUniformIndex( IProgramObject::EUniform( IProgramObject::Light0ColDiff + i ) ); - if( lc != -1 ) + int ldc = currentProgram->getUniformIndex( IProgramObject::EUniform( IProgramObject::Light0ColDiff + i ) ); + if( ldc != -1 ) { - setUniform4f( lc, 1.0f, 1.0f, 1.0f, 1.0f ); + setUniform4f( ldc, 1.0f, 1.0f, 1.0f, 1.0f ); + } + + int lac = currentProgram->getUniformIndex( IProgramObject::EUniform( IProgramObject::Light0ColAmb + i ) ); + if( lac != -1 ) + { + setUniform4f( lac, 0.1f, 0.1f, 0.1f, 1.0f ); } }