Dynamic shadow mapping- how to update the light's position

Started by
4 comments, last by JustChris 14 years, 2 months ago
Given the 8 corners of a camera's view frustum and the desired view direction of a light source (defined as a vector), what is a good way to calculate the view projection of a light in order to cover the entire camera frustum? I want a light's view frustum to always enclose the camera's view frustum completely, so that a projected shadow map always covers the entire view. As of now I can only render shadow maps with fixed-position lights. [Edited by - JustChris on February 19, 2010 11:42:36 PM]
Electronic Meteor - My experiences with XNA and game development
Advertisement
Not sure off hand but if nobody else helps you out, you might look at how cube maps work or how people capture images for sky boxes from 3d rendered scenes (:
I guess for cube maps, are you referring to a way to project a shadow map into a cube texture? I am just using one render target to make the shadow map.

As an example, let's say there is a camera looking just behind a character in third person view. When the character runs, the camera follows behind it. In an outdoor scene, there would be a shadows cast by a directional light (the sun), but for optimization purposes you would have the light only cast shadows over the viewable area. So as the character runs, the light needs to "follow" it with the camera by changing its position but keeping its angle. I hope that makes more sense. It seems to be a basic problem that needs to be solved for dynamic shadow mapping, but it's still not clear to me what I should be searching for.
Electronic Meteor - My experiences with XNA and game development
One method is to find the sphere which bounds those 8 points, centred at the camera's pivot point (the bit it rotates around).
Then place the light's centre at pivot - direction*radius, and make the projection wide/tall/deep enough to encompass the diameter of the sphere.
Instead of the camera's pivot, you could also use the mid-point of the 8 corners.
see this one too
Thanks, I will try both those approaches and see which one will turn out better for me.
Electronic Meteor - My experiences with XNA and game development

This topic is closed to new replies.

Advertisement