2

I can't seem to find a way to easily change the color of the "bloom"-effect in the unity PostProcessing Stack from code. Here's what I've tried, with no effect:

var postProcessVolume = GameObject.FindObjectOfType<UnityEngine.Rendering.PostProcessing.PostProcessVolume>();

UnityEngine.Rendering.PostProcessing.Bloom bloom = postProcessVolume.profile.GetSetting<UnityEngine.Rendering.PostProcessing.Bloom>();

var colorParameter = new UnityEngine.Rendering.PostProcessing.ColorParameter();
colorParameter.value = mainPlayer.GenerateRandomColour();
bloom.color = colorParameter;
bloom.color.value = colorParameter.value;
bloom.enabled.value = true;   

The code compiles and runs fine, but has no visual effect. I have seen a couple of posts about this, including here and
here. I have tried all approaches I was able to find in those links, with no success.

Is there not a simple way to change the color of the "bloom"-effect from within code in Unity?

ChrisC
  • 892
  • 2
  • 12
  • 33

3 Answers3

1

Use the Override (value) method:

    Bloom bloom = postProcessVolume.profile.GetSetting<UnityEngine.Rendering.PostProcessing.Bloom>();
    var colorParameter = new UnityEngine.Rendering.PostProcessing.ColorParameter();
    colorParameter.value = Color.red;
    bloom.color.Override(colorParameter);

https://docs.unity3d.com/Packages/com.unity.postprocessing@2.0/manual/Manipulating-the-Stack.html

STALER
  • 186
  • 2
  • 14
1

Not sure if anyone needs this but i did somethign similar to vignette with URP

private Vignette GetVignette()
{
    for (int i = 0; i < volume.profile.components.Count; i++)
    {
        if(volume.profile.components[i] is Vignette)
        {
            return (Vignette)volume.profile.components[i];
        }
    }
    return null;
}
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 21 '22 at 06:11
0

This worked easier for me:

 GetComponent<Volume>().profile.TryGet<Bloom>(out var bloom);
 //set bloom tint color
 bloom.tint.Override(tintColor);