Search Unity

Question Post-Processing Spline : Bounds

Discussion in 'General Graphics' started by AHFontaine, Aug 11, 2021.

  1. AHFontaine

    AHFontaine

    Joined:
    Aug 3, 2017
    Posts:
    19
    Hi!
    I'm trying to make some sort of selectable "Color Splash" effect through the Color Grading module's "HuevsSatCurve" curve graph.

    However, I'm a bit stumped as to an error I get regarding the bounds when creating new Spline objects.
    As there is no information in the API on the expected values of "bounds", or any examples, I'm getting a constant error on every frame :
    Code (CSharp):
    1. IndexOutOfRangeException: Index was outside the bounds of the array.
    2. UnityEngine.Rendering.PostProcessing.Spline.Cache (System.Int32 frame) (at Library/PackageCache/com.unity.postprocessing@3.1.1/PostProcessing/Runtime/Utils/Spline.cs:95)
    Here's an example of my code in its most simplified form :

    Code (CSharp):
    1. void changeCurve()
    2.     {
    3.         switch (selectedColor)
    4.         {
    5.             case 0:
    6.                 upcomingValue = new Spline(animationCurves[0], 0.5f, true, new Vector2(0.0f,1.0f))  ;
    7.                 break;
    8.             case 1:
    9.                 upcomingValue = new Spline(animationCurves[1], 0.5f, true, new Vector2(0.0f, 1.0f));
    10.                 break;
    11.             default:
    12.                 break;
    13.  
    14.         }
    15.  
    16.     }
    What should I put in this "bound" argument section? It asks for a Vector2, but should I put the expected values on the curve? Something else?

    EDIT : I am now getting another error :
    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. UnityEngine.Rendering.PostProcessing.ColorGradingRenderer.GetCurveTexture (System.Boolean hdr) (at Library/PackageCache/com.unity.postprocessing@3.1.1/PostProcessing/Runtime/Effects/ColorGrading.cs:767)
    3. UnityEngine.Rendering.PostProcessing.ColorGradingRenderer.RenderHDRPipeline3D (UnityEngine.Rendering.PostProcessing.PostProcessRenderContext context) (at Library/PackageCache/com.unity.postprocessing@3.1.1/PostProcessing/Runtime/Effects/ColorGrading.cs:507)
    EDIT #2 : Found the issue, somehow my GUI was trying to calculate a Spline that didn't exist. I called my function and it's all good now.
     
    Last edited: Aug 11, 2021