O'Reilly logo

OpenGL Insights by Christophe Riccio, Patrick Cozzi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Antialiased Volumetric Lines
Using Shader-Based Extrusion
S
´
ebastien Hillaire
11.1 Introduction
The ability to render lines has always been an important feature in computer graph-
ics. Lines are useful for several purposes. They can be used as a debugging tool to
display vertex normals or to visualize triangles in order to evaluate the complexity
of a scene. Line rendering is also an important feature of CAD applications to help
users to better perceive silhouettes and shapes by emphasizing object edges, or for
GUI information like a wireframe cube around a selected object, gizmos, etc. Lines
are also used in several games such as PewPew [Geyelin 09] or remakes of old games
like Battlezone [Coy 09] where l ine rendering is part of the retro visual style. Finally,
they are also used in GIS and simulation applications for roads, country borders, and
vehicles path.
Nowadays, rendering high-quality antialiased lines is still not a trivial task. Graph-
ics APIs like Direct3D or OpenGL allow the programmer to render basic 2D/3D
lines with a limited width. However, those lines are not properly antialiased on all
hardware [Lorach 05], and there is no perspective effect, i.e., a line always has the
same size on the screen whatever its distance to the viewer. Furthermore, they lack of
an overall volumetric look. McNanmara [McNamara et al. 00] and Chan [Chan and
Durand 05] have proposed methods to render antialiased lines, but they do not fea-
ture any perspective effect. Cozzi [Cozzi and Ring 11] proposed a geometry shader
extruding quads from 3D lines in screen space for high-quality antialiased lines with-
out any perspective effect. Lorach [Lorach 05] has proposed to render volumetric an-
tialiased l ines by using an extended quad in screen space using a vertex shader. Line
163
11
164 II Rendering Techniques
appearance is represented by 16 texture tiles that were interpolated b ased on the
camera position as compared to the line direction. However, the trick used is still
noticeable when viewing a line along its direction.
This chapter presents three methods to render high-quality antialiased lines. The
first method relies on the fixed-width line-rendering possibility of the OpenGL API.
The last two methods exploit shaders in order to extrude geometry around the line
that will be shaded to achieve a volumetric appearance without aliasing.
11.2 Antialiased Lines Using Postprocess
Antialiasing
One existing solution to rendering antialiased lines is to use the OpenGL line primi-
tives with hardware multisampling activated. The selected multisampling quality, 4,
8, or 16 times, will directly influence the required memory and bandwidth. As an
example, 8 times multisampling will require eight samples per pixel instead of one,
eight times more memory, and the execution of a resolve step computing final pixel
color from samples.
Over the last year, researchers have proposed a new way to achieve real-time
antialiasing as a postprocess without requiring huge memory and with a low compu-
tational cost: postprocess antialiasing. A complete overview is presented in [Jimenez
et al. 11]. Basically, these methods use screen-space information such as color, depth,
normals, and geometry to detect edges in the rendered picture and a pply a smar t
blur filter, taking advantage of the hardware linear filtering to reduce aliasing. Of
all the algorithms, FXAA [Lottes 11] is a good choice as it only relies on the color
buffer, and it only needs the luminance information. Another advantage is that the
full shader file provided can be used either in OpenGL, Direct3D, or on consoles,
Without FXAA With FXAA
Figure 11.1. OpenGL line primitives without and with postprocess antialiasing (FXAA).
The green rectangles represent the zoomed-in areas.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required