PDA

View Full Version : Weird problem with shadow volumes



karx11erx
11-24-2006, 11:54 PM
Hi,

I am having a strange problem when computing polygon visibility as seen from the light source for volumetric shadows (z-fail). I am using the dot product of polygon normal and vector from polygon center to light source for the test. The result changes depending on the viewer position and facing. For a test I have isolated a single polygon and painted its normal and vector from its center to the light source. Polygon blue, lines red and yellow: Polygon visible. Polygon green, lines light and dark blue: Polygon invisible.

If I am in front of the polygon and look a little down, it gets invisible. Behind the polygon its the other way round. The entire calculation takes place after light source and model vertices have been transformed (translate & rotate). This is done by software, not using the OpenGL transformation functions. Everything is rendered properly, even the vector from polygon to light source and the normal. I have no clue what's going wrong here.

Here's three images:

Overview:
http://www.descent2.de/temp/shadows5.jpg

Polygon visible from light source:
http://www.descent2.de/temp/shadows6.jpg

Polygon not visible from light source:
http://www.descent2.de/temp/shadows7.jpg

As you can see, the angle between normal and vector from polygon to light source doesn't change in the images. Nevertheless the computation doesn't work. I have found out that the distance between viewer and polygon center changes when rotating the view. The projection has some scaling (X = 3:4, Y = 1:1, Z = 9/16:1).

karx11erx
11-25-2006, 12:12 PM
Problem solved.