Wireframe Drawing

With smooth lines and no depth buffer artefacts!

Downloadable demo is here

Drawing a triangle mesh as wireframe with hidden surface removal is something we know how to do ... right?

Yes, that is right. There is a well established traditional method: First draw the filled polygons. Next, using a depth offset, draw the wireframe. The offset makes sure that the filled poly's don't obscure the wireframe. There are variations of this method, but the fundamental idea is the same.

Unfortunately, the wireframe drawing will look jaggy, and artefacts creep in because of differences in depth computation for lines vs triangles.

Our Method

We have developed a new method for wireframe drawing which is single pass. Essentially you just draw the triangle and then switch from fill color to wire color if the fragment being drawn is within a given distance of the edge.

There is more to it, but it is straightforward to implement. On a gamer card, it beats the traditional method (hands down) with respect to performance, and it is trivial to extend the method so it draws smooth prefiltered lines. We can also fade the lines as a function of distance as shown on the Happy Buddha model above.

(click to enlarge)

Many other extensions are also straightforward. For instance, the method works on quads with a few changes, and it is very easy to do lines of varying thickness. We can also remove the interior of the polygons in order to do haloed lines. In fact, putting all of this together, we can draw something that looks like a nice pen and ink illustration as shown in the figure to the right.

(click to enlarge)

There are drawbacks but they are few, especially on hardware which supports Direct3D 10/OpenGL 3.0.

Further Information

If you are interested, we have a SIGGRAPH sketch and a short movie on the method. Furthermore, the method is described in two papers:

http://www.imm.dtu.dk/Om_IMM/Medarbejdere.aspx?lg=showcommon&id=219956
http://www.imm.dtu.dk/Om_IMM/Medarbejdere.aspx?lg=showcommon&id=223949

The publication database entry for the sketch is:

http://www.imm.dtu.dk/Om_IMM/Medarbejdere.aspx?lg=showcommon&id=201184

Also available are the slides from the presentation, and of course the demo. The demo is in source format and should work on Linux, Win32, Mac.

NVIDIA Direct3D 10 Implementation

NVIDIA has made an implementation of our method which is available as one of the NVIDIA Direct3D SDK 10 Code Samples.

Maintained by: Andreas Bærentzen, jab 'at' imm.dtu.dk