# Is it possible to get a random number in the node editor?

Is it possible to generate a random number for use in the node editor?

I am aware of the Object Info node, but I want a random number which I have more control over.
Ideally I could change it with some sort of "seed" vale and be able to define limits for maximum and minimum values.

How is this possible?

There is now a White Noise Texture node, which takes input Coordinates and outputs a totally different value (either RGB or between 0 and 1) for even the slightest variation in input.

The input can be set to use 1D, 2D, 3D or 4D. If using 4D, the 4th input, W, can be used as an additional seed to the node.

• Oops, just duped you. And in the wrong place. Will link here, and delete mine after a bit. Feb 27 '21 at 11:10
• @RobinBetts No biggie !! I love me some seizure inducing GIFs :D Feb 27 '21 at 14:41
• that's what i was looking for! +1 Oct 8 '21 at 7:33

That would be through drivers. You can add an Input->Value node to feed into other nodes or add a driver to an editable value on any other node.

A simple way to get random values is edit the value and enter #noise.random() This will give random values between 0 and 1, you can expand the entry to multiply the value if you want it larger or add a minimum value.

To get more control over the generated value you can create a script and use bpy.app.driver_namespace["name"] = funcname to provide access to any function you define. The script name must end in .py so that you can register it and auto run python scripts also needs to be enabled.

• I tried using noise.random() as a scripted expression, however the debug value stayed as 0 and it did not appear to work in a render.
– gandalf3
Mar 27 '14 at 7:02
• You may need to update dependencies, but one thing I have seen stop this working is if the interpolation type of the driver is set to constant. The other is not enabling auto-run python scripts, you should see a notice if that is the case. Mar 27 '14 at 23:08
• I got it working :) I had to save the file first. Something to do with auto run perhaps? I have it enabled but with some excluded directories.
– gandalf3
Mar 27 '14 at 23:25
• Does this expression evaluate on each frame or on each sample?
– Matt
Nov 21 '20 at 3:11
• @Matt If you use random for a colour input you get the same colour over the object, per sample would give you variation. Nov 21 '20 at 6:23

If you are texturing, there is a "random" value in the object info node

Not entirely sure what your application is, but there's more info on the object info node at http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Nodes/More

Also found this post here on stack exchange: Random maps in cycles