pouët.net

Go to bottom

Polygon edge detection algorithm

category: general [glöplog]
 
I only know that one where you run all the faces facing the camera and insert the edges to a list or remove them if they're in the list... it may not be exactly this but it's easy to get there.

Is there any faster algoritmh that's not too hard to implement?
added on the 2008-01-05 06:34:56 by xernobyl xernobyl
"polygon edge detection" should be "mesh edge detection" or maybe "mesh sillouette" or something like that.
added on the 2008-01-05 06:37:00 by xernobyl xernobyl
Do you want the mesh silhouette as seen from an arbitrary point?
If so you can use the same edge-finding algorithms that are used by shadow volumes.
added on the 2008-01-05 11:14:50 by datsua datsua
Where the "arbitrary point" point is the camera ;)
added on the 2008-01-05 11:15:20 by datsua datsua
for shadow volumes we used to do this:
pregenerate a winged edge array (stores the edge and the two polygons connected to it - im assuming manifold meshes - i.e. only up to 2 polygons can be connected to an edge).
check each edge to see if one of the polys faces away from the camera and one faces towards (dot poly normal and camera to first vertex in your case.. or light->first vertex for shadows). those are the ones you need.
added on the 2008-01-05 12:40:05 by smash smash
additional property that may or may not improve speed: silhouette edges for a 2-manifold mesh form closed loops. so after you found a silhouette edge, you can just test the edges incident to your current edge's "end" vertex.

+: traverses the silhouette edges "in order", which is useful to have sometimes.
-: tends to be slower (per-edge) than the straightforward method because of the increased amount of pointer chasing.
added on the 2008-01-05 13:54:38 by ryg ryg
I dont believe there's a faster one.
added on the 2008-01-05 14:05:49 by Oswald Oswald
just remember that you don't need to normalize your normals or camera->vertex vectors here, it's only the signs what you care about. Ah, for directional lights (sun) it's faster of course - you only need to compare the signs of the (camera space) z components of the face normals.
added on the 2008-01-05 15:12:14 by iq iq
oswald, well, there's clustered backface culling, but i doubt it would help much with typical meshes.
added on the 2008-01-05 15:20:31 by ryg ryg
It looks as if the algorithm you are talking about is O(n), so probably there no faster algorithms
added on the 2008-01-05 15:32:28 by texel texel
By other hand, if it is for rendering silouettes lines (as in some NPR renderings), maybe you can do it render size dependant and not mesh dependant, rendering the scene with flat colors for every mesh without antialiasing and then checking for adjacent pixels of different color...
added on the 2008-01-05 15:39:35 by texel texel
no asymptotically faster algorithm, you mean. there's a world of difference :)

besides, an optimal algorithm would be O(k) (where k=number of silhouette edges), not O(n) (n=number of edges in mesh). i don't think such an algorithm exists, but you might be able to get something like O(k+log n) if:

  • you use something like hierarchical clustered backface culling to quickly reject groups of all-back/all-front faces.
  • you traverse along silhouette loops.
  • you find a quick way to find "seed edges" to start traversing from. this is probably the clincher - i don't think you can narrow the candidate edge list down to C*(k+log(n)) edges (C independent of the mesh) with just clustered backface culling, at least not for general 2-manifold meshes.

then again, as i said earlier, this problem is mostly academic, because i very much doubt the overhead for CBC is going to be worth it in practice.
added on the 2008-01-05 15:44:24 by ryg ryg
but ryg, since you are rotating, you would need to regenerate the hierarchy... and it should need O(n) I think...
added on the 2008-01-05 15:45:50 by texel texel
Wait wait, sorry, I've just understand what you said ryg... yes, maybe there is an algoritm like that :)
added on the 2008-01-05 15:50:28 by texel texel
ermm... I'm thinking about it... and it looks as if anyway, in the worst case it is o(n)...
added on the 2008-01-05 15:55:31 by texel texel
A question: have you used something like a thresold in the z-buffer between adjacet pixels for drawing silouttes in NPR rendering?
added on the 2008-01-05 15:58:26 by texel texel
texel: I really want the edges lines, not the pixel data :)
I'm still not sure what I want to do with it.
added on the 2008-01-05 23:35:13 by xernobyl xernobyl
added on the 2008-01-06 03:07:53 by bdk bdk
Quote:
We found that for small models, under 10,000 polygons for our hardware, brute force silhouette extraction is easy
to implement and runs nearly as fast much more complex methods.
added on the 2008-01-06 03:23:19 by xernobyl xernobyl
nice review broderick :) ty
added on the 2008-01-06 05:22:54 by makc makc
JustFakeItAndNooneWillNotice(tm)
added on the 2008-01-06 05:48:07 by kusma kusma
xernobyl, just some silly idea: draw the vertices alone to some 2d point data structure and do the barricading sleeping tigers algorithm. no clue about speed, can't be arsed to figure it out.
added on the 2008-01-06 09:36:48 by skrebbel skrebbel
Quote:
for shadow volumes we used to do this:
pregenerate a winged edge array (stores the edge and the two polygons connected to it - im assuming manifold meshes - i.e. only up to 2 polygons can be connected to an edge).
check each edge to see if one of the polys faces away from the camera and one faces towards (dot poly normal and camera to first vertex in your case.. or light->first vertex for shadows). those are the ones you need.

note: hehe, I have the very same algorythm in karate, this is for sure the thing to do for software rendering. here i an example of rendering with black polygons for edges:

BB Image
Note the edge polygons alo need a "normal vector" from the shape polygon, for the stroke width. You could re-link the whole edges to find the whole contour closed polygon, but re-using the 3D vertex's normal gives quite good result (and need no extra "asymptotically" shit ;)

*free ad*: karate makes it possible to re-use any kind of texture rendering objects for the edges.(you just patch a texture object with some other texture object used as edge renderer) :)
added on the 2008-01-06 11:27:56 by krabob krabob
Quote:
for shadow volumes we used to do this:
pregenerate a winged edge array (stores the edge and the two polygons connected to it - im assuming manifold meshes - i.e. only up to 2 polygons can be connected to an edge).
check each edge to see if one of the polys faces away from the camera and one faces towards (dot poly normal and camera to first vertex in your case.. or light->first vertex for shadows). those are the ones you need.

trivium: build "strips" of winged edges (first polygon on next edge is second triangle on previous edge) and get twice the speed.
added on the 2008-01-08 22:40:18 by hfr hfr

login

Go to top