How to export motion vectors (compatible with ReelSmart Motion Blur)

Matteo Marson's icon

Hi everyone,

I'm looking for a way to extract motion vectors from a 3D scene as a 2D image representing pixel motion in screen space. I want to use this image as a guide for motion blur effects in After Effects (such as ReelSmart Motion Blur).
Basically, having access to the information about the whole 3D scene, i'd like to create an image where each pixel represents the velocity (decomposed in green scale for the horizontal component and red scale for the vertical one) calculated as difference between the current and the next frame.
Each pixel tells where it's going and how fast, but I don't know how to access this information.

http://revisionfx.com/support/faqs/motion_vector_FAQs/motion_vectors/
Here you can find deeper explanations of what i'm trying to achieve along with some 3rd party plugins designed for 3D max, cinema 4D, Lightwave, Maya and Xsi

Thanks!

Rob Ramirez's icon

you can get pixel velocity data by capturing to a jit.gl.node @capture 3 and binding a jit.gl.material to you geometry. check out the mrt.basic.material.maxpat example patch for a demo. look inside the [p velocity] sub-patch for an explanation.

Rob Ramirez's icon

also, check out the pass.motionblur.maxpat example to see it in action.

Matteo Marson's icon

Thanks Bob, that was exactly what I was looking for!

dirkdebruin's icon

I'm trying to use @capture 3 on jit.gl.camera to use the depth and velocity textures from there but I'm getting some inconsistent results. Should this work the same as on jit.gl.node or should I give each camera its own node and use capture 3 on those?

Rob Ramirez's icon

hard to say without seeing a patch.

dirkdebruin's icon

It seems to have something to do with having multiple cameras. The moment I enable the second camera, the velocity texture starts to act weird.

Max Patch
Copy patch and select New From Clipboard in Max.

Rob Ramirez's icon

thanks for the patch. i can see that there are problems with @capture 3 on two jit.gl.cameras in the same sub-context. i'll see if there's any possible fixes for this for a future update.

dirkdebruin's icon

Thanks Rob! I'll be looking forward to that.