silhouette algorithms

Does anybody know a good place to look for opengl implemented algorithms to find silhouette edges (edges shared by one back and one front face).
Thanks

This isn’t really an opengl issue, more of a geometry processing issue. It’s quite easy to find the sil edge. For each edge in the model, if one of the triangles (of the two that share this edge) is facing the light and the other triangle (which will be an adjacent triangle obviously) is not facing the light, then this edge is a possible silhouette edge. If you want to see code check out nvidia’s infinite shadow volume demo by cass. I also have my older infinite shadow volume code online here: http://sirknighttg.tripod.com/projects/shadow.zip . My code is pretty simple and only works with my cube model I have supplied but it still shows this technique anyway. I have code for doing a loaded md2 model but it’s not online yet.

EDIT: link problems.
EDIT2: GRRR! My link isn’t working for me here. WTF. I logged into my tripod account and it IS there. Maybe it just has something to do with the computers here at the university.

-SirKnight

[This message has been edited by SirKnight (edited 10-25-2002).]

Now that I think about it, you can get OpenGL to do edge detection but it depends on what you want to do with the edges. Here is a demo http://www.delphi3d.net/download/edgedetect.zip . I dont know what you need the sil edge for, shadow volumes im assuming, if not then slap me. The technique above I don’t think (I could be wrong) that you can use that for shadow volumes.

-SirKnight

Thanks for the pointers SirKnight. Yes I need it for shadow volumes

For each face, find neighbor faces (for each vertex, save a list of faces using it, and then for each face, check list of face at each vertex for neighbors that uses another of our vertexes).

For each face, if toward light, flag it, and flag its vertexes

For each flagged vertexes, compute its 2 positions (original and projected)

For each flagged face, display caps. if any neighbor face is not visible, also display the corresponding edge of the shadow volume

Easier said than done.

Easier said than done.

Well…kindof. For me it was pretty easy done for the most part. The biggest problem I had was I didn’t store the normals in my data structure correctly. The only part that required the most thinking (and even then that was about 15min or so) was comming up with the algorithm to find and setup an adjacency graph for each triangle.

Ok well now I know you need it for shadow volumes then you dont need to worry about the link from delphi.net too much. It might be worth looking at it cuz its cool though.

BTW, did the link to my shadow code work for you?

-SirKnight

Originally posted by SirKnight:
[b]BTW, did the link to my shadow code work for you?

-SirKnight[/b]

Yeah, it works now.

Thanks guys. Somebody told me the easiest way of finding silhouettes might be using stencil buffer.

If you need silouhettes of GEOMETRY then stencil clearly isn’t your choice, as that works on PIXELS.

To generate shadow volume edges, you need to inspect the geometry somehow. Either have a pre-computed data structure with edges containing triangle pointers, and face normals per triangle, or insert slivers between all triangles with separate face vertex normals and extrude all (new) vertices that face away from the light.

If you are interested in doing shadow volumes in a vetex program (shader) then you would need to use the second method jwatte mentioned; the slivers between all triangles and whatnot. Nvidia has a demo of this incase you wasn’t aware. You dont have to use a vertex program for this method of course.

-SirKnight