Nuke: Normalizing animation curves

I have written a little tool to help turn animation curves into more useable numbers. I’ve called it CurveConverter and it’s just a node that takes an input curve and generates an output curve. Copy any animation into the input, then control other animations in your comp by linking them to the output.


Why is this useful?

Any time you have an animated value in your script that you wish to use to drive other animations, you will most likely have to multiply it by another value to get it into a useable range or scale it by hand in the curve editor. You might have to fiddle a while to get the peak and trough values to be where you want them. With this tool you don’t need to do any maths or manual scaling, just copy the curve across and enter your minimum and maximum values. It will scale the curve so that the highest peak is your maximum value and the lowest trough is your minimum value.


Practical example:

You have a plate with flickering fire light and you need to create a patch or CG character with flickering lighting to match. You might use a CurveTool node to analyze the average intensity of the plate (giving values perhaps between 0.028 and 1.124). Normally you might then link a grade node to that animation curve and work out what value you need to multiply by to get a good result.

Instead, go to a dark frame and adjust your grade node so your patch matches (perhaps using the multiply or gain), copy that value into the ‘New min value’ of a CurveConverter node. Then go to a bright frame, adjust to match then copy the value into the ‘New max value’. The patch should now animate between those two settings.

Alternatively, use a CurveConverter tool to convert that curve into values between 0 and 1. Then connect the result to a Dissolve node to switch between a dark grade setup and a bright grade setup. This way would allow you to do more complex grade adjustments in the two lighting states.

Another application would be matching animation to an audio curve.

Nuke: blip expressions to copy and paste

Using waves to drive animation in Nuke – part 2

In my previous article on this subject I gave some examples of expressions that you can just copy and paste into any value in Nuke to quickly create an infinitely repeating animating pattern. I was asked in the comments how to do a ‘blink expression every x frames’. I answered with ‘just use the square wave example’, but I realised that’s not what he was after. In this article I’ll give you some expressions that can be used for such a blink or ‘blip’ animation curve.

I have also made a new version of my gizmo WaveMaker that incorporates all of this, so you can download that if you’d prefer. It’s now in .nk format rather than .gizmo so it’s easier to share.

Square on/off blip every n frames

(((((sin(((frame*(pi*2/(freq/2))/2)+offset))+1)/2)) > cutoff ? 1 : 0) * (maxVal-minVal) ) + minVal

(Where ‘freq’ is the number of frames between blips, ‘offset’ is the time offset, ‘cutoff’ is a value between 0 and 1 which controls the width of each blip, ‘minVal’ is the lower value, ‘maxVal’ is the upper value. As in the previous article, either replace these variable names with your values, or better still, create a NoOp node, add some user knobs with those names and you’ll be able to adjust it on the fly)

Simpler version: ((( sin( ( ( frame * ( pi * 2 / ( 5 / 2 ) ) / 2 ) + 0.5 ) ) + 1 ) / 2 ) ) > 0.95 ? 1 : 0

(Blip pattern between 0 and 1, replace the ‘5’ to adjust amount of frames between blips, adjust the ‘0.5’ to move the whole thing back and forth in time, and adjust the ‘0.95’ to adjust the width of the blips)

So what’s it doing?

It’s really just a simple sine wave with another expression applied to see when that sine wave goes above the cutoff point. If so, set the value to 1, if not, set it to zero. If a high enough cutoff point is given (like 0.95) most of the time the sine wave will be below that value and only at the very tip of the peak go above it. The lower the cutoff, the longer the peak rises above the cutoff point and so the blip gets wider.

But if you need something a bit smoother than a simple on/off, I’ve also made this version:

Smooth pulse-like blip every n frames

(min((max((((((sin(((frame*(pi*2/(freq/2))/2)+offset))+1)/2)) > cutoff ? (((sin(((frame*(pi*2/(freq/2))/2)+offset))+1)/2)) : 0)) – cutoff,0) * (1/(1-cutoff)) * 1.001),1) * (maxVal-minVal) ) + minVal

Slightly simpler version: (min( (max( ((((( sin( (( frame*( pi * 2 / ( 10 / 2 ) ) / 2 ) + 1.55 )) + 1 ) / 2 )) > 0.7 ? (((sin( ( (frame * ( pi * 2 / ( 10 / 2 ) ) / 2 ) + 1.55 ) ) + 1 ) / 2 )) : 0 )) – 0.7 , 0 ) * ( 1 / ( 1 – 0.7 )) * 1.001) , 1 ))

(Smooth blip pattern between 0 and 1, replace the ’10’s to adjust amount of frames between blips, adjust the ‘1.55’s to move the whole thing back and forth in time, and adjust the ‘0.7’s to adjust the width of the blips)

Multiple blips

To make a complex repeating pattern of blips, create several user knobs using the above expressions, set to different values, then in another user knob max them all together:

max( max( blip1, blip2 ) , blip3 )

Manual looping

Remember, if you just need a quick repeating pattern for one thing in one shot, then building all these expressions is probably overkill because you can just draw a pattern in the curve editor, then tell Nuke to loop that pattern. This is more for the cases where you may have several things blinking on and off at different rates (perhaps a HUD, graphics display or warning lights on buildings), and you may need to go and adjust them all later. I personally wouldn’t go to the trouble of building all the knobs each time, that’s why I built BlipMaker into my WaveMaker gizmo so it’s available whenever I need it. My article where I took all my expressions from WaveMaker and made them available for quick copying and pasting has proved rather popular though so I thought I’d do the same for BlipMaker.