Conservative Rasterization Sample


Category:  Visuals
Min PC GPU: Fermi-based (GTX 4xx)
Min Tegra Device: N/A

Description

This sample demonstrates the pixel-level effect of enabling the conservative rasterization feature supported in OpenGL. It allows applications to shade every pixel whose area is touched by a fragment, rather than only those touching specific samples.

APIs Used

Shared User Interface

The OpenGL samples all share a common app framework and certain user interface elements, centered around the "Tweakbar" panel on the left side of the screen, which lets you interactively control certain variables in each sample.

To show and hide the Tweakbar, simply click or touch the triangular button positioned in the top-left of the view.

Other controls are listed below:

Device Input Result
touch 1-Finger Drag Orbit-rotate the camera
2-Finger Drag Move up/down/left/right
2-Finger Pinch Scale the view
mouse Left-Button Drag Orbit-rotate the camera
Right-Button Drag Move up/down/left/right
Middle-Click Drag Scale the view (up:out, down:in)
keyboard Escape Quit the application
  Tab Toggle Tweakbar visibility
gamepad Start Toggle Tweakbar visibility
  Right Thumbstick Orbit-rotate the camera
  Left Thumbstick Move forward/backward. Slide left/right
  Left/Right Triggers Move up/down

Technical Details

Overview

This simple sample demonstrates a new rasterization feature introduced in the Maxwell GM20x architecture —conservative rasterization.

Traditional rasterization considers pixels as discrete sample points, and only generates a pixel (fragment) if the sample point is inside the primitive. This means it is possible for thin and edge-on triangles to miss the samples entirely.

Normal rasterization
Figure 1: Normal rasterization (Click to enlarge)

Conservative rasterization generates a fragment if the primitive intersects any part of the pixel area. This generally means that the outline of the primitive is expanded.

Conservative rasterization
Figure 2: Conservative rasterization (Click to enlarge)

Conservative rasterization can be useful for 3D voxelization and generating data structures using rasterization on the GPU. For example, to generate a uniform grid acceleration structure, you want to know which triangles intersect each grid cell. This can be achieved by rendering the triangles at the grid resolution with conservative rasterization, and storing the triangle indices using a linked list.

Conservative rasterization also works with line and point primitives.

Lines with normal rasterization
Figure 3: Lines with normal rasterization (Click to enlarge)

Lines with conservative rasterization
Figure 4: Lines with conservative rasterization (Click to enlarge)

It is worth noting that there is limited precision available in the hardware to determine if a pixel intersects a primitive. The test is conservative, in that pixels may sometimes be identified as intersecting, even if with perfect precision they do not, but pixels will never be excluded if they do actually intersect the primitive.

Note that conservative rasterization can also be achieved on older hardware using a combination of a special geometry and pixel shader as described in the GPU Gems 2 article below, but in many cases this incurs considerable performance overhead. Hardware conservative rasterization has roughly the same performance as normal rasterization (it generates more fragments, and so might be slightly slower).

References

  1. Conservative Rasterization, GPU Gems 2.
  2. Conservative and Tiled Rasterization Using a Modified Triangle Setup

 


NVIDIA® GameWorks™ Documentation Rev. 1.0.220830 ©2014-2022. NVIDIA Corporation and affiliates. All Rights Reserved.