This shader is intended for those who wish to do compositing work before applying motion blur, or to use a specific third-party motion-blur shader. Its purpose is to export motion in pixel space (mental ray’s standard motion vector format is in world space) encoded as a color.
Most third-party tools expect the motion vector encoded as colors where red is the X axis and green is the Y axis. To fit into the confines of a color (especially when not using floating point and a color range extends only from black to white), the motion is scaled by a factor (here called Max Displace) and the resulting value range, which is –1 to 1, is mapped to the color channel’s 0 to 1 range. The shader also support a couple of different floating point output modes.
Sets the maximum encoded motion vector length. Motion vectors of this number of pixels or above are encoded as the maximum value that is possible to express within the limit of the color (that is, white or black).
To maximally utilize the resolution of the chosen image format, it is recommended that you use a Max Displace value of 50.0 (the default) for eight-bit images (which are not really suitable for this purpose) and a value of 2000.0 for 16-bit images. The shader outputs an informational statement of the maximum motion vector encountered in a frame to aid in tuning this parameter. For details, consult the documentation for your third-party motion-blur shader.
If Max Displace is 0.0, motion vectors are encoded relative to the image resolution. For example, for an image 600 pixels wide and 400 pixels high, a movement of 600 pixels in positive X is encoded as 1.0 in the red channel, while a movement 600 pixels in negative X is encoded as 0.0. A movement in positive Y of 400 pixels is encoded as 1.0 in the blue channel etc.
When not set to 0, the shader writes real, floating-point motion vectors into the red and green channels. They are not normalized to the max displace length, not clipped, and contain both positive and negative values. When this option is used, neither Max Displace nor Blue Channel Is Magnitude have any effect.