Light Class
const GLfloat bias[] = {0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.5, 0.5, 0.5, 1.0 }; glMatrixMode( GL_TEXTURE ); glLoadMatrixf( bias ); glMultMatrixf( projection_matrix ); glMultMatrixf( getCamera_matrix() );
This only gets called if the light is used as a shadow caster.
Draw Mesh.
glMatrixMode( GL_TEXTURE ); glLoadMatrixf( spot->getShadowmap_matrix() ); glMultMatrixf( obj->getModel_matrix() ); glGetFloatv( GL_TEXTURE_MATRIX, mat ); glMatrixMode( GL_MODELVIEW );
I pass this Matrix to the current shader. Tests are done to improve performance.
I now sort lights by distance to camera, this allows for automatic shadow map switching. At the moment this is just a harsh switch, one day I'll use a fade of some sort.