Conservative Rasterization Sample
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.
Shared User Interface
The Graphics 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.
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.
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.
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.
Figure 3: Lines with normal rasterization (Click to enlarge)
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).