Jump to content

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

Link to comment
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
Link to comment
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 2
Link to comment
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
Link to comment
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
  • Like 2
Link to comment
Share on other sites

  • 6 months later...
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. 

Link to comment
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
Link to comment
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

Link to comment
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
Link to comment
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
Link to comment
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

 

Link to comment
Share on other sites

  • 5 months later...

I found another way of doing it. I know its been a while : ) 

1. Using add sop create a point

2. copy relative references of camera's transform to the point

3. create another point using the add node and merge the two points

4. create another add node after the merge and go to polygons, then by group. This will create a line between the first and second point.

5. create a measure sop and set type to perimeter

6. attribute promote and promote perimeter to detail

7. on cameras focus distance use the detail hscript expression, it should look like this: detail("/obj/geo1/attribpromote1/", "perimeter",0)

8.There ya go! You can move the second point around using a transform

Link to comment
Share on other sites

  • 8 months later...

Have you guys manage to make this work with redshift eventually?

 

On 3/22/2018 at 6:37 PM, Thomas Helzle said:

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

 

Link to comment
Share on other sites

I recently looked into it again and found a workaround that works for my uses:
I render a Z-Depth AOV set to mimimal distance with my image.
This allows to pick the Z-Depth in the Redshift viewers sidebar.
I then enter the value by hand in the camera.

Still hoping for a direct option at one point though.

The other things I looked at either didn't update at all without a manual refresh or triggered a full scene reload.

Maybe we should bug Juanjo once more... :-)

Cheers,

Tom

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...