Jump to content
Sign in to follow this  

Motion vector from Camera?

Recommended Posts

I'm trying to generate a motion vector pass for use in Nuke later.


The way I've usually done it is like this, inside a shader:



Well that's not working now, and strangely if I set all the motion blur settings to

0 but I enable motion blur I still get motion blur.



When I change the shutter time setting on the camera in the scene, that seems to be influencing the motion blur.




Is there any way I can extract a useable motion vector pass for Nuke from what the camera is seeing, or am I going about this all wrong?


Share this post

Link to post
Share on other sites

Hey Petur,


Sorry for the late reply, hopefully this didn't cause you too much trouble, but for anyone out there looking for this solution here it is.


Petur your setup is very close. What is different to my setup is I never source the P (position) attribute into my motion vector from the globals. You need two 'getPBlur' nodes. Their input values for the time input are 0 and 1 (t0 and t1 respectively). t0 represents the position are the beginning of frame and t1 is the position at the end of frame. 


Next we should normalize the positions into the screen space using the toNDC node. Next we get the difference between the two position values (t1-t0).


Finally, its a good idea to make the value represent pixel movement so multiple the position vector by the resolution of the camera (1920, 1080, 0). Export this out with a bind. I call my export attribute vel usually. Depending on the MotionVector tool you may need to remap the vectors further (i.e. RSMB uses 0-1 space and 0.5 is not moving.)



Mantra Notes:


1.Make sure allow motion blur is turned on.

2.Turn off Allow Image Motion Blur.

3. For objects using velocity make sure to turn on 



Hip File is attached.




  • Like 2

Share this post

Link to post
Share on other sites

Thank you so much for the hip file! So thorough and helpful!


It totally solved the problem!

Your way is so much better than my was  :P

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this