12
$\begingroup$

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?

$\endgroup$
16
$\begingroup$

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.

$\endgroup$
  • 1
    $\begingroup$ 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. $\endgroup$ – gandalf3 Mar 27 '14 at 7:02
  • $\begingroup$ 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. $\endgroup$ – sambler Mar 27 '14 at 23:08
  • $\begingroup$ 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. $\endgroup$ – gandalf3 Mar 27 '14 at 23:25
5
$\begingroup$

If you are texturing, there is a "random" value in the object info nodeenter image description here

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

$\endgroup$
  • 1
    $\begingroup$ Please summarize the links you have referenced in your answer. If the link goes down, so does your answer. $\endgroup$ – CharlesL Dec 9 '13 at 14:14
  • $\begingroup$ gandalf3 already mentioned this. $\endgroup$ – Samoth Apr 17 '16 at 19:47
0
$\begingroup$

I took a little different approach. I added a "value" node. Then key framed it to 0.5 at frame 1 and also to 0.5 at the last frame. Then using the F-curve modifier, I added noise to the F-curve. This has worked well for me to use with flickering lights and such.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.