Added ambient term support for directional light.

--HG--
branch : gsoc2013-dfighter
hg/feature/gsoc2013-dfighter
dfighter1985 11 years ago
parent 43817746ec
commit 354d2b8c65

@ -66,6 +66,14 @@ namespace NL3D
Light5ColDiff,
Light6ColDiff,
Light7ColDiff,
Light0ColAmb,
Light1ColAmb,
Light2ColAmb,
Light3ColAmb,
Light4ColAmb,
Light5ColAmb,
Light6ColAmb,
Light7ColAmb,
NUM_UNIFORMS
};

@ -212,6 +212,14 @@ namespace NL3D
"light5ColDiff",
"light6ColDiff",
"light7ColDiff",
"light0ColAmb",
"light1ColAmb",
"light2ColAmb",
"light3ColAmb",
"light4ColAmb",
"light5ColAmb",
"light6ColAmb",
"light7ColAmb"
};
void CGLSLProgram::cacheUniformIndices()

@ -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;
}

@ -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 );
}
}

Loading…
Cancel
Save