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 4e04644bb..b42f582f6 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 @@ -420,7 +420,7 @@ namespace NL3D { ss << "float getIntensity" << num << "( vec3 normal3, vec3 lightDir )" << std::endl; ss << "{" << std::endl; - ss << "float angle = dot( normalize( -lightDir ), normal3 );" << std::endl; + ss << "float angle = dot( lightDir, normal3 );" << std::endl; ss << "angle = max( 0.0, angle );" << std::endl; ss << "return angle;" << std::endl; ss << "}" << std::endl; @@ -440,8 +440,10 @@ namespace NL3D ss << "{" << std::endl; ss << "vec4 lightDir4 = modelView * vec4( light" << num << "DirOrPos, 1.0 );" << std::endl; ss << "vec3 lightDir = lightDir4.xyz / lightDir4.w;" << std::endl; + ss << "lightDir = normalize( lightDir );" << std::endl; ss << "vec3 normal3 = vnormal.xyz / vnormal.w;" << std::endl; ss << "normal3 = normalMatrix * normal3;" << std::endl; + ss << "normal3 = normalize( normal3 );" << std::endl; ss << "vec4 lc = getIntensity" << num << "( normal3, lightDir ) * light" << num << "ColDiff + "; ss << "getSpecIntensity" << num << "( normal3, lightDir ) * light" << num << "ColSpec + "; ss << "light" << num << "ColAmb;" << std::endl; @@ -454,7 +456,7 @@ namespace NL3D { ss << "float getIntensity" << num << "( vec3 normal3, vec3 direction3 )" << std::endl; ss << "{" << std::endl; - ss << "float angle = dot( normalize( direction3 ), normal3 );" << std::endl; + ss << "float angle = dot( direction3, normal3 );" << std::endl; ss << "angle = max( 0.0, angle );" << std::endl; ss << "return angle;" << std::endl; ss << "}" << std::endl; @@ -485,6 +487,7 @@ namespace NL3D ss << "vec3 normal3 = vnormal.xyz / vnormal.w;" << std::endl; ss << "normal3 = normalMatrix * normal3;" << std::endl; + ss << "normal3 = normalize( normal3 );" << std::endl; ss << "vec4 lc = getIntensity" << num << "( normal3, lightDirection ) * light" << num << "ColDiff + "; ss << "getSpecIntensity" << num << "( normal3, lightDirection ) * light" << num << "ColSpec + "; 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 5dd3570d0..a8b7ba116 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl_program.cpp +++ b/code/nel/src/3d/driver/opengl3/driver_opengl_program.cpp @@ -791,7 +791,7 @@ namespace NL3D int ld = p->getUniformIndex( CProgramIndex::TName( CProgramIndex::Light0DirOrPos + i ) ); if( ld != -1 ) { - CVector v = _UserLight[ i ].getDirection(); + CVector v = -1 * _UserLight[ i ].getDirection(); setUniform3f( program, ld, v.x, v.y, v.z ); } }