I have a function Evaluate(), which is used to remap a noise value based on a curve/spline to make the noise more interesting. There are 3 inputs: the noise value to be remapped, the gradient of the noise, and the curve/spline. What I need help with is finding the new gradient.
// "noise" is in the range [0,1], and is the value form a noise function,
// "gradient" is the gradient of the noise function,
// and "filter" has the heights of an animation curve in the interval [0,1]
private void Evaluate(ref float noise, ref float3 gradient, in UnsafeList<float> filter)
{
int index = (int)(noise * (filter.Length - 1));
float remap = filter[index]; // f(x)
int h = index + 1 == filterResolution ? -1 : 1; // direction to evaluate the array
float remaph = filter[index + h]; // f(x+h)
gradient = (remaph - remap) / h * gradient; // curve derivative * noise derivative
noise = remap;
}