BTW, about the depth fail algorithm… I’ve got my z-pass algorithm working, it obviously brakes when entering a shadow volume. So I had a look at the z-fail algorithm. couldn’t get it working, so I drew the algoritm on paper just to see. And it looks like it’s flawed :\
ok, here we go…
first shadow volume pass.
glCullFace(GL_FRONT); // draw back facing quads
glStencilOp(GL_KEEP, GL_INCR, GL_KEEP);
.
/.\
/ . \
/ . \
/ . \
/ +1 . +1 \
/ . \
.------±-----.
| | |
| 0 | 0 |
| | |
|||____
| | |
| 0 | 0 |
| . |
| /.\ |
| / . \ |
| / . \ |
| / . \ |
| / +1 . +1 \ |
|/ . |
. . .
. . .
. . .
. . .
. . .
. . .
v v v
Second shadow volume pass
glCullFace(GL_BACK);
glStencilOp(GL_KEEP, GL_DECR, GL_KEEP);
.
/ \
/ \
/ \
/ \
/ \
/ \
.-------------.
| |
| 0 0 |
| |
|___|
| |
| 0 0 |
| |
| |
| |
| |
| |
| |
| |
.-------------.
. .
. -1 -1 .
. .
. .
. .
v v
result in stencil buffer
.
/.\
/ . \
/ . \
/ . \
/ 1 . 1 \
/ . \
.------±-----.
| | |
| 0 | 0 |
| | |
|||____
| | |
| 0 | 0 |
| . |
| /.\ |
| / . \ |
| / . \ |
| / . \ |
| / 1 . 1 \ |
|/ . |
.----- .------.
. . .
. 0 . 0 .
. . .
. . .
. . .
v v v
and we draw the scene with lights and the stencil function…
glStencilFunc(GL_EQUAL, 0, 0xffffffff);
or, in my case, I draw a full screen transparent overlay to darken things, and use…
glStencilFunc(GL_NOTEQUAL, 0, 0xffffffff);
which falls down to the same thing (at least in z-pass algorithm).
As you can see in the picture above, the triangle shadow itself.
To overcome this, I have to make the back plane also cast a shadow, in this case we get…
.
/.\
/ . \
/ . \
/ . \
/ 1 . 1 \
/ . \
.------±-----.
| | |
| 0 | 0 |
| | |
|||_____
. | | | .
. 1| 1 | 1 | 1 .
. | . | .
. | /.\ | .
. | / . \ | .
. | / . \ | .
. | / . \ | .
. | / 2 . 2 \ | .
. |/ . | .
. |----- .------| .
. | . | .
.1 | 1 . 1 | 1 .
. | . | .
. | . | .
. | . | .
v v v v v
and then
glStencilFunc(GL_LEQUAL, 1, 0xffffffff);
or, in my case, I draw a full screen transparent overlay to darken things, and use…
glStencilFunc(GL_Greater, 1, 0xffffffff);
Then, unlike Depth pass, it is a requirement to have all your surfaces casting shadows?
Sooo… What Did I fell to understand?
[This message has been edited by oliii (edited 03-01-2003).]
[This message has been edited by oliii (edited 03-01-2003).]