Motion Blur

From C4 Engine Wiki
Jump to navigation Jump to search
Figure 1. Motion blur is visible due to the movement of the camera and the falling debris.

The C4 Engine is capable of rendering full-scene motion blur as a post-processing effect. Motion blur in C4 is based on the concept of a velocity buffer, and it employs a sophisticated algorithm that uses information in both the velocity buffer and the structure buffer to apply the correct blur after the entire scene has been rendered. The screen-space velocity of a single pixel depends on several factors, including the motion of the geometry occupying that pixel, the motion of the camera, and possibly the motion of different vertices within the geometry (for example, skinned characters and dynamic cloth have moving vertices). The engine takes all of these into account and generates an accurate velocity for all objects in the scene. In Figure 1 to the right, the ground is blurred because the player is moving backward, and the crumbling debris is blurred because is falling to the ground and rolling.

Controlling Motion Blur

In the demo game that ships with C4, motion blur can be enabled or disabled by the user in the Graphics Settings dialog. This works by setting the value of the $postMotionBlur system variable to either 0 or 1.

Motion blur can be enabled or disabled on a per-geometry basis in the World Editor by selecting a geometry and opening the Node Info dialog. There is a check box under the Geometry tab called "Apply motion blur", which is enabled by default. This check box corresponds to the kGeometryMotionBlurInhibit flag that can be set for a GeometryObject using the GeometryObject::SetGeometryFlags() function.

It is sometimes necessary to explicitly tell the engine that an object has stopped moving so that motion blur for that object can be reset. (A stopped object is not normally being invalidated in the usual way, so the engine has no way of knowing that it needs attention.) The Node::StopMotion() function can be called to update the internal transforms so that an object is correctly recognized as completely stopped.

Further Reading