Motion Blur ES2 Sample


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

Description

This sample shows a method of simulating motion blur of fast-moving objects using multi-pass rendering. In the first pass, the fast-moving geometry is rendered unblurred into a framebuffer object. In the second pass, a special vertex shader stretches the geometry between the previous and current vertex position based on the normal at the vertex and apparent shutter duration (stretch length), and the fragment shader applies supersampling to the first pass results to generate a blurred visual.

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

Introduction

This sample is a simple implementation of a reconstruction filter for motion blur. Its main premise to to blur geometry by "stretching" some of the vertices in the opposite direction of object movement, and use the "stretched" vertex position for supersampling. This method has some constraints:

For a more plausible, generalizable motion blur effect, see the "MotionBlurAdvanced" sample for OpenGL 4.x and OpenGL ES 3.0.

Algorithm overview

The algorithm consists of the following two rendering passes:

  1. Unblurred, moving geometry pass:
    • The moving scene geometry is drawn, textured and shaded (simple Gourad interpolation).
    • This is rendered directly onto a framebuffer object (FBO).
  2. Blurred geometry plus rest of the scene:
    • The static scene geometry is drawn, textured and shaded (simple Gourad interpolation).
    • The skybox is drawn (using a cubemap texture) onto a screen-aligned quad at max depth distance.
    • The "stretched" moving geometry is drawn (with depth test disabled). In this step, the FBO color attachment rendered earlier is used for supersampling.
    • All of this is rendered directly onto the default framebuffer.
Using our sample implementation

In addition to the controls indicated in the section "Shared User Interface" above, The following controls have been added to the TweakBar:

 


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