Anyone know how to access post processing settings at runtime?

I’ve searched off and on for days on this subject, and so far nothing’s worked. I’m just trying to make a simple gamma/brightness slider, but no matter what I can’t get the Lift-Gamma-Gain settings to change at runtime other than manually tweaking them in the inspector. I’m on Unity 2019.4, and HDRP 7.3.1.

This can’t seriously be this complicated, right?!?

Thanks to another poster here , I discovered that the ‘w’ value of LiftGammaGain.gamma.value is what actually changes the gamma. x, y and z only change the color hues in r, g, b respectively. Not only that, but the xyz values in the inspector don’t even match the values that they have in code, for no apparent reason, and the w value isn’t even shown in the inspector.

tldr, here’s the full code for anyone in the future who might stumble upon this thread:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
public class UserSettings : MonoBehaviour
{
    private LiftGammaGain gamma;
    private Volume volume;
  
    private void Start()
    {
        volume = GetComponent<Volume>();
        volume.profile.TryGet<LiftGammaGain>(out gamma);
    }
    public void AdjustGamma(float value)
    {
        gamma.gamma.value = new Vector4(1f, 1f, 1f, value);
    
    }
}
2 Likes

Thanks, this help me a lot.

Also, after some testing I want to say:
in the Editor you see numbers like 0.62 0.66 0.74
so this number represent the color in this circle in a way not explained, so for practical purpose I suggest the next procedure:
1- Adjust the color of gamma you want and the gamma value you think is optimal.
2- Use Debug.Log(YourLiftGammaGainVariable.gamma.value.ToString(“0.00000”));
to save these values as default, Those are RGB (from 0 to 1) and gammaValue ( -1 to 1 ) (
3- Then Use the slider to set the minimum gamma you want, and the maximum gamma valid for your project, in every case use Debug.Log to read this values. And forget about the editor values.
You should notice that the only number changing is the last one (R, G , B , gammaValue)
4- To change gamma in runtime use:
YourLiftGammaGainVariable.gamma.value = new Vector4 ( R, G, B ,gammaValue)
and be sure
MinValue < gammaValue < MaxValue