I'm all set to set up shadow mapping in my 3d engine but there is one thing I am struggling to understand. The scene needs to be rendered from the light's point of view so I simply first move my camera to the light's position but then I need to find out which direction the light is looking. Since its a point light its not shining in any particular direction. How do I figure out what the orientation for the light point of view is?
Generally, the approach for a point light which is shining light in all directions is to produce 6 shadow maps one for each axis.
So you have your camera look along the +x, -x, +y, -y,+z and -z axes to make 6 shadow maps to create a cube map. Each axis's 'view' will be rendered with a 45deg field of view.
You can of course check each of the light's 'view' frustums for collision against the real view frustum. If it doesn't collide, then no need to generate the SM for that side of the cube map.
A lot of this work can be handled quite quickly by the geometry shader see here, but there is no such thing as a free lunch.
Realistically, if you have many lights, you will need to somehow limit the number of lights which are casting shadows either by;
- sort your lights in some priority order, perhaps based on brightness or some game context
- have you lights cast shadows only over a limited distance, so only lights within a certain radius of the camera cast shadows
- combination of 1 & 2 (2 is really a special case of 1 anyway)