9.2. Antialiasing

The SoGLRenderAction SoGLRenderAction SoGLRenderAction class also provides methods for antialiasing, techniques used to eliminate or reduce jagged lines and make objects drawn on the screen appear smooth. You can choose from two antialiasing methods:

  • Smoothing , which is relatively “cheap” in terms of processing time. Smoothing applies to lines and points only.

  • Using the accumulation buffer , which requires more processing time than smoothing but applies to the whole image and results in superior antialiasing. This technique requires an OpenGL window that supports an accumulation buffer.

Method 1: Smoothing

Use the SoGLRenderAction::setSmoothing() method to turn on smoothing. The isSmoothing() method returns the current state of the Smoothing flag. This form of antialiasing is for lines and points only. Because it requires alpha or additive blending, Inventor changes the transparency type if necessary when you turn on smoothing.

Method 2: Using the Accumulation Buffer

Normally, Inventor performs one rendering pass each time a render action is applied. You can use the SoGLRenderAction::setNumPasses() method to increase the number of rendering passes for accumulation buffer antialiasing. Inventor then renders the scene multiple times, moving the camera a little bit each time, and averages the results. The more times Inventor renders a scene, the better the antialiasing. The trade-off is that increasing the number of passes also increases the amount of time required to render the scene. The number of passes can be from 1 to 255, inclusive. Specifying 1 disables multipass antialiasing.

In addition, if you specify TRUE for the SoGLRenderAction::setPass- Update() method, the current contents of the accumulation buffer are copied into the currently active drawing buffer after each rendering pass. This technique slows things down but allows you to watch what happens between the incremental rendering passes. The default for setPassUpdate() is FALSE.

Tip: Use the SoXtRenderArea::setAntialiasing() method to turn on smoothing and to specify the number of passes for accumulation buffer antialiasing. You can specify either smoothing or accumulation buffer antialiasing, or both.

Full-Scene Antialiasing

Full-scene antialiasing (FSAA) is a new way to do antialiasing (eliminating or reducing jagged lines and making objects drawn on the screen appearing smooth) in Open Inventor.

Effect of antialiasing on the display quality. Left (aliased), right (antialiased)

Figure 9.1. Effect of antialiasing on the display quality. Left (aliased), right (antialiased)



The old multipass antialiasing method available in Open Inventor 4.0 can still be used, but we strongly recommend using full-scene antialiasing when it’s available. FSAA has the advantage of being hardware accelerated and does not require rendering the scene multiple times.

Activating Antialiasing

Availability of FSAA depends on your graphics hardware and driver.

FSAA is supported via the ARB_multisample OpenGL extension, which, in turn, requires the ARB_pixel_format OpenGL extension.

FSAA is enabled using the SoXtGLWidget::setFullSceneAntialiasing() method. This method allows you to globally enable or disable FSAA and to specify the quality level that will be used for rendering your scene graph, and to optionally initialize the antialiasing shape filter. The quality and filter concepts are discussed below.

Then, during scene graph traversal, the SoFullSceneAntialiasing SoFullSceneAntialiasing SoFullSceneAntialiasing node can be used to activate or deactivate the antialiasing for a specific part of the scene and/or to change the antialiasing shape filter.

Antialiasing Quality

The quality level of the FSAA rendering is based on the number of samples available on your graphics hardware and driver.

FSAA is done by sampling all primitives multiple times at each pixel.

Antialiasing pixel sampling.

Figure 9.2. Antialiasing pixel sampling.



NVidia graphics hardware can support number of samples * 2 levels of quality (assuming the NV_multisample_filter_hint OpenGL extension is available). For more info, refer to the document OpenGL Pixel Formats and Multisample Antialiasing by Sébastien Dominé, NVidia Corporation, 2001.

Because the number of samples doesn’t vary in the same way on all graphics hardware, the quality field doesn’t specify the number of samples used for antialiasing computation, but rather a value in the interval [0..1], where 0 is the lowest quality level and 1 is the highest quality level.

The quality level can be set by using the Graphics Preferences and Configurations as described in Section 2.7, “ Graphics Preferences and Configurations”.

Antialiasing Shape Filter

The SoFullSceneAntialiasing SoFullSceneAntialiasing SoFullSceneAntialiasing property node allows you to select what kinds of shapes will be antialiased. When FSAA is enabled, the default filter is ALL, meaning that all shapes will be antialised. If you want to disable FSAA for particular kinds of shapes, you can use SoFullSceneAntialiasing SoFullSceneAntialiasing SoFullSceneAntialiasing to do so.

Antialiasing depends on three factors:

  • The FSAA shape type (points, lines, polygons, text),

  • The current draw style,

  • The current antialiasing filter.

The shape type can be retrieved by a call to SoShape::getShapeType() .

During rendering, the following rules are applied to determine if the current shape must be rendered antialiased or not:

Shape type Draw style Filter Antialiased

POLYGONS

FILLED

LINES

POINTS

POLYGONS

TEXT

ALL

 

 

X

 

X

LINES

LINES

POINTS

POLYGONS

TEXT

ALL

X

 

 

 

X

POINTS

LINES

POINTS

POLYGONS

TEXT

ALL

 

X

 

 

X

Shape type Draw style Filter Antialiased

TEXT

FILLED

LINES

POINTS

POLYGONS

TEXT

ALL

 

 

X

X

X

LINES

LINES

POINTS

POLYGONS

TEXT

ALL

X

 

 

X

X

POINTS

LINES

POINTS

POLYGONS

TEXT

ALL

 

X

 

X

X

All text strings are antialiased when the SoFullSceneAntialiasing SoFullSceneAntialiasing SoFullSceneAntialiasing filter is set to TEXT Otherwise, antialiasing is done based on the current draw style.

Shape type Draw style Filter Antialiased

LINES

FILLED

LINES

LINES

POINTS

POLYGONS

TEXT

ALL

X

 

 

 

X

POINTS

LINES

POINTS

POLYGONS

TEXT

ALL

 

X

 

 

X

Shape type Draw style Filter Antialiased

POINTS

FILLED

LINES

POINTS

LINES

POINTS

POLYGONS

TEXT

ALL

 

X

 

 

X

How to read these tables: Suppose you want to antialias an SoCube SoCube SoCube object. SoCube SoCube SoCube is of type POLYGONS, so you would refer to the POLYGONS shape type in the tables. Then if the current draw style is FILLED, the two ways to enable antialiasing are to set the SoFullSceneAntialiasing::filter to POLYGONS (the SoCube SoCube SoCube type) or to ALL.

The antialiasing of certain primitives may be undesirable. For example, bitmap text strings (SoText2 SoText2 SoText2 , …) may be "blurred" when they are antialiased.