Volumetric lines 2
The ability to render 2D/3D lines has always been an important feature in computer graphics. Indeed, lines are very useful for several purposes. First, it can be used to visualize triangles in order to evaluate the complexity of a scene or as a debugging tool to display vertex normal. Secondly, line rendering is also used in CAD applications to emphasize objects edges for the user to better perceive objects silhouette. Last but not the least, it is used in many video games such as PewPew  (see Figure 1) or remake of old games like Battlezone.
Figure 1: PewPew iPhone game . (Screenshot Courtesy of Jean-François Geyelin)
Left, traditional lines rendering and, right, using anti-aliased lines .
Graphics API like DirectX or OpenGL allow rendering simple 2D and 3D lines with a customable width. However, those lines are not properly anti-aliased on all hardware  and are not rendered in a perspective correct way. Furthermore, this type of line lacks volumetric look and it is not possible to finely control their appearance. McNamara , and the GPU based version , proposed a method to render anti-aliased lines but it does not support the perspective effect. Lorach  proposed to render volumetric anti-aliased lines by an extended quad in screen space using vertex shading feature of graphics card. However, line appearance was represented by 16 texture tiles and interpolation between them become visible when progressively viewing a line along its direction.
More recently,  and  proposed a similar trick to render high quality anti-aliased lines. These methods are really fast (only using a vertex shader) and yield good looking results. Also, line width and appearance can be easily tuned. The method proposed by  has been successfully used in the iPhone game PewPew  (see Figure 1) resulting in a better looking game than using traditional line rendering. However, as in , when lines are viewed along their direction, the trick used to achieve a volumetric look becomes visible (Figure 2): this is especially true for wide lines. Furthermore, none of these methods support thickness based shading to render, for instance, laser beam or glowing neon lights without a post-process Gaussian blur.
Figure 2: View of a line along its direction.
Left, the trick used in  and  is visible. Right, using our method, the line is not distorted.
Anti-aliased Volumetric Lines
We propose two new methods to render capsule-like lines with any width and for any point of view. The first method A allows the rendering of high quality anti-aliased lines from any view, even along the line direction. We propose a second rendering method B, more time-consuming, in order to allow rendering of volumetric lines from any point of view. This second method allows using thickness based shading taking into account intersections with the virtual environment.
Figure 3: computation of the line bounding box and computation of intersection with a capsule
Both method A and B require the generation of an Object-Oriented Bounding-Box (OOBB). This is achieved using a geometry shader taking as input a line segment [V1, V2] and outputting two triangle strips (in green and blue on Figure 3-1). To extrude a bounding box from a line, we first compute an orthonormal basis having the X axis parallel to the line direction. The Y and Z axis are then generated using geometric properties: we do not care about their direction since a capsule is symmetrical along its major axis. Since each line is represented by a capsule, the OOBB has specific dimension presented on Figure 3. For each vertex of the OOBB, the view direction is computed and interpolated per pixel. It will then be used to compute intersection with the line in the fragment shader.
Method A allowing the rendering of high-quality anti-aliased lines that can be viewed from any view direction (Figure 4):
Figure 4: left, rendering lines with method; right, line appearance and width can be changed.
Method B allows the rendering of volumetric lines with correct intersection with the virtual environment using thickness based shading that can be viewed from any view point and direction (Figure 5):
Figure 5: rendering lines with method B: thickness based shading of volumetric lines
Figure 6: left, intersection with camera; right, use case: emphasizing edges of a 3D model.
Both methods A, for shading, and B, for attenuation based on environment and camera intersections, can be easily combined as shown on Figure 7. Using method A+B allows the rendering of high quality anti-aliased volumetric lines with correct intersection with the virtual scene from any view direction.
Figure 7: Left, using only method A leads to intersection artefact.
Right, correct intersections by combining method A and B.
It is possible to render soft particle by modifying the method B. First, you would need to replace the OOBB around the line with an AABB around a point and compute a single intersection with a sphere and the environment depth map to get the thickness of the spherical soft particle. Finally, you would just need to apply blending based on the thickness of the particle.
We have proposed two new methods to render perspective-correct high quality anti-aliased lines (method A) or volumetric lines (method B). It is also possible to combine both methods A+B in order to render high quality anti-aliased volumetric lines. We believe that this method could be used to render lines in CAD applications and games as it only requires the binding of our shader when rendering normal lines and some textures (gradient for method A and view space depth for method B).
1. PewPew, http://pewpewgame.blogspot.com/2010/01/volumetric-lines-2.html, 2009.
2. Stephen Coy. Simplified High Quality Anti-aliased Lines by Stephen Coy, ShaderX7, 2009.
3. Tristan Lorach, CG Volume Lines, nVidia SDK 9.52 code samples, http://developer.download.nvidia.com/SDK/9.5/Samples/samples.html#cg_VolumeLine, 2005.
4. Robert McNamara, Joel McCormack, and Norman P. Jouppi. "Prefiltered Antialiased Lines Using Half-Plane Distance Functions." Proceedings of the ACM SIGGRAPH/EUROGRAPHICS Workshop on Graphics Hardware, S.N. Spencer, Ed. HWWS'00, 2000.
5. Eric Chan and Frédo Durand, Fast Prefiltered Lines, GPU Gems 2, http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter22.html, 2005.
6. Sébastien Hillaire, Volumetric lines, http://sebastien.hillaire.free.fr/demos/simplevolumeline/vline.htm, 2007