Jump to content
  • Advertisement
Sign in to follow this  

Shadow matrix

This topic is 5198 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have this shadow matrix I would like to use, but I read drawing the model twice gives z-buffer artifacts. Is there something out there I can pass as input my intersecting shadow polys and return one (or more) combined polys?
shadowMatrix(GLfloat shadowMat[4][4], GLfloat groundplane[4], GLfloat lightpos[4]) { 
GLfloat dot; 
/* Find dot product between light position vector and ground plane normal. */ 
dot = groundplane[X] * lightpos[X] + 
groundplane[Y] * lightpos[Y] + 
groundplane[Z] * lightpos[Z] + 
groundplane[W] * lightpos[W]; 
shadowMat[0][0] = dot - lightpos[X] * groundplane[X]; 
shadowMat[1][0] = 0.f - lightpos[X] * groundplane[Y]; 
shadowMat[2][0] = 0.f - lightpos[X] * groundplane[Z]; 
shadowMat[3][0] = 0.f - lightpos[X] * groundplane[W]; 
shadowMat[X][1] = 0.f - lightpos[Y] * groundplane[X]; 
shadowMat[1][1] = dot - lightpos[Y] * groundplane[Y]; 
shadowMat[2][1] = 0.f - lightpos[Y] * groundplane[Z]; 
shadowMat[3][1] = 0.f - lightpos[Y] * groundplane[W]; 
shadowMat[X][2] = 0.f - lightpos[Z] * groundplane[X]; 
shadowMat[1][2] = 0.f - lightpos[Z] * groundplane[Y]; 
shadowMat[2][2] = dot - lightpos[Z] * groundplane[Z]; 
shadowMat[3][2] = 0.f - lightpos[Z] * groundplane[W]; 
shadowMat[X][3] = 0.f - lightpos[W] * groundplane[X]; 
shadowMat[1][3] = 0.f - lightpos[W] * groundplane[Y]; 
shadowMat[2][3] = 0.f - lightpos[W] * groundplane[Z]; 
shadowMat[3][3] = dot - lightpos[W] * groundplane[W]; 

Share this post

Link to post
Share on other sites
Render the shadow(s) into the stencil buffer instead of to the screen. Then apply a shadow coloured quad/sprite over the whole screen with stencil test set to only render shadow coloured pixels for those pixels which are set in the stencil buffer (i.e. the shadowed parts).

Share this post

Link to post
Share on other sites
I'm doing this for some older graphics cards without stencil support, so I would like to render
it as a non-intersecting poly.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • 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!