Search Unity

Wrong Distance Calculation in Cinemachine Volume Settings

Discussion in 'Cinemachine' started by Onat-H, Apr 21, 2019.

  1. Onat-H

    Onat-H

    Joined:
    Mar 11, 2015
    Posts:
    195
    Hey there,

    I just discovered a little bug:
    When using the Cinemachine volume settings with a physical camera, the focus is currently off. It seems like the distance is calculated between the camera transform and the target transform, while it needs to be calculated from the image plane.

    By the way, did the last update remove the cinemachine trigger (the one which could be used to activate and deactivate cameras when walking through it)? Could we have it back? it was really useful... :D
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Hi Onat,

    Yes, the distance is the distance between the transforms. The image plane is assumed to be located at the origin of camera space.

    CinemachineTriggerAction.cs hasn't been removed. You should see it in com.unity.cinemachine/Runtime/EventHelpers. Is it not there?
     
  3. Onat-H

    Onat-H

    Joined:
    Mar 11, 2015
    Posts:
    195
    Well I measured it with a Unity cube (my tape measure) of 7.6m length since the calculated distance shown in the inspector was 7.6 and attached the results in the following. The target is Harold in this case, and as you can see at that distance (from the camera transform) the image is out of focus. When I move my tape measure so that it starts at the start of what seems like an image plane gizmo, the tip of the camera is in line with the computer in the BG which seems to be in focus...

    Found thee cinemachine trigger action by the way, but it seems like the references to the cameras got lost in one of the updates, do you know if there is a quick fix for that?
     

    Attached Files:

  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Hmmm... interesting. In fact that gizmo shows the near clip plane. Try reducing that in the vcam. I will check with the Post Processing people to see how that focus distance calculation is done.

    Are any prefabs involved?
     
  5. Onat-H

    Onat-H

    Joined:
    Mar 11, 2015
    Posts:
    195
    Hmm... actually it didn't have any effect, so I guess at least that was seemingly a coincidence. What I still noticed though was that the in-focus area is always further away than the calculated distance. By the way, I also tried other settings to see if anything was influencing it, and while I didn't find any clues I noticed the following which might also be interesting for thee PP team: None of the camera parameters (Sensor size, aperture value etc. ) seems to affect the d.o.f... which basically makes the whole "physical camera" thing pretty pointless right now, besides of having real world lens values. (Oh and it's still resolution dependent... which I thought was fixed in HDRP Post Processing).


    No, only scene objects unfortunately.
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    PP team is looking into the focus distance thing.
    For the lost references, that's really strange.
    What version of CM are you using?
    Do the references come back if you downgrade to an earlier version?
    Have you disabled either the Physics or the Physics2D modules in Unity?
     
  7. Onat-H

    Onat-H

    Joined:
    Mar 11, 2015
    Posts:
    195
    Hi Gregoryl, do you have an update regarding the wrong focus distance? I totally missed your answer by the way, seems it was only a bad package import or something. After reimporting, everything worked again.
    By the way, it seems that I can't have cinemachine volume settings on a Vcam inside a prefab.. the cam loses the reference to the script and breaks the prefab (can't override changes anymore). Is this a known Problem? is there a workaround?
    Thank you
     
  8. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Hi Onat,
    The PP team unfortunately does not yet have a fix for the focus distance. It's on their list.
    For the prefab problem, yes it's known. It's a bug in Unity (fixed, but only for 2019.3) that has to do with conditionally-compiled scripts not being recognized in some circumstances. The workaround is to remove the #ifdef at the top of CinemachineVolumeSettings. You'll have to edit the CM source.
     
    Last edited: Jul 12, 2019
  9. Onat-H

    Onat-H

    Joined:
    Mar 11, 2015
    Posts:
    195
    Thanks for the quick reply, 2019.3 sounds good, we are already on 2019.2 anyway, and until then I'll just impot it locally. Is there an estimated time already for the focus distance problem? Also again that's actually a pp-team thing... but the resolution dependency also still doesn't seem to be fixed..