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.

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top