Jump to content
  • Advertisement
  • entries
    88
  • comments
    105
  • views
    70834

Lighting and shadow map changes

Sign in to follow this  
mixmaster

313 views

Very productive night last night. Modified the way I calculate my Shadow Map Texture Matrix. Split into two parts

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.
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!