Search code examples
opengledge-detection

Edge detection with Single-Pass Wireframe Rendering


I would like to implement a typical CAD software and therefore need an edge detection algorithm to draw the silhouette of various meshes. Silhouette includes outline, ridges and creases of various objects. Here is an example of a cube created in Blender where the silhouette is made of thick orange lines:

enter image description here

I want to use a geometrical approach where wireframes are drawn on top of the objects and interior lines like diagonals are omitted. The wireframe rendering is described here. In this article, the geometry shader is used to draw the wireframe. It is also explained that one has to set a per-vertex attribute to decide if a line should be omitted or not.

My question is: How could I decide which lines I have to omit? I use OpenGL as rendering API by the way.

EDIT: To clarify, I really want to draw just the edges that constitutes the silhouette but not any diagonals. Here is an example of what I want to achieve:

enter image description here


Solution

  • From your sample pictures I infer that you want to enhance

    • the silhouette edges, i.e. those that belong to the outline of the projections,
    • the salient edges, i.e. those that join two angled faces.

    The former are determined by looking at the orientation of the faces: a face is "facing" when the observer is outside the half-space it delimits and conversely. A silhouette edge is one that belongs to a facing face and a non-facing face. Note that this is a viewer-dependent property.

    A salient edge is such that it joins two faces forming a sufficiently large angle that the connection is considered non-smooth. (The angle threshold is up to you.) This is a viewer-independent property.