Motion Blur D3D Advanced Sample


Category:  Visuals
Min PC GPU: Fermi-based (GTX 4xx)

Description

This sample shows a filtering method for simulating motion blur of fast-moving objects. The method used is a 2D full-screen post-process that works on a normal framebuffer augmented with a screen-space velocity buffer; thus, filtering performance is not dependent on scene geometric complexity. The algorithm is based on the paper 'A Reconstruction Filter for Plausible Motion Blur', by McGuire et. al. (SIGGRAPH I3D'12).

APIs Used

App-Specific Controls

This sample has the following app-specific controls:

DeviceInputResult
mouseLeft-Click DragRotate the scene
 Middle Button ScrollZoom the scene
keyboardF1Toggle onscreen UI
Tab Toggle performance stats

Technical Details

Introduction

This sample is an implementation of a plausible reconstruction filter for motion blur. It is a 2D multi-pass post-process implemented mostly in a GPU shader language, which has the following advantages over competing alternatives:

The algorithm takes the following as inputs:

Figure 1: Color buffer (Click to enlarge)

Figure 2: Depth buffer (Click to enlarge)

Figure 3: Half-velocity buffer (Click to enlarge)

Algorithm overview

Once the color buffer C, depth buffer Z and vertex half-velocity buffer V (all of size w and h) have been generated, the algorithm performs the following passes:

  1. TileMax(V):
    • Takes the vertex half-velocities V as input.
    • It is a downsampling pass: it produces a buffer of size (w/K, h/K), where each pixel represents a tile.
    • Each tile stores the dominant (i.e. highest magnitude) half-velocity for all the original values within that tile.

Figure 4: TileMax pass output (Click to enlarge)

  1. NeighborMax(TileMax):
    • Takes the output of TileMax(V) as input.
    • Both input and output buffers are of size (w/K, h/K).
    • Each tile's dominant half-velocity is compared against its neighbors', and it stores the highest dominant half-velocity found. This effectively "smears" the highest velocities onto other neighboring tiles.

Figure 5: NeighborMax pass output (Click to enlarge)

  1. Final gathering (reconstruction) pass:
    • It takes C, V, Z and NeighborMax as inputs.
    • Its output goes directly to the default framebuffer (or to other post-processes, if appropriate), using the entire screen size.
    • Each output pixel is blurred in the direction of the dominant half-velocity for its tile (obtained from NeighborMax). This is done by selecting S pixels in a pseudorandom fashion along that dominant half-velocity, and the selected pixel is then weighted against the current one. This weighing takes into account depth differences and ordering (by consulting Z).

Figure 6: Final reconstruction pass output (Click to enlarge)

Using our sample implementation

In addition to the shared controls above, the following items have been added to the TweakBar:

 

 

 


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