PDA

View Full Version : Shadow Buffers and Direction Light (infinity)

pocketmoon
09-03-2002, 05:56 AM
Dear Chaps,

<edit - subject line should say Directional of course)

Two questions for you.

1) What goes into the depth buffer when rendering using orthgonal projection ?

2) Can the SGI Shadow Buffer extension method (as seen in Nvidia and other shadow map demos) be modified to implement a light at infinity (directional light).

The two questions link since I'll need to render the scene to the shadow buffer from the light point of view using an orthogonal projection and I'll then need change the way the routine compares fragment Z values since the shadow buffer wont hold distance from light, rather just distance <answer to question 1>

ta ta

[This message has been edited by pocketmoon (edited 09-03-2002).]

jwatte
09-03-2002, 07:09 AM
There is nothing particularly different about orthogonal projections. The math works out pretty much the same.

And, yes, you should be able to use a directional light in shadow buffer, by making the projection orthogonal, just like you intuit. The input to the depth compare has to be slightly different, however; it should probably be a dot product with the light vector (distance from plane) rather than a regular distance to point.

Nakoruru
09-03-2002, 07:31 AM
There are several other issues to doing directional shadows. The best solution to shadow maps so far is Perspective Shadow Maps. This method handles directional lights particularly well.

09-03-2002, 11:30 AM
2) Don't know if this helps, but I used a skewed orthogonal projection for lights at infinity. This way I could make the light shine in at an angle, while still having the far clipping plane parallel to the ground plane.

Here's the projection matrix:

/ 2/(r-l) 0 (r+l)/((r-l)n) 0 \
| 0 2/(t-b) (t+b)/((t-b)n) 0 |
| 0 0 -2/(f-n) -(f+n)/(f-n) |
\ 0 0 0 1 /

As you can see it's similar to the orthogonal projection matrix, but x and y is dependent on z instead of just being translated.

/Jonas

pocketmoon
09-04-2002, 02:19 AM
thanks folks,
I had a read of the Perspective Shadow Maps paper last night. And I'd like to try something similar but more restictive, using a skewed orthogonal projection as described by Jonask.

The simple case. Viewpoint above a ground plane looking horizontally. The area I want to shadow is defined as extending from the view point projected onto the horizontal plane, extending from zNear to say 100 units. This gives an area of interest like this (looking north, viewed from above):

............_______________............
............\............./............
.............\.........../.............
..............\........./..............
...............\......./...............
................\...../................
.................-----................
.............near clip plane........

Assume this area never changes shape, only location on the z-plane and rotation around y axis.

Assuming in this case my directional light is straight up.

What I need is an skewed orthogonal projection that will take the area and project it into the shadow buffer.

______ ___
\ / | |
\__/ => |___|

Am I on the right track ? Whats the best 'space' to work in ? I suppose I've described this working in some sort of z-plane eye space...

Rob.

[This message has been edited by pocketmoon (edited 09-04-2002).]