Save camera focus distance in Rhino Named Views

If it is possible, it would be great to save Vray camera focus distance in rhino named views. I often use DoF in vray camera setting and I need to focus camera different in every named views (camera positions).
So now it is impossible for me to run a batch render, because before every camera position I need to manual set focus distance.

The pitfall is that the DOF target mode is set to a default distance of 200 instead of “camera target” like in the past. Since nearly nobody needs fixed 200 but nearly all user need the camera target it should be changed. So, @pavol_pastork you need to enable this mode and save the target of your camera per view. (There is a V-Ray button tool to move the focus to an object.)

@georgi.georgiev I reported it in the past and I ask me - could it be changed? Maybe now? :wink:

@Micha Thanks Micha. But, the V-ray focus to an object does not change the rhino camera target. It only change the focus distance in DoF in Vray.
So, I found _CameraTarget button in Rhino, but it turns set camera view so that camera target is always at center od camera. Workaround could be to first set the camera position, then set camera target and then rotate camera (without moving) to previous position.
@georgi.georgiev do you have another simpler solution? :slight_smile:

Maybe I have overseen something, but it should work like you need it:

* use the button to move the camera target
* save you your named view again
* use camera target DOF mode

So, always if you recall a view you get the saved target like you ask for - target per named view.

Screen Shot 01-06-21 at 09.05 AM.JPG

It does not work as expected. Button which you mentioned only change vray focus but it does not change rhino camera target position. Tried several times with showed camera points in rhino.

For now it works as I wrote: Set camera target (_CameraTarget) and then rotate camera (without moving by CTRL+ALT+Shift + RMB) to previous position. And then set Vray DOF to “Camera Target mode”

Right, my mistake. I use own button scripts since years for this job and thought the official button doe’s the same. You should try this scripts, it are my favourites. This scripts should be Rhino or V-Ray standard.

Move Focus

-_RunScript (
' Tested with Rhino3 SR4 only.
' Moves a perspective projection view's target plane to pass through a given point.
' Affected view is that which is active when the script is launched.
' User is prompted to pick a point, in any view, through which the initial view's
' target plane is to pass.
' Last modified - 2006 September 30

Option Explicit

MoveTargetPlane

Sub MoveTargetPlane()
Dim viewName
Dim targetCPlane
Dim userPoint, userPointCP
Dim newTargetPoint, newTargetPointCP
Dim cameraPoint
Dim cameraUp
viewName = Rhino.CurrentView
If Not Rhino.IsViewPerspective(viewName) Then
Rhino.Print "MoveTargetPlane works in perspective projection views only."
Exit Sub
End If
userPoint = Rhino.GetPoint("Pick point in desired target plane")
Rhino.CurrentView viewName
If IsNull(userPoint) Then
Rhino.Print "No point was picked."
Exit Sub
End If
Rhino.EnableRedraw False
targetCPlane = GetViewTargetCPlane(viewName)
userPointCP = Rhino.XformWorldToCPlane(userPoint, targetCPlane)
newTargetPointCP = Array(0,0,userPointCP(2))
newTargetPoint = Rhino.XformCPlaneToWorld(newTargetPointCP, targetCPlane)
cameraPoint = Rhino.ViewCamera(viewName)
cameraUp = Rhino.ViewCameraUp(viewName)
Rhino.ViewCameraTarget viewName, cameraPoint, newTargetPoint
Rhino.ViewCameraUp viewName, cameraUp
Rhino.Print "Target plane moved by " & CStr(Abs(newTargetPointCP(2))) & " units."
Rhino.EnableRedraw True
End Sub

Function GetViewTargetCPlane(viewName)
GetViewTargetCPlane = Null
If Not Rhino.IsView(viewName) Then Exit Function
Dim initialActiveView
Dim initialViewCPlane
Dim targetCPlane
initialActiveView = Rhino.CurrentView(viewName)
initialViewCPlane = Rhino.ViewCPlane(viewName)
Rhino.Command "_CPlane _View", False
targetCPlane = Rhino.ViewCPlane(viewName)
Rhino.ViewCPlane viewName, initialViewCPlane
Rhino.CurrentView initialActiveView
GetViewTargetCPlane = targetCPlane
End Function
)

Show focus plane

-_RunScript (
' Tested with Rhino3 SR4 only.
' Draws a 30% transparent plane on a perspective projection view's target plane.
' Affected view is that which is active when the script is launched.
' The drawn plane fills the view. Selection state of objects is unaffected.
' Last modified - 2006 September 30

Option Explicit

DrawTargetPlane 30

Sub DrawTargetPlane(transparency)
Dim viewName
Dim initialViewCPlane
Dim targetCPlane
Dim nearClipPlaneTopLeft, nearClipPlaneTopLeftCP
Dim cameraCP
Dim nearToTargetFactor
Dim targetTopLeftCP, targetBottomRightCP
viewName = Rhino.CurrentView
If Not Rhino.IsViewPerspective(viewName) Then
Rhino.Print "DrawTargetPlane works in perspective projection views only."
Exit Sub
End If
initialViewCPlane = Rhino.ViewCPlane(viewName)
Rhino.EnableRedraw False
Rhino.Command "_CPlane _View", False
targetCPlane = Rhino.ViewCPlane(viewName)
nearClipPlaneTopLeft = Rhino.XformScreenToWorld(Array(0,0))
nearClipPlaneTopLeftCP = Rhino.XformWorldToCPlane(nearClipPlaneTopLeft, targetCPlane)
cameraCP = Rhino.XformWorldToCPlane(Rhino.ViewCamera(viewName ), targetCPlane)
nearToTargetFactor = cameraCP(2) / (cameraCP(2) - nearClipPlaneTopLeftCP(2))
targetTopLeftCP = VectorScale(nearClipPlaneTopLeftCP, nearToTargetFactor)
targetTopLeftCP(2) = 0
targetBottomRightCP = VectorNegate(targetTopLeftCP)
AddTransparentPlane targetTopLeftCP, targetBottomRightCP, transparency
Rhino.ViewCPlane viewName, initialViewCPlane
Rhino.EnableRedraw True
End Sub

Sub AddTransparentPlane(topLeft, bottomRight, transparency)
Dim initialSelectedObjects
initialSelectedObjects = Rhino.SelectedObjects(True)
Rhino.UnselectAllObjects
Rhino.Command ("_Plane " & Rhino.Pt2Str(topLeft, 12, True) & Rhino.Pt2Str(bottomRight, 12)), False
If Rhino.LastCommandResult <> 0 Then
Rhino.Print "Error adding plane."
Else
Rhino.FirstObject True
Rhino.Command ("_-Properties _Material _Object _Enter _Transparency " & transparency & " _Enter _Enter"), False
Rhino.UnselectAllObjects
End If
If IsArray(initialSelectedObjects) Then
Rhino.SelectObjects initialSelectedObjects
End If
End Sub

Function VectorNegate(v)
VectorNegate = Null
If Not IsArray(v) Or (UBound(v) <> 2) Then Exit Function
VectorNegate = Array(-v(0), -v(1), -v(2))
End Function

Function VectorScale(v, d)
VectorScale = Null
If Not IsArray(v) Or (UBound(v) <> 2) Then Exit Function
If Not IsNumeric(d) Then Exit Function
VectorScale = Array(v(0) * d, v(1) * d, v(2) * d)
End Function
)

Thank you very much, It works. :o

Hi @pavol_pastork

You could also use Rhino’s Snapshots (LINK), which store V-Ray render settings and afterwards using V-Ray Batch Render to render all saved snapshots in a sequence.

Thanks for reminder. I tried Snapshots few times, but didn´t know about storing V-ray render settings too.

@georgi.georgiev What do you think about:

* make “camera target” as default DOF mode and
* adding a button to move the target so that the state can be saved to the named view?

@Micha

If I understand correctly the request, these options already exist in the render settings (LINK)

@georgi.georgiev Sorry, this isn’t what I mean. The tool at the render settings measure the distance and set the distance only.

* (A) Current method measure the distance from the scene and bring it to the DOF option. This can’t be saved to a named view. Default: distance mode

* (B) Requested workflow - a tool allow to move the Rhino camera target to a point where wanted and this change can be saved to a named view. Requested Default: camera target mode

In the past (B) was the default mode of VfR1/2. Much easier workflow by named views, also working for Bongo animation.

@Micha

Thank you for the clarification!

The request for Camera Target as default value has been logged.

Regarding the focus point, is the Pick Point option not sufficient enough? Understandably a visual representation of the point in the viewport would be helpful, however, the setting can be saved in a snapshot.
Otherwise if camera target is used as DOF mode, you could use Rhino’s Camera widget (F6) or properties panel to specify the target.

No, the Pick Point isn’t sufficient enough. Never I used it, because I prefer an easier workflow. Named Views are the basic standard - stable, easy to use, no unwanted side effects like by Snapshots. Named views are saving the target/focus point, why not use them?

My workflow is simple:
* personal Pick Point script moves the focus/target point of the camera
* save the named view

Using “Rhino’s Camera widget (F6) or properties panel to specify the target” is cumbersome and doesn’t work, since the view will changed, if the wanted focus point isn’t in the middle of the view. My script (it’s not from me) moved the target so that the focus can be free set. I used it really often. (The second script is not in the focus of my request, it’s nice to have only.)

I’m careful with Snapshot. It’s powerful, but has some problems. For example it can’t be used for the current scene without the file is reloaded. Very bad for large project files (1..2GB). Also I don’t trust Snapshot, it saves to much some times and some times it destroy things. I wouldn’t use it for simple tasks like saving views.