I have posted a question about shadow volume (ZFAIL) some times ago: http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/010323.html
I think i have found the source of my problem with shadow volume, but i don’t know how to solve it.
I think the problem comes from:
_ When a mesh (mesh1) is inside the shadow volume of another mesh (mesh2), mesh1 is in front of the some part of the back side of the shadow volum of mesh2. And mesh1 increase the stencil buffer (because of the fail of the depht test).
I have not find any documentation which spoke about this problem.
Maybe i do not use shadow volume in the good way. But in theory, my problem comes from the algo i use and not from the way i code it.
How can i solve this problem?
I have read this article. it is a very good article.
I have already used it to solve the problem of clip plane.
I just use the basics of Zfail algo (increase and decrease of stencil buffer) and caps.
Do i have to use something else?
Because the other technics of this article seems to speak just about speed optimization and i don’t need it for the time being.
I have read it again, and now i don’t understand why my program dosen’t work
My idea was stupid, because if my mesh is inside the volume of another mesh, it is normal for it to be shadowed.
It’s strange because the shadow bugs move when my camera moves, as you can see in this demo:
I compute shadow for all meshes of my scene in the same time (like one mesh).
Do i have to compute my shadow in different pass for every meshes? Do i have to make some difference between the caster and receiver?
Have you read "Robust stencil shadow volumes" on the nVidia site?
It might be that you are not setting your stencil writes up correctly (so volumes within volumes would be affecting each other). From memory above paper mentions this and has the necessary code to overcome it. (Apart from the fact you can just go through the code in the document and end up with zfail that works)
[This message has been edited by rgpc (edited 10-23-2003).]
Make sure you disable depth writes when drawing the stencil volumes. glDepthMask(GL_FALSE) is your friend.