Jump to content
  • Advertisement
Sign in to follow this  
Kwizatz

OpenGL What values to pass glFrustum to generate a spotlight shadowmap?

This topic is 4372 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

So, I somehow got shadowmaps working on my engine based on the More OpenGL Game Programming book, but I need to find out what values to pass to glFrustum when generating the shadow map in order to get a tight fit with a spotlight. For example I have a spolight at position 0,0,0 looking at position 0,-500,-500, and it has an "aperture" angle of 45 degrees, its round, so the left, right,top bottom parameters must be the same value to create a square, but what do I do in order to calculate all the parameters (including near and far)? I tried gluPerspective, but it didnt quite work. Also, I am getting some shadow artifacts as well as a shadow in the ceiling of the cube that doesnt belong there, how can I avoid it? I take it this is due to the shadowmap projection, should I disable the shadowmap texture when rendering geometry that is not in the light frustum? back on topic, what I want is to have shadows only on the light blue circle on the picture above. Thanks [smile]

Share this post


Link to post
Share on other sites
Advertisement
Ok I figured the original question, using TAN and an arbitrary near value, I can get the value for top, which is the same for right and the same but negative for bottom and left.

basically:

radius=tanf(DEG2RADIANS(angle))*arbitrary_near_plane_distance;

the far plane is also arbitrary and independent from the other values, now I think I need to use the stencil buffer in order to get the circle shape into the shadowmap.

Anyway, I am still getting the shadow artifacts, any ideas?

Share this post


Link to post
Share on other sites
draw the light frustum onscreen it helps tremendously
to do that draw a (-1,-1,-1)->(1,1,1) cube in the inverse of the proj*mv matrix
the shadow at the top is cause by back projection (the shadow will be reversed)
google 'shadowmap back projection etc' + u should find some solutions

Share this post


Link to post
Share on other sites
Alright, thanks guys, seems like I need Back Shadow Clipping though those walls are actually a cube each (I am using a BSP tree with convex brushes) so, disabling the shadows on the faces not inside the light frustum will probably be better, I'll see what I can do.

Thanks!

[Edit] Wow!, Phantom, I would had sworn I had already rated you up before, but I had not!, its corrected now [smile].

[Edited by - Kwizatz on October 5, 2006 12:41:47 PM]

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!