Search Unity

Separate focus distance for every virtual camera

Discussion in 'Cinemachine' started by second_ich, Jul 6, 2022.

  1. second_ich

    second_ich

    Joined:
    Oct 17, 2020
    Posts:
    39
    Hello, I have created a product visualisation with a cinemachine and 3 virtual cameras. So you can switch between 3 camera positions.

    Now I want to add some depth of field. So every virtual camera needs a different focus distance. But I can only adjust the focus distance on the main camera which affects all virtual cameras.
    How can I set the focus distance for every virtual camera?

    Thank you
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Are you using HDRP, or URP, or builtin graphics?

    In HDRP or URP, focus distance is set using a volume with post-processing effect. You can add post-processing effects to the vcam, and they will blend in and out along with the vcam. Use the CinemachineVolumeSettings extension..
     
    second_ich likes this.
  3. second_ich

    second_ich

    Joined:
    Oct 17, 2020
    Posts:
    39
    Thanks a lot. With the CinemachineVolumeSettings it finally worked.

    I was watching some tutorials and tried to use a Post Process Volume and Post Process Layer but this never worked for me.

    Im using HDRP.

    Is there a way to also use a different focus distance for the Top, Middle and Bottom Rig in the Free Look Camera?
     
    Last edited: Jul 8, 2022
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    The best way would be to use the FocusTracking field inside VolumeSettings. Set the target to be your LookAt target. It will dynamically adjust the focus distance to match the target.
     
    Last edited: Jul 8, 2022
  5. second_ich

    second_ich

    Joined:
    Oct 17, 2020
    Posts:
    39
    It seems this only works if the Focus Mode in Depth of Field is set to Physical Camera. But then the front of the object is also blurred, what I don't want.

    If I set Focus Mode to Manual Ranges I can make the background getting blurred without affecting the front, but now the focus point doesn't adjust to the camera height.

    I probably need some kind of the autofocus system.
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Yes, focus tracking only works with physical mode, because it manipulates the focus distance. To focus on the front of the object, you can adjust the focus tracking offset.
     
  7. second_ich

    second_ich

    Joined:
    Oct 17, 2020
    Posts:
    39
    I have a very last question. Is there a simple way to set up a start position for the FreeLookCamera when using cinemachine rig?
     
  8. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    What is the Binding Mode of the FreeLook?
     
  9. second_ich

    second_ich

    Joined:
    Oct 17, 2020
    Posts:
    39
    Binding Mode is World Space
     
  10. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    So the camera position is determined by the target position and by the Value members of the FreeLook's X and Y axes. You can set the values to be what you want at start time. You can't directly set the transform because the FreeLook's positioning algorithm will overwrite it.
     
  11. second_ich

    second_ich

    Joined:
    Oct 17, 2020
    Posts:
    39
    Ok, thank you.