- Home /
,How to blend Color Curves through script - Color Curve Interpolation
Hello,
I have been trying to automate interpolation between two different color curve components. It seems however, that there is minimal/no functions that Unity provides to help with this. In fact, there is almost zero information on color curve implementation via script on the internet. I am wondering if it is possible to automate this interpolation over time via script and if so, how would people go about this.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
public class PPEffectsChanger : MonoBehaviour
{
public VolumeProfile blackandwhiteDark;
public VolumeProfile yellow;
public ColorCurves colorCurvesYellow;
public ColorCurves colorCurvesBW;
public void SetYellowVolumeActive()
{
VolumeParameter paramYellowHS = colorCurvesYellow.hueVsSat;
VolumeParameter paramBWHS = colorCurvesBW.hueVsSat;
blackandwhiteDark.TryGet<ColorCurves>(out colorCurvesBW);
yellow.TryGet<ColorCurves>(out colorCurvesYellow);
colorCurvesBW.hueVsSat.SetValue(paramYellowHS);
colorCurvesBW.hueVsSat.Interp(colorCurvesBW, colorCurvesYellow, t);
}
}
As you can see from this excerpt of code, I can set the ColorCurves via script using: "colorCurvesBW.hueVsSat.SetValue(paramYellowHS);", but I I cannot use this function to interpolate between two parameters...
Furthermore, the "Interp" function requires two TextureCurves to work properly.
I hope I have posted this in the right section, as I am new to asking questions on the forums (usually someone's got an answer out there already!). ,Hello,
I have been trying to automate interpolation between two different color curve components. It seems however, that there is minimal/no functions that Unity provides to help with this. In fact, there is almost zero information on color curve implementation via script on the internet. I am wondering if it is possible to automate this interpolation over time via script and if so, how would people go about this.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
public class PPEffectsChanger : MonoBehaviour
{
public VolumeProfile blackandwhiteDark;
public VolumeProfile yellow;
public ColorCurves colorCurvesYellow;
public ColorCurves colorCurvesBW;
public void SetYellowVolumeActive()
{
VolumeParameter paramYellowHS = colorCurvesYellow.hueVsSat;
VolumeParameter paramBWHS = colorCurvesBW.hueVsSat;
blackandwhiteDark.TryGet<ColorCurves>(out colorCurvesBW);
yellow.TryGet<ColorCurves>(out colorCurvesYellow);
colorCurvesBW.hueVsSat.SetValue(paramYellowHS);
colorCurvesBW.hueVsSat.Interp(colorCurvesBW, colorCurvesYellow, t);
}
}
As you can see from this excerpt of code, I can set the ColorCurves via script using: "colorCurvesBW.hueVsSat.SetValue(paramYellowHS);", but I I cannot use this function to interpolate between two parameters...
Furthermore, the "Interp" function requires two TextureCurves to work properly.
I hope I have posted this in the right section, as I am new to asking questions on this space (usually someone's got an answer out there already!).