Jump to content
ejr32123

Controlling Focus Distance

Recommended Posts

Hey,

This is how I control the focus distance in Maya. I use a measure distance node, then use that distance to drive the focal distance so where ever I move the null, the scene is in focus. Can I do this in Houdini? Is there a measure distance node that can get the distance between two null objects? One null would be at camera's position and the other null where I want to focus.

Thanks

Share this post


Link to post
Share on other sites

Have a look at this, Adrian provided an example here. Also if you want take a look at the vtorigin function

 

Share this post


Link to post
Share on other sites
9 hours ago, ejr32123 said:

Hey,

This is how I control the focus distance in Maya. I use a measure distance node, then use that distance to drive the focal distance so where ever I move the null, the scene is in focus. Can I do this in Houdini? Is there a measure distance node that can get the distance between two null objects? One null would be at camera's position and the other null where I want to focus.

Thanks

Hey,

Also , you can find the distance between camera and arbitrary point in SOP level and then fetch it as your Focus distance value.

See attached example.
Hope it help.

focus_distance1.hipnc

Edited by MagicRej

Share this post


Link to post
Share on other sites

What I really miss is a way to click into the rendering to set the focus distance. This is very nice for quickly finding the sweet spot for stills. Love it in Thea Render etc.

Is there a way to do this as a viewport action in Houdini with some raytracing from the mouse?

Cheers,

Tom

Share this post


Link to post
Share on other sites
2 hours ago, Thomas Helzle said:

What I really miss is a way to click into the rendering to set the focus distance. This is very nice for quickly finding the sweet spot for stills. Love it in Thea Render etc.

Is there a way to do this as a viewport action in Houdini with some raytracing from the mouse?

Cheers,

Tom

Indeed there is. Just to illustrate a concept:

- copy $HFS/scripts/ipr/pickpixel.py to ~/houdini16/scripts/ipr/

- comment out the very last line (hou.ui.displyMessage(...))

- append (in the same scope, just bellow): 

    if not "Pz" in viewer.planes():
        rop_node_name.parm("vm_quickplane_Pz").set(1)
        viewer.startRender()
    else:
        value  = viewer.pixel("Pz", px, py)
        camera = rop_node_name.parm("camera").eval()
        camera = hou.node(camera)
        camera.parm("focus").set(value[0])

For a first time you will have to Ctrl-Click twice if there is no "Pz" plane, otherwise Ctrl-click on IPR pane will set distance on rop's camera.

cheers,

skk.

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

You can also use an Object CHOP to get the distance between two objects, then put a chop() expression in the focus parameter to fetch the result.

Share this post


Link to post
Share on other sites
14 minutes ago, Thomas Helzle said:

Thanks symek - have to try that.

I guess that will only work with Mantra, right?

You're welcome :). I think the only Mantra dependency is adding Pz to planes' set. Otherwise it relies only on pixel value from a viewer, so if only your renderer puts some pixels there it's should work for it too.

  • Thanks 1

Share this post


Link to post
Share on other sites

Cool - have to try it with Redshift as soon as the current job is done! :-)

So far I always used this in the focus distance field:

// Camera focus distance to a null called focus:
vlength(vtorigin(".","../focus"))

But it's a bit clumsy to navigate the null.

Tom

Edited by Thomas Helzle

Share this post


Link to post
Share on other sites
On 9/7/2017 at 10:56 AM, Thomas Helzle said:

Cool - have to try it with Redshift as soon as the current job is done! :-)

So far I always used this in the focus distance field:


// Camera focus distance to a null called focus:
vlength(vtorigin(".","../focus"))

But it's a bit clumsy to navigate the null.

Tom

Is this supposed to work still?

It errors out due to infinite recursion in 16.5.378

The chop expression way also does not evaluate. 

Share this post


Link to post
Share on other sites
19 hours ago, trzanko said:

Is this supposed to work still?

It errors out due to infinite recursion in 16.5.378

 

// Camera focus distance to a null called focus:
vlength(vtorigin(".","../focus"))

Works for me in the same version you use.
Did you parent the null to something that it creates a loop? I just use a camera and a null on the obj top level.

Edited by Thomas Helzle

Share this post


Link to post
Share on other sites
On 9/7/2017 at 4:46 PM, symek said:

You're welcome :). I think the only Mantra dependency is adding Pz to planes' set. Otherwise it relies only on pixel value from a viewer, so if only your renderer puts some pixels there it's should work for it too.

I totally lost track of this but now finally tried it out - works great, but only for Mantra.

With Redshift I get the Python error:
Error.jpg.0a209af383cb1360c96bebcc3165abce.jpg

So I guess Redshift (2.5.62) doesn't provide the needed handles (Houdini 16.5.378).
I'll probably have to wait for their render viewer to provide this natively.

Cheers,

Tom

Share this post


Link to post
Share on other sites

It's because adding Pz/Depth extra plane for Redshift works differently. Possibly camera parameter might have different name on RS rop. It's an easy fix if you have RS around (I don't till Monday, sorry). 

skk.

damn you OSX with no X server anymore.

  • Like 1

Share this post


Link to post
Share on other sites
On 2017-09-07 at 11:21 AM, ejr32123 said:

Thanks btw, I will see which solution works best for me!!!

you can also have a look at Tims tutorial. 16 minutes in, he shows a simple setup for adjusting depth via the viewport

 

Share this post


Link to post
Share on other sites
37 minutes ago, symek said:

It's because adding Pz/Depth extra plane for Redshift works differently. Possibly camera parameter might have different name on RS rop. It's an easy fix if you have RS around (I don't till Monday, sorry). 

skk.

damn you OSX with no X server anymore.

Thank you symek and no hurry at all!
Redshift can use the Mantra camera parameters (which is what I tried) so that shouldn't be the issue.
I also tried to create a Z-Depth AOV in Redshift to no avail.

I never used python scripting in Houdini so am a bit out of my depth... :-)

Thanks and Cheers,

Tom

Edited by Thomas Helzle

Share this post


Link to post
Share on other sites
3 hours ago, Thomas Helzle said:

 


// Camera focus distance to a null called focus:
vlength(vtorigin(".","../focus"))

Works for me in the same version you use.
Did you parent the null to something that it creates a loop? I just use a camera and a null on the obj top level.

ye all good, thanks for responding! was testing the expression in the 'tz' channel lol

 

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

×