Jump to content
  • Advertisement
Sign in to follow this  
Relfos

OpenGL Stencil volumes troubles

This topic is 4490 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Today I implemented stencil shadow volumes into my engine. They worked fine when I create the volumes as triangles and draw it with glDrawArrays(GL_TRIANGLES,0,VertexArray) (Left Image) Now I decided to change it to quads, to reduce geometry count, render it with glDrawArrays(GL_QUADS,0,VertexArray) and it also works, with a litle problem. Those strange lines appear, showing the volumes outline, almost if I rendered in wireframe mode. (Right image) I really need to get this working with quads. I remember in D3D there was a setting to disable last pixel of each polygon edge, is there something similar in OpenGL? Because I think the problem is that the quads edges are overlapping each other, thus messing up with the stencil algoritm. I already tested in two different pcs, with different graphic cards and the result is the same. Image Hosted by ImageShack.us [Edited by - Relfos on July 9, 2006 7:04:29 AM]

Share this post


Link to post
Share on other sites
Advertisement
Quote:

to reduce geometry count


Is there really a need for that ? AFAIK, quads are rasterized as 2 triangles anyway, you are only saving on the bus transfers, which is negligable. Although, if you really want to, you could do the extrusion of the shadow volume on the GPU.

Apologies for this remark, since I dont actually know the answer, but it seems to me like its a driver/chip problem.

Regards,
DP

Share this post


Link to post
Share on other sites
What were the graphics cards/drivers you tested on? Can you try running NVIDIA's "Robust shadow volumes" code sample on the same setup and see if the lines are visible there too?

Share this post


Link to post
Share on other sites
hmmm. try stencilwrap. instead of GL_INCR GL_INCR_WRAP
i think this will avoid the stencil problems.

Share this post


Link to post
Share on other sites
Sorry, I was a stupid bug, when I was extruding the shadow volumes, I was creating the quads with wrong vertex order, and that was the cause of the bug. Works fine now.

Quote:
AFAIK, quads are rasterized as 2 triangles anyway, you are only saving on the bus transfers, which is negligable.


Is that true, so even when I have lots of shadows in the scene there's none or little advantage in using quads? Since my quads only use 4 vertices per extrusion and triangles use 6, its something like a 30% save in geometry, so I thought that was a good thing to do.

Another thing I want to ask, pratically every article/tutorial about stencil shadows tells that we need to render our scene without lights first, and then render it again for each light scene. But I've found a demo that only renders the scene once, with lights on, then in the end it draws a black quad over the scene instead of rendering it again
This is the method I implemented, since rendering the scene only once seems a good thing, does this has any advantages/disavantages comparing with the other most common method?

Quote:
hmmm. try stencilwrap. instead of GL_INCR GL_INCR_WRAP
i think this will avoid the stencil problems.

Hmmm, using this caused something strange. When I enter inside a shadowvolume the whole scene shadows get inverted. I heared something about capping the shadow volumes, but that seems very complicated, another easy way to fix this?

Share this post


Link to post
Share on other sites
this depends on the algorithm you use. zfail or zpass. there is a really good article on this here!

Share this post


Link to post
Share on other sites
Hmmm, my algoritm is different from everything I see in articles, is based on a demo I found in a site, but I think the algoritm is or is based in zpass. Works like this:

1º Draw normal scene geometry with all lights on
2º For Each shadow volume
Draw front faces and increment stencil when zpass
Draw back faces and decrement stencil when zpass
3º Draw fullscreen black quad where stencil>=1

I already found one flaw in this method, when drawing scenes with fog, the shadows are not affected by fog. However, I already found a way to hack around this problem. Other than that, I seems to work ok, so why everybody says to draw multiple passes of the scene?

About the volume capping I already read an article about it and seems easier than I thought. But something still bothers me.
Quote:
Remember that shadow volume capping is only necessary for the depth-fail technique.

I read this in an article here in gamedev.net, however I'm using zpass, and I'm having a problem when camera enters a volume. So I don't understand, is there other alternatives to volume capping?

And about the 30% vertex count saving? Is it worthless?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!