Jump to content
  • Advertisement
  • entries
  • comments
  • views

Lighting and shadow map changes

Sign in to follow this  


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  


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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!