Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

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.

[edit]

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;

  1. sort your lights in some priority order, perhaps based on brightness or some game context
  2. have you lights cast shadows only over a limited distance, so only lights within a certain radius of the camera cast shadows
  3. combination of 1 & 2 (2 is really a special case of 1 anyway)
share|improve this answer
    
width*height*6n if n is the number of point lights sounds like allot of pixels. This sounds computationally expensive. Are you sure I have to render 6 shadow maps per light because most of those shadows generated this way will be frustum culled anyways. –  PgrAm Oct 15 '12 at 19:52
    
I have read about something called Dual-Paraboloid Shadow Mapping that only uses two maps per light does anyone have any details about implementing this in OpenGL? –  PgrAm Oct 15 '12 at 20:04
    
maybe you should make a new question about that technique? –  Ken Oct 15 '12 at 20:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.