Jump to content
Sign in to follow this  
JJ FX

mantra velocity pass

Recommended Posts

Hi, 

So there is no default velocity pass in mantra. At least I cant see it. I added extra image plane, the v variable, but nothing renders out.

Yeah I can colorize by velocity and render out, and this would be my veloctiy pass. But that needs additional rendering. And I dont have time to do additional renders now

Can I render out velocity as one render?

Edited by JJ FX

Share this post


Link to post
Share on other sites

Always seemed odd that there's no simple way to do this. It's quite tricky to handle all cases but below is what I've been doing...

// 2D motion vector output in absolute pixels, lewis@lewissaunders.com July 2018
// Paste this in an Inline Code VOP, enable "Expand Expressions in Code"
// Connect a Bind set to "vel", type Vector, to the first input
// Set Output 1 Name to "mv", type Vector
// Connect the output to a Bind Export set to the name used in Mantra's image planes
// Make sure motion blur is enabled on the ROP, even if "Allow Image Motion Blur" is not
vector ndcv = toNDC(getblurP(1.0)) - toNDC(getblurP(0.0));
string engine; renderstate("renderer:renderengine", engine);
if((engine == "raytrace" || engine == "pbrraytrace") && isbound("vel")) {
    // When rendering volumes in raytrace mode the getblurP() method doesn't work, but we do the best we can
    // It's correct for a static camera but there's no way to incorporate camera motion. For simple camera moves
    // the camera motion vectors can be added to this in comp before the blur is done... to get solid vectors
    // from a volume the density normally needs to be increased a lot anyway, and rendered as another pass, so
    // it might be better to just do that pass in micropoly mode :)
    vector p0 = getblurP(0.0);
    vector framev = vel / $FPS;
    vector camerav = vtransform("space:object", "space:camera", framev);
    ndcv = toNDC(p0 + camerav) - toNDC(p0);
}
vector res; renderstate("image:resolution", res);
ndcv *= set(res.x, res.y, 0.0);
\$mv = ndcv;

http://lewisinthelandofmachines.tumblr.com/post/159532447318/houdini-2d-motion-vectors-from-mantra

 

Edited by Lcrs
updated code for H16.5

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  

×