What is it?
Conservative raster is a cool new feature that came along with NVIDIA’s new Maxwell architecture, which means it is accessible today on GTX9X0 and better boards. It allows rasterization to generate fragments for every pixel touched by a primitive. This post shows how to enable the feature, and highlights a couple of example use cases: ray traced shadows and voxelization.
Conservative raster produces fragments for every pixel touched by a primitive, and that holds true even if no sample location is covered. However it should be pointed out that primitives with zero area will still be culled. Figures 1 to 4 demonstrate the effect of enabling this feature.
Figure 1: Solid Fill - Conservative Raster OFF
Figure 2: Solid Fill - Conservative Raster ON
Figure 3: Wire Frame - Conservative Raster OFF
Figure 4: Wire Frame - Conservative Raster ON
How can it be enabled?
Use the NVIDIA NvAPI to create an ID3D11RasterizerState, the interface for this is shown below:
NvAPI_D3D11_RASTERIZER_DESC_EX NVAPI_RS_DESC; NVAPI_RS_DESC.ConservativeRasterEnable = TRUE; // Enable conservative raster NvAPI_D3D11_CreateRasterizerState(pD3D11Device,(const NvAPI_D3D11_RASTERIZER_DESC_EX*)&NVAPI_RS_DESC,&m_pConservativeRaster);
Direct3D11.3 & Direct3D12
These future Direct3D API’s will include full support for this feature
Use the GL_NV_conservative_raster extension.NVIDIA also has an OpenGL GameWorks SDK sample demonstrating how to set up Conservative Rasterization.
Is it possible to achieve Conservative Raster without HW support?
Yes, it is indeed possible to do this, and there is a very good article describing it here.
Essentially it involves using the Geometry Shader stage to either:
a) Add an apron of triangles around the main primitive
b) Enlarge the main primitive
However both approaches add performance overhead, and as such usage of conservative rasterization in real time graphics has been pretty limited so far.
So what can I do with it?
There are no doubt many applications for the conservative raster, but in this article I’d like to highlight a couple of interesting usage cases:
Ray Traced Shadows
An interesting approach to ray tracing that avoids the use of bounding volume hierarchies, is to store primitives in a regular grid data structure as seen from the light’s point of view. Essentially you can think of this like a shadow map, but instead of storing depth, you store an array of triangles, as depicted in figure 7 below. Of course it is important to note that this kind of data structure would not scale to cater for a highly complex game scene, but instead would be more appropriate for a discrete dynamic object, such as the main game character.
Figure 7: Deep Primitive Map Rendering
Conservative rasterization is definitely needed in this case, to ensure that every triangle that touches a primitive map texel is stored. Without conservative raster enabled triangles will be missing from the map, and you’ll wind up with holes in the shadow. To perform the ray tracing, just compute primitive map lookups in a similar way as you would for shadow mapping, but instead perform ray-triangle intersection tests to determine if a screen pixel is occluded. The resulting quality of shadow, as compared to regular shadow mapping is very high. Figures 8 to 10 compare regular shadow mapping with the ray traced result, and show the effect of switching conservative raster on:
Figure 8: Regular Shadow Map
Figure 9: Ray Traced - Conservative Raster OFF
Figure 10: Ray Traced - Conservative Raster ON
This is the process of converting a triangular mesh into a voxel representation, and can be thought of as a way of storing a lower level of detail for a scene, as highlighted by the photograph below:
Voxelization has many potential usage scenarios, but an obvious one is Global Illumination (GI). GI is the process of computing the effect of light as it bounces around a scene, the result of which is far more life-like lighting than traditional direct lighting solutions, as demonstrated by the comparison shots below:
Figure 12: Tradition Direct Lighting
Figure 13: Global Illumination
Conservative rasterization comes into play during the voxelization process, to ensure that small triangles are not dropped out of voxel information. Voxelization tends to be performed at a lower resolution than the full scene for performance reasons, which only increases the need for conservative raster to be enabled.
NVIDIA GameWorks VXGI
For more details on NVIDIA’s VXGI technology take a look this video.
Call to Action
Conservative rasterization is a superb addition to the GPU, it enables advanced techniques such as ray traced shadows and global illumination. Over the coming months developers are going to think of great new ways to make use of this feature, so it’s over to the development community…