RSS< Twitter< etc

<< Back To XMesh Index

XMesh Saver MX Subframe Sampling

 

Note

While the content of this tutorial applies to all versions of XMesh Saver MX, the exact steps used in the examples are using the v1.0.2 update which is available from the Downloads page. In this version, the samples are defined via a drop-down list and not a floating point spinner.

Introduction

By default, the XMesh Saver will write one mesh per frame, representing the look of the geometry to be rendered exactly at the times that will be rendered. Thanks to the Velocity channel, information about the look of the geometry between two frames can be extrapolated to produce relatively usable motion blur or retiming data.

In some cases though this amount of information might be insufficient to reproduce the exact motion or shape of the saved object. In particular, this is an issue when a mesh is rotating very fast.

To solve this problem, XMesh Saver MX provides the ability to save Subframe samples. This workflow was further improved  in the v1.0.2 update of XMesh MX. 

A Test Case

In order to visualize the problem with very fast rotations and the solution of using Subframe sampling, we will create a very simple scene containing a spinning box primitive. 

  • Create a Box in the Front view with width of 200 units, length of 20.0 and Height of -10.
  • Set the 3ds Max animation segment to 0 to 6 frames.
  • On Frame 6, enable AutoKey and rotate the Box at 360 degrees about its local Z axis (view Y axis).
  • Create a Camera looking at the box from approximately the front.
  • Set the Camera Multi-pass effect to Motion Blur, Total Passes 20, Duration 2.0
  • Go to frame 1  

The viewport should look something like this:

  • Render in Default Scanline Renderer - the resulting image will show 20 motion blur samples over 2 frames:

Saving to XMesh Using 1 Sample

Now let's see what happens when the spinning box is saved to an XMesh file sequence using the default 1 Sample setting. 

  • Select the Box
  • Open the XMesh Saver MX dialog.
  • Set the Source mode to "Selected Geometry".
  • Set the Save mode to "Save ALL Object To ONE MESH In WORLD SPACE Coordinates"
  • Keep the timing to 1-6, 1 Sample.
  • Make sure >Save Proxy Sequence is disabled.
  • In the Advanced Settings rollout, set the "When an object has no material" option to "Use RED NEON..." - this will create an XMesh Loader that will be red to distinguish it from the original object color of the spinning primitive 

  • Press the "SAVE 1 OBJECT AS ONE MESH IN WORLD SPACE..." button to generate the XMesh sequence - an XMesh Loader will be created and will be red.
  • With the XMesh Loader selected, change the Y Position to 0.1 to ensure it is a bit behind of the original source and avoid Z-fighting in the viewport and during rendering.
  • Render Frame 1 in Default Scanline Renderer again: 

As you can see, the red samples do not match the green ones. This is because the positions of the vertices of the box mesh are extrapolated linearly from the full frame's position along the Velocity vectors.  The result is a skewing of the mesh where the Velocity vectors continue moving in the same direction from half a frame before to half a frame after the sample and of course do not follow the rotation of the object.

With slower rotating object, this skewing would be pretty negligible. But in this extreme case, the discrepancy is also extreme.

Saving With Multiple Subframe Samples 

As mentioned in the beginning, saving multiple samples per frame can help fix this problem. 

  • Switch the drop-down list to 2 Samples.
  • Press the "SAVE 1 OBJECT AS ONE MESH IN WORLD SPACE..." button again - this will resave the sequence and update the XMesh Loader with the new sequence.
  • Make sure the Loading Mode in the XMesh Loader is switched from "Frame Velocity Offset" to "Subframe Velocity Offset".
  • Render Frame 1 again:

This looks slightly better because we have a reference sample at both full frames and half frames, and the linear segments produced by the vertex position extrapolation are shorter.

We can keep on increasing the number of Samples to 4, 5, 8 and 10 (assuming the Scene is using a Frame Rate of 30 FPS) to see further improvements at cost of saving time and disk space usage. 10 samples seem to produce a pretty good result:

3ds Max uses integer values called Ticks to represent time. A Tick is the smallest time unit 3ds Max can represent and there are exactly 4800 Ticks in a second. When the Frame Rate (Frames Per Second) changes, so does the Ticks Per Frame value - 4800/30=160, 4800/25=192, 4800/24= 200 TPF. Version 1.0.2 of XMesh Saver MX now uses Ticks internally and also exposes only the Sample values that produce correct Tick intervals according to the current scene Frame Rate settings. In earlier versions of XMesh Saver MX, the Sampling was exposed as a floating point number, so a Sampling of 10 had to be specified as 0.1. The old method allowed time requests that did not match a round Tick value and while it produced usable results, the new workflow and UI should be much easier to grasp.

Using Frame and Subframe Interpolation

The XMesh Loader provides two more Loading Modes - Frame Interpolation and Subframe Interpolation. These options are useful when the topology of the geometry is unchanging between frames, but no Velocity channel was saved by the XMesh Saver.

In Frame Interpolation mode, vertex positions on sub-frames will be interpolated using the two existing full frames around it. 

In Subframe Interpolation mode, the two closest subframe samples will be used to generate the requested subframe sample mesh.

Since the Frame Interpolation mode tends to create shorter skewed meshes (as opposed to the overshooting of the Frame Velocity Offset mode), we must select the XMesh Loader and move it to Y = -0.1 to place it slightly in front of the original box.

Rendering in Frame Interpolation mode produces the following image:

As you can see, the red samples are linearly interpolated, but are inscribed in the curvature of the reference object's vertex trajectories.

Note that the same result will be produced by the Frame Interpolation mode regardless of the actual number of existing subframe samples - in this mode, only the full frames are taken into account and any existing subframe samples are simply ignored.

Switching to Subframe Interpolation and using the 10 Samples sequence saved in the previous section will take into account all existing samples and produce a well-curved motion blur effect:

Subframe Sampling And XMesh Loader Retiming

Another case where the saving of multiple subframe samples is useful is when performing extreme slow-downs using the XMesh Loader's Playback Graph option.

Let's use the same spinning Box scene as example. 

Assuming we want to slow down the playback 10 times, producing 60 frames of animation using our saved 6 frames of Box rotation. 

  • Save the box from frame 0 to 6 with 10 Samples to a new Version of the output path.
  • Save the box once again from frame 0 to 6 with just 1 Sample using the next Version of the output path. The XMesh Loader will now show the 1 Sample version.
  • Change the Scene Segment to 0 to 60.
  • In the XMesh Loader, enable Graph and keyframe it from 0 on frame 0 to 60.0 on frame 60.
  • Clone the original spinning Box and shift the rotation keys of the clone from frame 6 to frame 60 as reference.
  • If we look at frame 5 (half-frame between 0 and 1 retimed to 0 and 10), we will see the same skewing we saw in the Multi-Pass Motion Blur example - the XMesh Box will be much longer than the reference Box:

  • Now select the XMesh Loader and go back one version to load the files saved with 10 Samples.

As you can see, since we have exactly one sample matching each retimed frame, the reference box and the retimed XMesh now align perfectly.