Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Focus Target Independent of aim Target

Discussion in 'Cinemachine' started by Onat-H, Sep 19, 2017.

  1. Onat-H

    Onat-H

    Joined:
    Mar 11, 2015
    Posts:
    195
    It would be great to have the option to define a focus target that overrides the currently set aim target. This us especially useful for the basic camera which doesnt have the option to set any target obviously, but also to rack focus on something while aiming the camera at something else.
     
  2. Adam_Myhill

    Adam_Myhill

    Joined:
    Dec 22, 2016
    Posts:
    342
    A number of ways to do this.

    If you want a full focus rig, simply make focus target object the child of the camera and have the camera look at it.
    upload_2017-9-20_8-12-30.png
    upload_2017-9-20_8-13-17.png

    You can animate that down Z and it's your custom focus rack object.


    You can also use the Target Group Camera.
    upload_2017-9-20_8-15-44.png

    Have one target be your FocusTarget object and the other being your character. Now you can blend between the two whenever you wish for a sort of focus rack / procedural target hybrid focus setup.
    upload_2017-9-20_8-16-21.png


    Otherwise, if you want to use the actual focus targets and throw some before/after focus in there, animate some +- values in the Focus Offset
    upload_2017-9-20_8-27-31.png
     
  3. Onat-H

    Onat-H

    Joined:
    Mar 11, 2015
    Posts:
    195
    Thank you Adam! That's a great idea, but unfortunately it doesn't solve my problem since the focus and the Composer share the same target. So once i change the focus targets position, the composition changes (which i want to keep) so let's say i have a closeup of the character in the left third of the screen, looking at something in the foreground on the right third and i want to rack the focus in the object without changing the framing. I also can't set a look at target when using the new framing transposer as it breaks my shot. And i think there is also no way of setting a target if i want to just use a basic static camera (which i still want to have integrated with CM for blending and focus purposes)
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    @Onat-H Why don't you animate the focus offset?
     
  5. Onat-H

    Onat-H

    Joined:
    Mar 11, 2015
    Posts:
    195
    Well I could do that, and it works great in Cutscenes for example where I know where exactly i want to have the focus plane. But i have a zoom function as can be seen here, where I use a target group to frame the shot to have both my main character and the object I'm looking at in.
    Focus.gif
    I want to have the focus on the object I'm looking at (independent from the group target), and since the distance between the target group and the object I'm looking at is always different, i can't set a specific offset. Of course I could calculate the distance between the two and set the offset accordingly, but that would only solve one part of the problem, since I still wouldn't have the option to set the focus on a static camera where i use hard constraints (as soon as i place something inside the look at for focus purposes, the camera aims despite having the hard constraint).
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    @Onat-H Yes I understand what you need. We've recognized that the "Hard Constraint" setting on the vcam aim is not expressive enough. Sometimes you want to say "I don't care if I have a LookAt target, leave my rotation alone!". We're looking at adding another setting so that this becomes expressible.

    In the meantime, you could probably cobble together a little script to set your focus depth independently of CM. Create a CM camera that doesn't set the focus distance, and elsewhere do something like this:

    Code (CSharp):
    1. void SetFocusDistance(Camera cam, float distance)
    2. {
    3.     var pp = cam.GetComponent<UnityEngine.PostProcessing.PostProcessingBehaviour>();
    4.     if (pp != null)
    5.     {
    6.         var dof = pp.depthOfField.settings;
    7.         dof.focusDistance = distance;
    8.         pp.depthOfField.settings = dof;
    9.     }
    10. }
     
    Onat-H likes this.
  7. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    @Onat-H Another option would be to add a custom behaviour to your vcam that takes a focus target, and in its Update it dynamically sets the CM focus offset to the difference between the vcam's lookAt and the focus target. That's probably the cleanest solution.
     
    Onat-H likes this.
  8. Onat-H

    Onat-H

    Joined:
    Mar 11, 2015
    Posts:
    195
    That sounds great Gregoryl! Looking forward for the update. And thanks for script.

    And a little Off Topic, is there any estimated time, when the Post Effects Stack V2 is going to be integrated?
     
  9. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    PostProcessing V2 is already integrated, just some final testing before we update the beta. Within the next week or two, for sure.
     
    Onat-H likes this.
  10. Adam_Myhill

    Adam_Myhill

    Joined:
    Dec 22, 2016
    Posts:
    342
    let us know how that goes @Onat-H - your project looks really cool What is it called?
     
    Onat-H likes this.
  11. Onat-H

    Onat-H

    Joined:
    Mar 11, 2015
    Posts:
    195
    I will :) Thank you! It's "Harold Halibut", you can watch our most recent Teaser here:

    And here is our Trailer, which shows more gameplay:


    Everything rendered realtime in Engine by the way...;)