Noise Curve
Random noise as a curve is something I use all the time for all sorts of things. Here is an expression which uses Nuke's noise function to generate random noise along a curve. I use this to drive random flicker, luminance shifts, transforms or even camera float or film weave. Here, Nuke's noise function (noise (x,y,z)) is being called via some User Knobs.
Noise Curve using different settings.
There’s control over Frequency, Seed, Amplitude, Time Offset and Amount.
Here's the code. Since it's only using the noise function, it should work for older versions of Nuke such as 5.x as well as recent versions like 6.0v5.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
set cut_paste_input [stack 0] version 6.0 v5 push $cut_paste_input Multiply { value {{"(1*(noise((frame+(timeOffset*100))*freq, (seed*5), 0)*2-1)*amp+(amp*.7))+amount" i}} maskChannelMask -rgba.alpha name NoiseCurve selected true xpos 61 ypos -62 addUserKnob {20 parameters l Parameters} addUserKnob {7 freq l Frequency} freq 0.15 addUserKnob {7 seed l Seed t "\t\t\t\t\t\t" R 0 100} seed 2.5 addUserKnob {7 amp l Amplitude} amp 0.5 addUserKnob {7 timeOffset l "Time Offset" R 0 100} addUserKnob {7 amount l Amount} amount 0.75 addUserKnob {26 ""} addUserKnob {41 channels_1 l channels T Noise.channels} addUserKnob {41 value_1 l value T Noise.value} addUserKnob {26 "" l mask T ""} addUserKnob {41 maskChannelMask_1 l "" -STARTLINE T Noise.maskChannelMask} addUserKnob {41 maskChannelInput_1 l "" -STARTLINE T Noise.maskChannelInput} addUserKnob {41 inject_1 l inject -STARTLINE T Noise.inject} addUserKnob {41 invert_mask_1 l invert -STARTLINE T Noise.invert_mask} addUserKnob {41 fringe_1 l fringe -STARTLINE T Noise.fringe} addUserKnob {41 unpremult_1 l "(un)premult by" T Noise.unpremult} addUserKnob {41 invert_unpremult_1 l invert -STARTLINE T Noise.invert_unpremult} addUserKnob {41 mix_1 l mix T Noise.mix} } |
Comments
Thank you very much for this tutorial. We were searching for a solution to generate random curves for a while and this is doing a great job!
There is only a few Missing knob errors. While Adding the User Knobs to NoiseCurve instead of Noise the errors disappear.
Nicely done. I'm getting the same knob errors on the parameters tab as well. I found that if I drop a Noise node in the script and specifically name it "Noise", some of the errors go away, but not all.
I'm getting the following knob errors:
Missing knob: Noise.channels
Missing knob: Noise.value
Missing knob: Noise.fringe
Missing knob: Noise.unpremult
Missing knob: Noise.invert_unpremult
I'm on 6.2v2 if this helps. Also, the function still seems to work.
I can then rename it to something else without errors.
First of all, noise returns -1 to 1, so *2-1 actually shifts it to -3 to 1, making the curve somewhat unpredictable.
Also, adding amp * 0.7 makes the behavior of the curve even more unpredictable because if you e.g. have an amplitude of 0.1 and an offset of 0.9, you would expect it to go from 0.8 to 1.0.
Here's the code with these things fixed and a change in the order of attributes that makes more sense to me (and as a matter of personal preference, a phase of 1 now actually means a shift of 1 frame, not 100):
set cut_paste_input [stack 0]
version 6.0 v5
push $cut_paste_input
Multiply {
value {{"(noise((fram e+phase)*freq, (seed*5), 0)*amp)+offset" i}}
maskChannelMask -rgba.alpha
name NoiseCurve
selected true
xpos 61
ypos -62
addUserKnob {20 parameters l Parameters}
addUserKnob {7 freq l Frequency}
freq 0.15
addUserKnob {7 amp l Amplitude}
amp 0.5
addUserKnob {7 offset l Offset}
offset 0.75
addUserKnob {7 phase l "Phase" R 0 100}
addUserKnob {7 seed l Seed t " " R 0 100}
seed 2.5
}
Very usefull
RSS feed for comments to this post