Los Angeles mental ray® User Group
 Home   About   Info   Summaries   Gallery   Forum   Resources   Contact   Jobs 


Resources Sections

General

Install/Setup

Options Settings

Performance Optimizations

mi Scene File

FG/AO/GI

Subsurface Scattering

Shiny Stuff

mrfm (Maya)

Shader Writing

Hair and Geometry Shaders

Motion Tips

Motion Blur

mental ray offers several methods to create motion blur within the framework of the various sampling and filtering mechanisms. The type of motion blur which samples at various times within the shutter interval is often referred to as 3D motion blur, whereas the term 2D motion blur typically refers to a post process to rendering. Although an output shader could be inserted to provide 2D motion blur functionality, that approach will not be the focus of this discussion.

Motion blur is enabled by using the shutter option to specify an "open" interval. By default, the shutter is not enabled and assumes an instantaneous snapshot at frame time 0.

By opening up the shutter to include a time interval, mental ray considers any geometry and camera motion that may be specified for the frame. With motion, a sample taken at any given location could vary with time. Hence, we begin with an explanation of temporal samples and their relationship to what we know about samples from the Samples Tips resource page. As a follow-up to that page, our presentation here makes reference to its diagrams and terminology.

Temporal Sampling

In Samples Tips, we depict samples from the perspective of the image plane. Showing the samples in rectangular pixel tiles, we demonstrate a variety of patterns with fixed and adaptive densities. Because these samples populate the xy plane of image space, we call them spatial samples.

At each spatial sample location, mental ray takes a number of temporal samples, samples taken at different times across the open shutter interval. Multiple temporal samples combine to create the result required by a single spatial sample. In a sense, for sampling, time is a third dimension, t, added to the two dimensions of image space, x and y. One spatial sample combines a number of temporal samples with differing times t, at the same x, y location.

With an instantaneous shutter time, the number of temporal samples is one. For each spatial sample, mental ray uses a single temporal sample taken at the same time. By default, this is the start of the frame. In other words, with the default shutter 0 0 only one point in time, frame time 0, is used for each spatial sample. The two numbers following shutter indicate the opening and closing of the shutter window in frame time. The first number is optional and is referred to as the delay, or offset.

Actually, in the special case of frame time 0, neither geometry nor camera motion need consideration. At any other time in the frame, motion needs to be considered. However, it is interesting to note that the point of time for instantaneous sampling (without motion blur) can be shifted. For example, to sample at exactly 0.5 frame time, then use: shutter 0.5 0.5, and geometry and camera motion will be considered at the halfway point along any directed motion for the frame.

Technical Note: This technique of capturing motion instantaneously at midframe is known to be useful for creating bi-directional motion blur in 2d post. This could be implemented in an output shader, for example.

If the shutter is fully open, i.e., shutter 0 1, then a sample can be taken anywhere within the 0 to 1 interval when motion is detected. For a partially open shutter, such as 180 degrees as specified by shutter 0.0 0.5, the samples lie on that subinterval of the frame time.

When motion is detected at a given spatial sample location, mental ray selects equally spaced times within this range for a number of temporal samples, and then averages them together to create the effective spatial sample at that location. Note that for equal spacing, we treat the ends of the open shutter interval as if they were joined in a loop.

The time contrast option controls the number of temporal samples taken per spatial sample location. As depicted, it is approximately the inverse of the number of temporal samples. In a 0-1 interval, the time period between samples is the time contrast value; so, above left, the samples are 0.5 apart. Generally, it represents the fraction of time covered while the shutter is open. Note that all the time contrast arguments should be specified as equal, because in mental ray 3.x, there is no variation according to color.

In the following example, this means that 10 temporal samples average together to form 1 spatial sample. It is the resulting spatial sample then, that is used for comparing contrast during adaptive sampling. Note that time contrast does not specify adaptive sampling in the t dimension. The terminology is a legacy from an earlier implementation of mental ray.

And now we'll show similar examples with a shutter delay of 0.25.

So far, we've presented these temporal samples centered in the open shutter interval. This isn't exactly what happens. Actually, mental ray shifts the times as a group for each spatial sample. The temporal samples remain equidistant, but they are offset by some initial amount. To illustrate this below, we show an increasing shift for 4 different spatial samples on the left, and varying shift, on the right.

Technical Note Across the image, mental ray uses Quasi-Monte Carlo (QMC) deterministic sampling techniques to determine how much shift. More specifically, it uses QMC to choose an initial time for the first temporal sample for each spatial sample. And this, in turn, determines the remaining temporal sample times for that location because they are equally spaced in the open shutter interval. As a result, each temporal sample across the image has a uniquely determined time.

Fast Motion Blur

An alternative sampling technique to account for varying sample times.

If most of the picture is moving, or for example when the camera is moving, adaptive sampling may become quite dense, and therefore may increase render time significantly. Remember to check sampling density with the diagnostic samples, and keep in mind that each spatial sample averages a number of temporal samples. If your diagnostic picture is almost all opaque white with a samples max > 0, lots of sampling is going on! For these cases, one may consider another option that takes advantage of using multiple spatial samples for almost every pixel in the image.

mental ray offers an option called fast motion blur, a form of motion blur that can be used with a fixed sample rate, ie if samples min equals samples max. It is enabled by setting the time contrast option to 0, and ensuring that samples min = samples max. For each spatial sample, mental ray will take a single temporal sample, but each at a different time than its neighboring samples.

Take our fixed grid examples. With normal motion blur, each sample point will take a number of temporal samples. With fast motion blur, each sample point takes one temporal sample. Both diagrams below represent a density of 16 temporal samples per pixel. Of course, the actual samples used depends on the filter specification.

In this mode, we increase the smoothness of the motion blur by increasing the spatial sample density. Also, note that increasing the filter size may accomplish some of the same effect for your particular scene. Effectively, the number of samples used per pixel roughly determines the number of temporal samples used per pixel, replacing time contrast as a method for controlling time sampling density.

Technical Note Recall that the first temporal sample uses QMC sampling techniques to determine a time. Because fast motion blur only uses one temporal sample, every sample has a uniquely determined sample time. This spreads out time samples across the image space rather than within each sample location. For this to work effectively, multiple samples per pixel must be specified through the samples and/or the filter size options. We rely on the QMC algorithm to spread the times well throughout the shutter interval, over the entire image.

Rasterizer

As a note of interest, mental ray uses the fast motion blur technique of spreading time among the spatial samples for the rasterizer/rapid motion scanline method. However, in the rasterizer the samples are based on (sub)pixel centers rather than (sub)pixel corners. For more details on this approach, see Rasterizer Tips.

Motion Specification

At this point you may be wondering what it means to take a sample at a given time? To answer this question, we need to consider how we specify motion.

An open shutter means nothing without indicating to mental ray what is moving and how. Put simply, we won't get motion blur without motion.

mental ray offers two ways to specify motion:

  • by directing object or camera motion, or
  • by directing the motion of individual points on objects.

Motion Transformations

In the first method, a motion transformation matrix can be added to an instance of an object, or the camera, to indicate a change in transformation through the frame time. The object's initial transformation indicates its position and orientation at the start of the frame (frame time 0), whereas the motion transformation indicates its position and orientation at the end of the frame (frame time 1). In the instance block, use the transform and motion transform statements, respectively, to specify these matrices.

Motion Vectors

In the second method, a motion vector may be given to each individual point on an object to indicate movement through the frame time. The point definition includes a position at the start of the frame, and a single motion vector, which adds to it to indicate the position at the end of the frame. In the vertex definition section of the object block, use the v and m statements, respectively, to specify these vectors. Normal and texture vectors may also be inserted inbetween them, e.g., v 0 n 10 t 20 m 40.

Motion Detection and Application

Motion is detected when either a motion transformation, or motion vectors, direct an object through the spatial sample location. More specifically, the eye ray for that sample will intersect the object at some time during its movement within the frame time. Motion transformations and vectors can be combined, so mental ray must account for this when detecting motion.

As noted, a motion transformation, or a point with a single motion vector, represents motion spanning the whole frame time interval. This means, for example, that at frame time 0.5, a point has traveled half the distance of its motion vector. Similarly, at a temporal sample time of 0.25, all points with attached motion vectors will have been transformed by one quarter of the vector's distance.

Note that we use these simple times for example only, and that the actual temporal sample times are determined by the QMC sampling algorithm.

Multisegment Motion Paths

For movement requiring bending motion blur paths, mental ray provides for multisegment motion vectors. Each point can have more than one motion vector segment during the open shutter interval. For example, with a four segment motion path, each point on an object would include four motion vectors. These motion vectors are typically passed on from the 3D application.

Technical note: Although the path is a multisegment line, the motion vectors themselves are not connected to each other, but rather to the time 0.0 point location. Each vector represents a "ray" from the initial point to the point at time 1/n, 2/n,...n-1/n, 1, along the motion path containing n segments. mental ray derives the motion path from this specification.

With a multisegment motion path, a given sample time will lie on the segment appropriate for its subinterval on the frame time line.

Motion Steps

A motion transformation on an object instance can also be broken down into multiple steps. Automatically, mental ray may approximate a number of intermediate transformation matrices between the initial and final transformation. This feature is enabled with the motion steps option.

mental ray actually uses an interpolation scheme that takes into account rotation, so your typical helicopter blade will rotate correctly. Automatic matrix interpolation does get trickier with fancier transformations, so make sure to check your blur paths. When combining multistep motion transformations with multisegment motion paths, it is recommended to make the number of motion vectors equal to the number of motion steps. Typically, your 3D application has a mechanism to synchronize these together.

Motion and Global Illumination/Caustics

With global illumination and caustics, mental ray has another phase that can be affected by time. In the photon tracing phase, when photons are being emitted, the path of any given photon may be dependent on the location of moving geometry. Any object that casts or receives photons may be moving during the open shutter interval. In addition, the source of photon emission, the light itself, may be moving.

To account for this, mental ray uses time when emitting photons. When motion blur is enabled during photon tracing, each emitted photon takes on a time within the open shutter interval. These times are spread uniformly over the shutter period.

However, when these photons are stored in the photon map, mental ray no longer stores the associated time. This keeps the size of photon maps down, along with the complexity of the photon lookup, in trade-off with slightly decreased accuracy in certain situations. Within the radius used for looking up photons in the photon map, mental ray will use photons stored from all times.

Technical Note: With the kd-tree API, it is possible to make your own photon map that stores time along with location and energy.

Tip If the camera is moving while using photon maps, avoid using the scanline methods. In other words, turn scanline off. With a moving camera, the scanline methods force a fixed camera transformation which can decrease the quality of the photon map lookup, as well as decrease the speed of ray tracing.

Motion and Final Gathering

When using motion while creating finalgather maps for final gathering, the situation is similar to creating photon maps. The final gather points are computed at different times, however, the final gather map itself has no notion of these times. So the interpolation of finalgather points includes points generated at all times. Keep this in mind when adjusting the final gather accuracy.

Motion and Light Maps

For computing light maps, mental ray uses frame time 0. Note that light maps are computed in a two phase process separate from, and typically, before the sample-taking rendering phase.

However, a light map that uses indirect illumination, may incorporate photons from the photon map. With an open shutter and moving geometry, these photons could represent energy at varying times.

Discuss on LAmrUG forum


 © 2003-2006 Los Angeles mental ray® User Group, All Rights Reserved.
mental images and mental ray are registered trademarks of mental images GmbH, in the United States
and other countries. Other product names may be trademarks of their respective owners.


About Us| Contact Us