Search Unity

Feedback Post process stack integration flaw with priority, toggling effects

Discussion in 'Cinemachine' started by sacb0y, Jun 5, 2020.

  1. sacb0y

    sacb0y

    Joined:
    May 9, 2016
    Posts:
    873
    So I've come to a conclusion that cinemachine has a serious flaw in it's implementation of PPSV2.

    The way it works is it forces a volume to be global for the duration of the active camera, and forces said volume to be the max possible priority. This is a very strange method, cause it makes a simple problem very complicated to solve.

    If i want to manage my post processing effects for my entire game, I can't do that easily so long as I'm using vcams for effects use.

    The easiest solution would be to have a main volume, and have that volume control if an effect is enabled or not, and the quality. But instead I have to find someway to disable an effect on ALL profiles which is just excessive. Especially when you could have 100+ profiles and hundreds of vcams.

    I think the priority should be, if anything high but not absolute maximum. Or instead a toggle should exist for if it's forced or not. One way or another the current implementation is not ideal.

    The problem code is here in line 164 CinemachinePostProcessing.cs
    Code (CSharp):
    1. if (!(profile == null)) // in case it was deleted
    2.                 {
    3.                     PostProcessVolume v = volumes[i];
    4.                     if (firstVolume == null)
    5.                         firstVolume = v;
    6.                     v.sharedProfile = profile;
    7.                     v.isGlobal = true;
    8.                     //this is the problem line here
    9.                     v.priority = float.MaxValue-(numBlendables-i)-1;
    10.                     //-------------------------
    11.                     v.weight = b.m_Weight;
    12.                     ++numPPblendables;
    13.                 }
    Please improve this! Especially since i can't seem to easily fix this myself without it undoing the fix... :/
     
    Last edited: Jun 5, 2020
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Thanks for the feedback.

    The reason that the vcams have max priority is that CM makes the assumption that if you've attached an effect to a vcam, it's because you want it there and you want it to override your default settings. If you don't want an effect to override your default settings, then don't include it in the vcam profile. Just put it in the default profile instead of attaching it to all the vcams.

    Can you give a specific example of a use-case where this approach won't work?
     
  3. sacb0y

    sacb0y

    Joined:
    May 9, 2016
    Posts:
    873
    Well the way I use VCams is largely for cinematic effect, my game is very visual and i like to tune every camera for a wide range of animations and scenarios. A single scene could have like 20-30 cameras, each with slightly different effects or focuses.

    My main issue is performance, if i want players to be able to adjust post processing quality or effects used, under the current setup i can't do that without adjusting EVERY possible postprocess profile at one time.

    My most common post process effect I add to a VCcam is DoF and bloom, I can't simply have Dof have the same settings on every camera (you get more or less blur depending on distance and aperture/etc ) so a simple single volume won't work, so most vcams have a profile with different aperature settings and such for the specific scene. I also absolutely HAVE to have a profile on the vcam for it to track focus which forces the effect on anyway.

    Like I can't tell the vcam to not force the effect on or not force the effect off. I basically have to turn the effect on even if i just want tracking.
    upload_2020-6-9_9-34-15.png

    So the only solution if i want to turn off DoF globally is to go through the complex process of disabling dof in every single post process profile in the project, so if a player turns off "dof" in their settings it applies globally. Do understand i'm not much of a programmer, i've seen people achieve this but it seemed very complex and imo should be unnecessary to do. By the end of my games production i could have 1000's of vcams and profiles, so to me this could be a big issue.

    This issue also applies when i want to use stronger bloom for a specific camera angle for a scene or something, i can't enhance the effect without forcing the effect to be turned on.

    This also makes for a massive issue if I'm targeting mobile platforms as well as PC, I have all these VCams with all these profiles that have effects that aren't good for mobile. And even if I turn off "depth/stencil" for android PPS V2 forces the effect on (this does not happen with URP though only standard). So unless i remove the effect from every possible profile when i want to do an android build DoF will be forced on for mobile.

    So far, i've just solved this for now by editing the cinemachinepostprocess.cs before i make a build, just setting the priority to 500 or something. I understand having a high priority but absolute maximum is silly.

    Otherwise there's no simple way to override these effects, and attempting to scale back use just doesn't seem like the way the system is designed to be used and benefits from the most.
     
    Gregoryl likes this.
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Thanks for that description. It's helpful.

    So if I understand correctly the use-case not supported is the ability to globally disable an effect. You would like to do it by having an even-higher-priority profile in which you can selectively disable effects. Makes sense to me.
     
  5. sacb0y

    sacb0y

    Joined:
    May 9, 2016
    Posts:
    873
    Yes, that would be ideal as well!
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    You say "as well"... isn't it what you're doing? Setting the vcam profile to 500 and having a default with a higher priority that just disables? If not that, then what?
     
    Last edited: Jun 9, 2020
  7. sacb0y

    sacb0y

    Joined:
    May 9, 2016
    Posts:
    873
    Well the way you describe it sounds a bit different, you described it as a way to give a volume absolute priority rather than allow a vcam to have reduced priority.

    Either way is fine. so long as i can easily globally set if a post process effect is on or not.

    I will say my method doesn't seem perfect, you see i've noticed some mild flickering when going between vcams when i have dof turned off and it transitions to a camera with no dof post process on it. it's like even if globally the dof is off, it still somewhat tries to turn it on?

    I'm just glad you understand the general idea, how you guys deem it's best to do it i can understand. :p
     
  8. sacb0y

    sacb0y

    Joined:
    May 9, 2016
    Posts:
    873
    There's still no good solution for this :(
     
  9. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    We have made the change described above. Instead of using float.MaxValue as priority, we use CinemachineVolumeSettings.s_VolumePriority, which is currently set to 1000.
     
  10. sacb0y

    sacb0y

    Joined:
    May 9, 2016
    Posts:
    873
    Oh I wasn't aware! Awesome! Maybe now i can avoid having to change 100+ volume profiles just to turn off an effect. I don't remember seeing it in the change logs.

    I guess from there it really just comes down to post process being setup with an "enabled" option or intensity setting where "0=off", instead of "activation" to avoid processing the effect.

    I'm off to experiment!
     
    Gregoryl likes this.