Added lighting to the specular shader.

--HG--
branch : gsoc2013-dfighter
hg/feature/gsoc2013-dfighter
dfighter1985 11 years ago
parent f194704a28
commit 0453f30582

@ -601,10 +601,29 @@ namespace NL3D
ss << "uniform mat4 mvMatrix;" << std::endl; ss << "uniform mat4 mvMatrix;" << std::endl;
ss << "uniform mat4 texMatrix0;" << std::endl; ss << "uniform mat4 texMatrix0;" << std::endl;
ss << "smooth out vec3 cubeTexCoords;" << std::endl; ss << "smooth out vec3 cubeTexCoords;" << std::endl;
if( desc->fogEnabled() || desc->hasPointLight() )
{
ss << "vec4 ecPos4;" << std::endl;
}
if( desc->fogEnabled() ) if( desc->fogEnabled() )
ss << "smooth out vec4 ecPos;" << std::endl; ss << "smooth out vec4 ecPos;" << std::endl;
ss << std::endl; ss << std::endl;
if( desc->lightingEnabled() )
{
addNormalMatrix();
addLightUniformsVS();
addLightOutsVS();
ss << std::endl;
addNormalFromMVFunction();
addLightsFunctionVS();
ss << std::endl;
}
ss << "vec3 ReflectionMap( const in vec3 eyePos, const in vec3 normal )" << std::endl; ss << "vec3 ReflectionMap( const in vec3 eyePos, const in vec3 normal )" << std::endl;
ss << "{" << std::endl; ss << "{" << std::endl;
ss << "vec3 u = normalize( eyePos );" << std::endl; ss << "vec3 u = normalize( eyePos );" << std::endl;
@ -616,6 +635,12 @@ namespace NL3D
ss << "{" << std::endl; ss << "{" << std::endl;
ss << "vec4 eyePosition = mvMatrix * v" << attribNames[ 0 ] << ";" << std::endl; ss << "vec4 eyePosition = mvMatrix * v" << attribNames[ 0 ] << ";" << std::endl;
if( desc->lightingEnabled() )
ss << "calcNMFromMV();" << std::endl;
if( desc->hasPointLight() )
ss << "ecPos4 = eyePosition;" << std::endl;
if( desc->fogEnabled() ) if( desc->fogEnabled() )
ss << "ecPos = eyePosition;" << std::endl; ss << "ecPos = eyePosition;" << std::endl;
@ -627,6 +652,9 @@ namespace NL3D
ss << "cubeTexCoords = t.xyz;" << std::endl; ss << "cubeTexCoords = t.xyz;" << std::endl;
ss << "gl_Position = mvpMatrix * v" << attribNames[ 0 ] << ";" << std::endl; ss << "gl_Position = mvpMatrix * v" << attribNames[ 0 ] << ";" << std::endl;
if( desc->lightingEnabled() )
addLightsVS();
for( int i = Weight; i < NumOffsets; i++ ) for( int i = Weight; i < NumOffsets; i++ )
{ {
if( hasFlag( vbFormat, vertexFlags[ i ] ) ) if( hasFlag( vbFormat, vertexFlags[ i ] ) )
@ -1282,9 +1310,18 @@ namespace NL3D
ss << "uniform samplerCube sampler1;" << std::endl; ss << "uniform samplerCube sampler1;" << std::endl;
addDiffuse(); addDiffuse();
addAlphaTreshold(); addAlphaTreshold();
addFogUniform(); addFogUniform();
if( desc->lightingEnabled() )
{
addLightUniformsFS();
addLightInsFS();
ss << std::endl;
addLightsFunctionFS();
ss << std::endl;
}
if( desc->fogEnabled() ) if( desc->fogEnabled() )
ss << "smooth in vec4 ecPos;" << std::endl; ss << "smooth in vec4 ecPos;" << std::endl;
@ -1304,6 +1341,9 @@ namespace NL3D
ss << "texel.a = texel1.a;" << std::endl; ss << "texel.a = texel1.a;" << std::endl;
ss << "fragColor = texel;" << std::endl; ss << "fragColor = texel;" << std::endl;
if( desc->lightingEnabled() )
addLightsFS();
if( desc->fogEnabled() ) if( desc->fogEnabled() )
addFog(); addFog();

Loading…
Cancel
Save