[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Shadow volumes
Hey people,
I'm having a bit of trouble trying to implement a shadow volume
technique using OpenGL, if any of you could give me a hand, I'd
appreciate it a lot :)
Thing is, I have this article from Gamasutra entitled "Real-Time Shadow
Casting Using Shadow Volumes", by Jason Bestimt and Bryant Freitag, in
which they describe the following procedures (the examples in the
article use Direct3D) - I'll also put a copy of my code for the
stenciling in OpenGL:
quote: "First, the volume is rendered into the scene, incrementing the
stencil buffer value for every pixel that passes a normal z depth test."
Note that depth test is enabled and writing to depth buffer is disabled
-> glStencilFunc(GL_ALWAYS, 0x00, 0x00);
-> glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
Render volume...
quote: "Next, the cull mode (...) is reversed, and the volume is
re-rendered. The stencil buffer is decremented for every pixel that
again passes a normal z depth test."
We still don't write to the depth buffer, only do the normal depth test
-> glStencilFunc(GL_ALWAYS, 0x00, 0x00);
-> glStencilOp(GL_KEEP, GL_KEEP, GL_DECR);
-> glFrontFace(GL_CW);
Render volume again...
quote: "After this (...), an alpha blended quad is rendered to the
entire screen. The graphics card is set up to render only the pixels in
the stencil buffer that have a positive value associated with them.
(...) The graphics card can set the stencil buffer to zero every time
the stencil check passes and a shadow pixel is drawn."
Rendering the quad with depth test disabled and depth writing also
disabled
-> glStencilFunc(GL_GREATER, 0x00, 0x00);
-> glStencilOp(GL_KEEP, GL_KEEP, GL_ZERO);
Render quad...
That's about it. The initial test I'm doing is not using an alpha
blended quad, just a simple "solid" one, I just want to see if the
process is working, which, as you might have already guessed, is not :)
Any clues on this? Am I doing this all wrong?
Thanks in advance,
Miguel A. Osorio.