Class KeyframeUtility
A helper function for interpolating AnimationCurves together. In general, curves can not be directly blended because they will have keypoints at different places. InterpAnimationCurve traverses through the keypoints. If both curves have a keypoint at the same time, they keypoints are trivially lerped together. However if one curve has a keypoint at a time that is missing in the other curve (which is the most common case), InterpAnimationCurve calculates a synthetic keypoint at that time based on value and derivative, and interpolates the resulting keys. Note that this function should only be called by internal rendering code. It creates a small pool of animation curves and reuses them to avoid creating garbage. The number of curves needed is quite small, since curves only need to be used when interpolating multiple volumes together with different curve parameters. The underlying interp function isn't allowed to fail, so in the case where we run out of memory we fall back to returning a single keyframe.
Inherited Members
Namespace: UnityEngine.Rendering
Assembly: Unity.RenderPipelines.Core.Runtime.dll
Syntax
public class KeyframeUtility
Examples
Example:
{
AnimationCurve curve0 = new AnimationCurve();
curve0.AddKey(new Keyframe(0.0f, 3.0f));
curve0.AddKey(new Keyframe(4.0f, 2.0f));
AnimationCurve curve1 = new AnimationCurve();
curve1.AddKey(new Keyframe(0.0f, 0.0f));
curve1.AddKey(new Keyframe(2.0f, 1.0f));
curve1.AddKey(new Keyframe(4.0f, 4.0f));
float t = 0.5f;
KeyframeUtility.InterpAnimationCurve(curve0, curve1, t);
// curve0 now stores the resulting interpolated curve
}</code></pre>
Methods
Name | Description |
---|---|
InterpAnimationCurve(ref AnimationCurve, AnimationCurve, float) | Interpolates two AnimationCurves. Since both curves likely have control points at different places in the curve, this method will create a new curve from the union of times between both curves. However, to avoid creating garbage, this function will always replace the keys of lhsAndResultCurve with the final result, and return lhsAndResultCurve. |
ResetAnimationCurve(AnimationCurve) | Helper function to remove all control points for an animation curve. Since animation curves are reused in a pool, this function clears existing keys so the curve is ready for reuse. |