[Built-in render pipeline]
1st of all, import UnityEngine.Rendering.PostProcessing,
and get the PostProcessVolume.
using UnityEngine.Rendering.PostProcessing;
[SerializeField] PostProcessVolume m_vol;
2nd of all, get the PostProcessProfile and get the effect you want.
PostProcessProfile profile = m_vol.profile;
m_colorGrading = profile.GetSetting<ColorGrading>();
3.
and edit parameters.
using UnityEngine;
using UnityEngine.Rendering.PostProcessing;
namespace PostProcessBuiltinChangerDemo
{
public class PostProcessBuiltinChanger : MonoBehaviour
{
[SerializeField] PostProcessVolume m_vol;
ColorGrading m_colorGrading;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
PostProcessProfile profile = m_vol.profile;
m_colorGrading = profile.GetSetting<ColorGrading>();
}
// Update is called once per frame
void Update()
{
}
public void OnSetGamma(float _value)
{
Vector4Parameter gamma = m_colorGrading.gamma;
gamma.value = new Vector4(1f, 1f, 1f, _value);
m_colorGrading.gamma = gamma;
Debug.Log("gamma: " + gamma.value);
}
}
}
[Universal render pipeline(URP)]
1st of all, import UnityEngine.Rendering.Universal,
and get the UnityEngine.Rendering.Volume.
using UnityEngine.Rendering.Universal;
[SerializeField] UnityEngine.Rendering.Volume m_vol;
2nd of all, TryGet() the effect.
LiftGammaGain m_liftGammaGain
m_liftGammaGain = null;
m_vol.profile.TryGet(out m_liftGammaGain);
3.
and edit parameters.
using UnityEngine;
using UnityEngine.Rendering.Universal;
namespace PostProcessURPChangerDemo
{
public class PostProcessURPChanger : MonoBehaviour
{
[SerializeField] UnityEngine.Rendering.Volume m_vol;
LiftGammaGain m_liftGammaGain;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
m_liftGammaGain = null;
m_vol.profile.TryGet(out m_liftGammaGain);
}
// Update is called once per frame
void Update()
{
}
public void OnSetGamma(float _value)
{
m_liftGammaGain.gamma.value = new Vector4(1f, 1f, 1f, _value);
}
}
}
Top comments (0)