Search Unity

Blend between PostProcess Profile at runtime

Discussion in 'Cinemachine' started by Gandarufu, Sep 22, 2020.

  1. Gandarufu

    Gandarufu

    Joined:
    Nov 10, 2014
    Posts:
    22
    I'm currently trying to figure out, if there is a smart way of cross-fading different post process profiles on virtual cameras – the way you would do it via volumes and their weights.

    Say, when I examine an object in my game, I want to smoothly fade in a different profile, when I put the object back down, I want to restore the default profile of that camera.

    Blending between cameras with different profiles in their VolumeSettings doesn't produce a smooth result.
    Does anybody know if there's a way to override the DOF effect with a different profile that's not on a virtual camera?

    I'd appreciate any input.
    Thanks in advance!
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,720
    How is the result not smooth? Under the hood, the volume's weight gets animated between 0 and 1 to match the vcam blend curve, so it should be smooth under normal circumstances.
     
  3. Gandarufu

    Gandarufu

    Joined:
    Nov 10, 2014
    Posts:
    22
    I found that certain effects blend nicely, like the DOF effect. Others, however, like Color Adjustments or Vignette seem jumpy. They blend well in one direction, the other way however the blend takes place slowly and after the old camera is disabled, there's a very abrupt change.
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,720
    This sounds like more of a PostProcessing issue. You'll get the same results no matter what is driving the blend. Perhaps you can ask about this on the PostProcessing forum.
     
  5. Gandarufu

    Gandarufu

    Joined:
    Nov 10, 2014
    Posts:
    22
    I found out what was causing this. You need to have the same effects set up on both profiles, and have each override the value that's supposed to change. I assumed simply having the effect added was enough. Thanks anyways!
     
    Gregoryl likes this.
  6. Gandarufu

    Gandarufu

    Joined:
    Nov 10, 2014
    Posts:
    22
    One more question, if you don't mind, Gregoryl.
    Creating a clone of the active Vcam at runtime, just in order to change some post process effects, seems inefficient in my opinion. Is there a way to integrate a priority setting into the VolumeSettings, just like on the normal volumes? That way one could easily override certain effects on Vcams easily, without the need to have another camera for just that.
     
  7. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,720
    Yes, the volume settings have their own priority system. Under the hood, CM creates hidden global profiles with high priority and puts the active CM profiles in there. You can independently make global volumes with the profile overrides you want, and blend them in and out according to your own logic. The volume system will blend together all active global profiles according to their weights and priorities.
     
  8. Gandarufu

    Gandarufu

    Joined:
    Nov 10, 2014
    Posts:
    22
    The part CM creates hidden global profiles with high priority (float.MaxValue - (numBlendables - i - 1) * 1.0e35f; ) is what I'm struggling with, since I cannot override the CM profiles anymore with a higher priority. The only solution for me right now is to change that line of code in order to override the CM profiles with global volumes.
    Hence, I thought it might be neat to expose that priority parameter in the Volume Settings, or even the weight property.
     
    Last edited: Sep 23, 2020
  9. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,720
    Yes agreed, that value is too bold. We will make a note to reduce it for the next release. In the meantime, you could make that change yourself (instead of float.MaxValue, just use some reasonably high number - keeping float precision in mind).

    Alternatively, could you set up your profiles such that you don't need to override anything in the vcam profiles? I mean, make a global default profile, put most of the effects there, and only put in the vcam profiles those specific effects that the vcams explicitly need to override.
     
  10. Gandarufu

    Gandarufu

    Joined:
    Nov 10, 2014
    Posts:
    22
    Thanks, @Gregoryl! For now I set the priority to 50.0f and it's working as expected. The problem that I have in my escape the room kinda game, is that every Vcam has a somewhat different DOF setting. When the player examines an object, I need the whole background to blur out with a different DOF profile.
    Anyhow, the solution with changing the priority does the trick for now. Thanks again for your effort!