Stencil shadow volumes - constraints on models too delicate?

Started by
3 comments, last by Pottuvoi 11 years, 3 months ago

I am working on my first implementation of Stencil Shadow volumes and I have to say I'm a bit skeptical. I read this tutorial (and the tutorial the follows) and I understand the concept, the math and the geometry quite well, but the tutorial did not say if there are any constraints on the types of models you can render. Certainly I can see that any model involvng transparrencies would be bad news, but no information about the general shape.

In particular, the algorithm in the tutorial assumes that a given edge on a triangle will always be adjacent to another triangle. If you peek at my model below, you can see that the low end of his shirt (that hangs down beneath his belt) has no adjacencies at the edge. So I decided for this case that when an edge on a front facing triangle doesn't have an adjacent triangle at all, it is assumed to be a silohuette edge. It appears to work fairly well. The bottom edge of his shirt was marked as an edge appropriately. The model features plenty of such edges, especially at joints of the major body parts. Are stencil shadow volumes even expected to work for a model such as this? If no, what contraints are needed on the model for this to work?

[attachment=13238:stencil_shadow_volumes.png]

My other question, here I am rendering the silohuette edges of the mesh in bind-pose, from the viewer's location (silohuette edge calculation all done in CPU at the moment, moving to GPU later). I have it set to rotate as it is displayed. As the model rotates, a very small but noticable number of edges tend to flicker (marked in yellow in the attached image). Sometimes little sections of edges disappear. The outisde outline seems to always be there, but various other edges flicker in and out as it rotates. Will such minor variations in the silohuette edges cause noticable artifacts when rendering the shadow volume?

In case someone asks,

1. I have properly computed and checked my indices to make sure I am retrieving adjacent vertices.
2. I consider an edge a silohuette edge if its triangle is front facing, and its adjacent triangle is back facing OR if there is no adjacent triangle.
3. I consider an edge front facing if (eyeLocation - edgeVertex0) dot faceNormal > epsilon. I have tried adjusting epsilon but it does not appear to help any of the flickering edges.

Some advice would be most appreciated!


Advertisement

This might be unrelated to your silhouette edge finding problem, but usually, shadow volume meshes must be "water-tight" -- i.e. the mesh must form a completely closed geometry. Some modelling tools have helper functions to help close off a mesh like this.

For example, excuse my bad mspaint drawing of a green arm connecting to a blue glove...

Often these kinds of connections will have gaps that can be seen at certain angles (1st image), which is bad.

The easiest fix for an artist is just to close off the 'outer' shape (the glove here), but leave the other one open, which is bad (2nd image).

You either have to close off both (3rd image), or properly weld them together (4th image).

DEr7b.png

Also, IIRC there's different constraints on your models depending on which stencilling technique you choose (there's many ways to render shadow volumes using the stencil buffer). It may be that some of these techniques tolerate non-water-tight meshes while other's don't...

Thanks for that speedy reply, Hodgeman. No, that is exactly what I am asking about. I was afraid that a non-watertight (i guess the proper term is 'non-Gaussian') surface might mean bad news. :\ Moreover, my model appears to be just like the drawing second from the top that you made. That's depressing! sad.png

I wonder what I should do. I don't have an artist helping me and only work with models I purchase from Turbosquid, so I am kind of at a loss for how to proceed...

(edit)

So this article describes a modification to the algorithm for low quality, 'non-two manifold' meshes (Hey we now have three names for them!). Essentially it says to do exaclty what I'm doing with the edges that don't have neighbors. However! They also render silohuette edges between faces that switch from back-facing to front facing (as opposed to just front facing to back facing). I'll try rendering the silohuette edges this way and post a screenshot.

There is a better algorithm for producing shadow volumes. Check out this paper: http://hungryspoon.com/PX_web/paper/paper.pdf

Not sure why it isn't more commonly known, I implemented it years ago in my hobby engine and it worked great. I didn't have to worry about the meshes at all, if it looked solid from the lights point of view it would cast a proper shadow.

___________________________________________________David OlsenIf I've helped you, please vote for PigeonGrape!

you also might want to check research found here.
http://graphics.cs.lth.se/research/shadows/

They have many papers on stencil shadows, including a good way to do area shadows with correct penumbra.

And source code as well..

This topic is closed to new replies.

Advertisement