Hi,
I have got a really silly question but I couldnt figure it out yet. I want the camera to stay focused on a specific object, even if the object or the cam is moving. Is there an easy one-klick solution?
Focus on object
25833 19 2- Rosko Ron
- Member
- 184 posts
- Joined: March 2015
- Offline
- malexander
- Staff
- 5212 posts
- Joined: July 2005
- Offline
- Rosko Ron
- Member
- 184 posts
- Joined: March 2015
- Offline
- verysame
- Member
- 59 posts
- Joined: May 2015
- Offline
twod
It's not exactly one click, but there's a Look At parameter on the Camera object. Select the object that you want to look at and it'll do the rest. It won't auto-frame the object, though.
What if I want to control the focus but I don't want to change camera's constraint?
In other words, I still want to control cam pos, rot, without pointing at any particular object in the scene, but I do want to control the focus distance (as if I were changing focus on my camera using the lens' focusing ring).
An example for this comes from Blender:
Andrew
Houdini Apprentice
Houdini Apprentice
- goldfarb
- Staff
- 3464 posts
- Joined: July 2005
- Offline
on the Sampling Tab of the camera object there is a parameter called Focus Distance
NOTE - this will only work when you have Depth of Field turned ON
if you select the camera and hit Enter in the viewport you'll get the handles for the camera, then use the “z” hotkey
now you'll have a little square thingy and two arrow thingys
move the square thingy to the distance you want to focus and the arrows to narrow the depth of field
I made a little file to show you one way to have more control over the two main parameters you need to adjust to have focus track an object
I built a geometry object and inside I merged in the camera origin and the center point of a null object
I made a poly line with those two points and the measured it's length
I then used a prim() function on the Focus Distance Parameter of cam1
now I can place the null object - called “focus_target” anywhere in the scene and that will drive the focal distance…which doesn't seem all that great…but if you unparent the null from the camera it can now become a child of anything in your scene…and if it's a moving object the focal distance will update as needed.
the other parameter you need to adjust is the F-Stop - large values mean a deep focal distance, small values mean a very tight range that will be in focus.
in the ropnet the mantra node has Enable Depth of Field turned ON.
you can make this way better of course…but it's something to play with
and you should check this out:
https://www.youtube.com/watch?v=01UlqkRRcgQ [youtube.com]
HTH
NOTE - this will only work when you have Depth of Field turned ON
if you select the camera and hit Enter in the viewport you'll get the handles for the camera, then use the “z” hotkey
now you'll have a little square thingy and two arrow thingys
move the square thingy to the distance you want to focus and the arrows to narrow the depth of field
I made a little file to show you one way to have more control over the two main parameters you need to adjust to have focus track an object
I built a geometry object and inside I merged in the camera origin and the center point of a null object
I made a poly line with those two points and the measured it's length
I then used a prim() function on the Focus Distance Parameter of cam1
now I can place the null object - called “focus_target” anywhere in the scene and that will drive the focal distance…which doesn't seem all that great…but if you unparent the null from the camera it can now become a child of anything in your scene…and if it's a moving object the focal distance will update as needed.
the other parameter you need to adjust is the F-Stop - large values mean a deep focal distance, small values mean a very tight range that will be in focus.
in the ropnet the mantra node has Enable Depth of Field turned ON.
you can make this way better of course…but it's something to play with
and you should check this out:
https://www.youtube.com/watch?v=01UlqkRRcgQ [youtube.com]
HTH
- Rosko Ron
- Member
- 184 posts
- Joined: March 2015
- Offline
- verysame
- Member
- 59 posts
- Joined: May 2015
- Offline
- tamte
- Member
- 8839 posts
- Joined: July 2007
- Offline
- verysame
- Member
- 59 posts
- Joined: May 2015
- Offline
tamte
you can just put following expression to Focus Distance parm without any extra steps
vlength(vtorigin(“.”, “../focus_target”))
it will measure world space distance from camera to focus object (in this case named focus_target in the same level as camera)
Thanks,
that's very handy!
Andrew
Houdini Apprentice
Houdini Apprentice
- Rosko Ron
- Member
- 184 posts
- Joined: March 2015
- Offline
- Matt Slanchik
- Member
- 1 posts
- Joined: Sept. 2013
- Offline
- goldfarb
- Staff
- 3464 posts
- Joined: July 2005
- Offline
Matt Slanchik
So long story short, there is no Maya F type function? You all are going on and on about coding F stops and random stuff but it's really a simple question. Can you focus the camera on something or not?
this thread is about a camera's focus - not what applications refer to as ‘focus’
if you want to snap the camera view to a selected Object - use ‘f’
- CYTE
- Member
- 709 posts
- Joined: Feb. 2017
- Offline
- chris wells
- Member
- 57 posts
- Joined: Jan. 2015
- Offline
- videlam
- Member
- 2 posts
- Joined: July 2017
- Offline
- CYTE
- Member
- 709 posts
- Joined: Feb. 2017
- Offline
- videlam
- Member
- 2 posts
- Joined: July 2017
- Offline
I made a script to create a null and set the focus on it.
On the shelf, create a new tool and copy/paste the code
On the shelf, create a new tool and copy/paste the code
import toolutils scene_viewer = toolutils.sceneViewer() selected_objects = scene_viewer.selectObjects("Select a camera and press Enter",allowed_types = ["cam"]) object = hou.selectedNodes() netparent = object[0].parent() selectname = str (object[0]) focus_obj = netparent.createNode("null", selectname+'_focus_target') d_focus=('vlength(vtorigin(".", "../'+str(focus_obj)+'"))') hou.parm('/obj/'+selectname+'/focus').setExpression(str(d_focus))
- Mike_A
- Member
- 282 posts
- Joined: Aug. 2018
- Offline
- Schinkenwurst
- Member
- 1 posts
- Joined: April 2021
- Offline
- trigfuller
- Member
- 1 posts
- Joined: Aug. 2018
- Offline
Hi,
I realise this is rather late but I've found videlam's bit of code really useful for creating a focus object for Karma.
I too wanted to get use it in solaris and having watched some of solaris essentials
https://www.sidefx.com/solaris-essentials-lops-karma-matx/ [www.sidefx.com]
I realised a way - use the code above to create your focus object and then when you go to solaris use stage or create a lopnetwork, then use scene import(all) for your whole scene or scene import (camera) import to bring in your camera - and it will include the focus distance to the object. If you go back to object context and fiddle around with the focus object - back in solaris it will update. It works animating the focus object for focus pulls etc.
This is probably really obvious to seasoned users but as someone who has just started experimenting with Karma it is not. As this topic is what I found when searching for karma focus object it might be one other people's first result.
Hope that helps someone.
I realise this is rather late but I've found videlam's bit of code really useful for creating a focus object for Karma.
I too wanted to get use it in solaris and having watched some of solaris essentials
https://www.sidefx.com/solaris-essentials-lops-karma-matx/ [www.sidefx.com]
I realised a way - use the code above to create your focus object and then when you go to solaris use stage or create a lopnetwork, then use scene import(all) for your whole scene or scene import (camera) import to bring in your camera - and it will include the focus distance to the object. If you go back to object context and fiddle around with the focus object - back in solaris it will update. It works animating the focus object for focus pulls etc.
This is probably really obvious to seasoned users but as someone who has just started experimenting with Karma it is not. As this topic is what I found when searching for karma focus object it might be one other people's first result.
Hope that helps someone.
-
- Quick Links