3

I was implementing omnidirectional shadow mapping in a deferred renderer but am having trouble solving this problem:

Here is a picture: shadow problem example

This is what happened when I just position six spot lights pointing along each axis in positive and negative directions. I know that the problem is caused by the spot light calculations keeping the lighting in the cone for the lights and that's why it is circular.

My first thought was to just disable the cone calculations but obviously because the lights are blended together if you look through one light to another there will be overlap. If I change the geometry being rendered for the light from a cone shape to a square based pyramid (which I think I will need to do anyway?) I would then be able to use the frustum of the light (which I already have) instead of a cone calculation to test if the current pixel falls inside the frustum, right?

If so does anyone know what the best way to do this in a pixel shader would be? I thought of just checking if the point lies in front of each plane of the frustum but this seems expensive to do in a pixel shader.

Gijs
  • 5,201
  • 1
  • 27
  • 42
  • Deleting and re-asking the same question is *not* how you get your question answered. You get it answered by actually putting the information *into* the question that people asked for. – Nicol Bolas Nov 30 '12 at 15:05
  • "*This is what happened when I just position six spot lights pointing along each axis in positive and negative directions.*" What would possess you to actually do that? If you want a *point light*, then just use a point light. Are you just copying and pasting code from some online deferred shading example that only showed how to do spot lights? – Nicol Bolas Nov 30 '12 at 15:07
  • Sorry for deleting the old question, i have not just resubmitted it again, i have reworded it, i had stupidly omitted that i was dealing with shadow mapping, im not asking about just adding a point light, i have that working properly. "What would possess you to actually do that?" my question regards shadow mapping with point lights in which you need to use 6 spot lights to model a point light, for an good explanation i recommend reading this alt dev blog article http://www.altdevblogaday.com/2011/01/30/omni-directional-shadow-mapping/ – user1848064 Nov 30 '12 at 16:41
  • You seem to make graphics programming tutorials and I feel if you read my reworded question you would be able to answer it now that it states I am dealing with shadow mapping – user1848064 Nov 30 '12 at 21:33
  • Make a proper point light. That's the simplest light volume type to implement. – Grimmy Dec 03 '12 at 05:16
  • No, i have point lights working, im trying to add shadow mapping for point lights (if you read the alt dev blog link in my previous comment) and need to know how i can adjust the spot light's cone calculation to an efficient frustum culling equation in the pixel shader =) – user1848064 Dec 03 '12 at 08:35

1 Answers1

0

You have 6 frustums, but note that

  1. you don't need to check the back or front faces, just whether it is in the infinite pyramid
  2. each face is shared by two neighbouring frustums
  3. each face is mirrored by the frustum that faces backwards

This means that you only have to check the pixel against 6 planes IN TOTAL to see which shadow map you need to access.

tjltjl
  • 1,479
  • 8
  • 18