From 6c58856ed714d99c7f087b2c9faec5ebaad199d4 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Sun, 15 Sep 2013 22:38:04 +0200 Subject: [PATCH] Shininess is now loaded from the material as a uniform instead of being hardcoded. --HG-- branch : gsoc2013-dfighter --- code/nel/include/nel/3d/i_program_object.h | 8 ++++++++ code/nel/src/3d/driver/OpenGL3/driver_glsl_program.cpp | 10 +++++++++- .../3d/driver/OpenGL3/driver_glsl_shader_generator.cpp | 3 ++- .../src/3d/driver/OpenGL3/driver_opengl_program.cpp | 6 ++++++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/code/nel/include/nel/3d/i_program_object.h b/code/nel/include/nel/3d/i_program_object.h index 5646ef21f..04cf0a77f 100644 --- a/code/nel/include/nel/3d/i_program_object.h +++ b/code/nel/include/nel/3d/i_program_object.h @@ -83,6 +83,14 @@ namespace NL3D Light5ColSpec, Light6ColSpec, Light7ColSpec, + Light0Shininess, + Light1Shininess, + Light2Shininess, + Light3Shininess, + Light4Shininess, + Light5Shininess, + Light6Shininess, + Light7Shininess, 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 2d577855d..547b808fe 100644 --- a/code/nel/src/3d/driver/OpenGL3/driver_glsl_program.cpp +++ b/code/nel/src/3d/driver/OpenGL3/driver_glsl_program.cpp @@ -228,7 +228,15 @@ namespace NL3D "light4ColSpec", "light5ColSpec", "light6ColSpec", - "light7ColSpec" + "light7ColSpec", + "light0Shininess", + "light1Shininess", + "light2Shininess", + "light3Shininess", + "light4Shininess", + "light5Shininess", + "light6Shininess", + "light7Shininess" }; 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 f35ffa305..2d81b087b 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 @@ -365,6 +365,7 @@ namespace NL3D ss << "uniform vec4 light" << i << "ColDiff;" << std::endl; ss << "uniform vec4 light" << i << "ColAmb;" << std::endl; ss << "uniform vec4 light" << i << "ColSpec;" << std::endl; + ss << "uniform float light" << i << "Shininess;" << std::endl; break; } } @@ -442,7 +443,7 @@ namespace NL3D //ss << "float angle = dot( normal3, reflection );" << std::endl; ss << "float angle = dot( normal3, halfVector );" << std::endl; ss << "angle = max( 0.0, angle );" << std::endl; - ss << "float si = pow( angle, 128.0 );" << std::endl; + ss << "float si = pow( angle, light" << num << "Shininess );" << std::endl; ss << "return si;" << std::endl; ss << "}" << 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 95070e1fb..885fde8fe 100644 --- a/code/nel/src/3d/driver/OpenGL3/driver_opengl_program.cpp +++ b/code/nel/src/3d/driver/OpenGL3/driver_opengl_program.cpp @@ -412,6 +412,12 @@ namespace NL3D setUniform4f( lsc, glCol[ 0 ], glCol[ 1 ], glCol[ 2 ], glCol[ 3 ] ); } + int shl = currentProgram->getUniformIndex( IProgramObject::EUniform( IProgramObject::Light0Shininess + i ) ); + if( shl != -1 ) + { + setUniform1f( shl, mat.getShininess() ); + } + int lac = currentProgram->getUniformIndex( IProgramObject::EUniform( IProgramObject::Light0ColAmb + i ) ); if( lac != -1 ) {