The 'random' expression

Written by Victor Perez on .

Here you are a brief explanation of all controls in Nuke's random expression.

This is the full function 'by default':
(random(1,frame*1)*1)+0
or just simplified: random(1,frame)
This creates a curve containing random values between 0 and 1.

The breakdown controls:
(random(seed,frame*frequency)*amplitude)+valueOffset

seed value randomly changes the curve without modify its nature
frequency value increase or reduce the amount of oscillations (1
= 1 peak per frame by default)
amplitude indicates the maximum value of your oscillation (max=1 by default)
valueOffset value decides where the curve sits on Y axis (0 by default)


Example:
if you want to generate a curve with random values between 2 and 8 with a (low) frequency of 1 peak every 5 frames this is the formula:
(random(1,frame*0.2)*6)+2

You can use this function as an expression in any numerical knob.

Comments   

 
+2 # Ahad Mohebbi 2012-04-04 16:02
Thanks VICTOR PEREZ
it is very useful for me
Thanks again
 
 
+1 # frank rueter 2012-04-04 16:10
just to avoid confusion: this is actually a Nuke expression, not TCL. Doesn't make it any less useful though :-)
 
 
+1 # Anton Moss 2012-11-06 11:48
Thanks a ton Victor, this is very useful.
 
 
+1 # Jed Smith 2012-12-23 23:46
Thanks for this helpful explanation! If anyone might find it useful, I created a simple gizmo wrapper / frontend to this expression which you can use to generate a source of random values, without having to fiddle with the expression's values.
http://pastebin.com/p4fzUu8C
 
 
+1 # martin constable 2012-12-24 00:07
In my experiance, when wrapping this up in a node it is best to pull off two values for the noise, each one using a different seed, but identical in other respects. This arrangemnt is most usefull for random style XY movements.
 
 
+3 # charles k 2014-10-20 15:28
How to have a different seed when you duplicate your node ?

In AE it's the default setting. Duplicate a layer with a random() expression and the seed will be different.

In Nuke, to make this, I write "xpos" or "ypos" in the seed parameter. It will take the position where the node was created as the seed.

random(ypos, 1)
 
 
+1 # Reed Eriksson 2016-02-22 19:42
How do you get random values between 1 and 1.5?
 
 
+3 # Frank Rueter 2016-02-23 00:17
random() always returns a value between 0 and 1, so in order to adjust the output to always be between a custom minimum and maximum value you can do something like this:
random(frame) * (myMaxValue-myM inValue) + myMinValue

so in your case this would be:
random(frame) * (1.5-1) + 1

if you link min and max values to user knobs you can drive this interactively.
 
 
0 # Reed Eriksson 2016-03-16 22:32
Thank you!!
 
 
0 # Rion . 2019-01-28 12:25
is that possible to make random expression.
ie: 1st frame value 1
2nd frame value 0
 
 
0 # Hossein Ghasemi 2019-01-30 08:59
Hello.
I need source code of random and noise function in nuke for using in maya.
can you help me?
 

You have no rights to post comments

We have 2473 guests and 67 members online