Post Processing Script Changes in Recent Updates?

I’ve been playing around with a script to fade in/out various post-processing settings- bloom, vignette, and chromatic abberration. It worked perfectly in a previous version of Unity, but now everything is broken. The new version of post processing also seems unnecessarily contrived.

Before updating I found a good, functional code example online and VS did the rest by providing the applicable terms for my experimentation, but I can’t find any comprehensive documentation for the new syntax changes and just don’t know where to start. Clearly everything is now wrong, as VS has found 54 errors in my code.

Can anybody at least point me to a full outline of the correct terms, if not provide the relevant corrections to my old code?

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.PostProcessing;


public class PostControl : MonoBehaviour {

    public PostProcessingProfile profile;
    public float bloomSpeed = 0.5f;
    public float vinspeed = 0.2f;

    //directions
    private float vinDir = 1;
    private float direction = 1;
    private float chromDir = 1;
   
   
    void Start () {
        BloomModel.Settings bloomSettings = profile.bloom.settings;
        bloomSettings.bloom.intensity = 0;
        VignetteModel.Settings vinSet = profile.vignette.settings;
        vinSet.intensity = 0;
        ChromaticAberrationModel.Settings chromSet = profile.chromaticAberration.settings;
        chromSet.intensity = 0;
       
    }
   
   
    void Update () {
        BloomModel.Settings bloomSettings = profile.bloom.settings; // sets values for stack settings
        VignetteModel.Settings vinSet = profile.vignette.settings; //just type in thing you want to change and VS finds it
        ChromaticAberrationModel.Settings chromSet = profile.chromaticAberration.settings;

        bloomSettings.bloom.intensity += direction * bloomSpeed * Time.deltaTime;
        vinSet.intensity += vinDir * vinspeed * Time.deltaTime;
        chromSet.intensity += chromDir * vinspeed * Time.deltaTime;    


        if (bloomSettings.bloom.intensity >=5)
        {
            direction = -1;
        }
        else if (bloomSettings.bloom.intensity <=0)
        {
            direction = 1;
        }

        if (vinSet.intensity >=1 )
        {
            vinDir = -1;
        }

       else  if (vinSet.intensity <= 0)
        {
            vinDir = 1;
        }

       if (chromSet.intensity >= 1)
        {
            chromDir = -1;
        }

        else if (chromSet.intensity <= 0)
        {
            chromDir = 1;
        }


        //Debug.Log("Bloom Intensity:" + bloomSettings.bloom.intensity);
        //Debug.Log("VinTensity:" + vinSet.intensity);
        Debug.Log("chrom value:" +chromSet.intensity);

        profile.bloom.settings = bloomSettings;
        profile.vignette.settings = vinSet;
        profile.chromaticAberration.settings = chromSet;
    }
}

You need to manipulate the volume, either global or local, rather than a global profile since v2:

Some combination of those should get you started.

1 Like

I’m a novice with coding and especially with unity, so I just have to figure things out from whatever working examples I can find. I got the Vignette script working so I think I can stumble my way through from there.

Thank you!