Jump to content
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
  • Like 1

Share this post


Link to post
Share on other sites
Hey Lewis I found your solution to Motion vector blur in Houdini & I was hoping you could help me out.
I'm trying to get a Motion Vector AOV from Mantra for a pyro render
So I want to get an AOV like this
Vectors_Final.jpg
Looking at your post here I thought this might work but Houdini doesn't like the last bit
\$mv = ndcv;
The other way I'm trying is adding this to my pyro shader network.
Mantra_MV.JPG.312b3ca16b71f5ff21a07c41de4b890a.JPG
 
But I only get this
MVOUT.JPG.bf8df6499c9cb9b3ed7096784f980315.JPG
Do you know a way to render out the AOV from Mantra? I know the game dev tools can do it but I want to render it out this way.
 
Hope you can help
Thanks

Steve

Share this post


Link to post
Share on other sites

Hi!  Attached a .hipnc showing motion vectors from a shelf fireball.  Your example pic has the values adjusted to be between 0 and 1, where naturally the motion vectors will have a lot of negatives... might be an idea to do that after the render, you have to choose a min and max value and if you do it in the shader it's too easy to forget what you chose :-[ It looks like the vectors there have also been spread out past the edges of the object - you can't really do that in the shader either, it's more a comp thing.

In the file I cranked the density hella up because semi-transparent volumes will average the motion vectors out otherwise, between the close to camera and far from camera voxels along each ray.

Hope that makes sense!

Ls_volumemotionvectors.hipnc

Share this post


Link to post
Share on other sites

Thanks for the speedy reply Lewis!!!
It's working in the hip file so I'll try to make sense of that.
I did try to break your code up into nodes in the shader but I'm not that clever with Houdini yet, but I do get the gist of what your code is doing.
I think from using this output I can use the game dev tool to work out how to get what I need out in COP's (hopfully)
Thanks mate!

  • Like 1

Share this post


Link to post
Share on other sites

Here's with the same thing as nodes - the workaround for raytrace mode is more nodes than it has any right to be, if you can render in micropoly mode you can ignore the second branch going into the switch VOP.  Remember to disable preview/gradual refinement with the button above the render view when testing, it forces raytrace mode even if you select micropoly on the ROP...

 

Ls_volumemotionvectorsnodes.hipnc

Share this post


Link to post
Share on other sites

Thanks for the Nodes mate they helped understand it a lot easier & I think the reason mine didn't work was because I'm rendering using PBR not Micro PBR.

So is there a node way to get this to work better with PBR?
This is Micro PBR
MV_MPBR.JPG.1cc921b78cd5a57fa43e0a559205fff3.JPG


This is PBR. As you can see there's speckling which I'm guessing is due to out of range samples as it's not 0-1 (complete guess)? 
MV_PBR.JPG.dec33194ec7c9ccd2537c0bf396bc42d.JPG

Thanks

Steve

Share this post


Link to post
Share on other sites

Hmmmmm I'm guessing but I would try increasing volume step rate on the mantra ROP - try 1.0 - and then increase the stochastic samples, maybe 16 or just disable stochastic transparency altogether. If it's still not enough you could carefully increase volume filter width on the object's render/shading tab, or last resort mantra's pixel samples (if you have to go higher than 8x8 it usually means something else is wrong). Try disabling "Allow image motion blur" at the bottom of the mantra options too...

Share this post


Link to post
Share on other sites

Thanks Lewis!

I tried all the different ways you said but none seemed to work.
Even with the 8x8 pixel samples I got the same result below....
8x8Samples_ST_ON.JPG.6d1de31101254e9a16cd9cdca99a54e8.JPG

But by using 4x4 pixel samples & turning off stochastic transparency altogether I got this much better result...

4x4_ST_OFF.JPG.1857917a8ae863207ae71fb009eaa73d.JPGST_Off.JPG.bd9cdf453c1a8926562b68d004431dea.JPG

The render time has gone up but I tried adding stochastic transparency samples up to 4000 & still had no change.
So with the 8x8 pixel samples not working I'm not sure if, like you said, there's something wrong? At least this way works, so thanks loads!!

Steve

Share this post


Link to post
Share on other sites

What if, before you export your parameter in the shader, you multiply it by "Of", which is one of the outputs from the volume model or the pyro shader core? 

Edited by Andrea
typo

Share this post


Link to post
Share on other sites

Hey thanks Andrea!!
Thats knocked 10 mins off the render time & got me what I need.
So no need to turn off Stochastic Transparency whcih was giving me a good result but added 10 mins per frame so it wasn't really something I could go for.
Adding the multiply with the 'Of' from the Pyro Shader Core like you said gave me this!!

01.JPG.996ca181f70b65ae2f652c30cf36a1f5.JPG


02.JPG.d115dd0e3d7ecc35b1e6ace83486a281.JPG

Thanks mate!
Steve

Share this post


Link to post
Share on other sites

The only problem I have now is getting this

01.JPG.2715ebd765fdc61e84c02883371a5c13.JPG

To this in Houdini
Vectors_Final.jpg

I've been using COPs all week but that is soo unstable crashing loads throughout the day
As the colours are different I've no idea where to staret really.
Any ideas?

Thanks
Steve

Share this post


Link to post
Share on other sites

I can't help much here but ... What you are seeing from the Houdini pass is an RGB image and looks also clamped because of negative values that are not showing up. Probably you have them but the viewer is not showing them.

Meanwhile the FumeFX picture you posted has just X-Y components (and looks like it's displaying the full range of values?)

 

So.. is the velocity pass that you are exporting from Houdini the velocity pass converted to camera view? If yes it should be ok but I think you are not going to have the red-green values outside the volume.

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

×