1
$\begingroup$

Using the Noise Texture node in Geometry Nodes, how do you set it up so that the pattern is randomized with each use of the Modifier?

There is no 'seed' input for Noise, and adding a Random Value node to the W-input doesn't work as expected (I posted about that here).

Any suggestions?

$\endgroup$
6
  • $\begingroup$ Connect W- to the node group input and use the script to change each modifier W input. $\endgroup$
    – X Y
    Aug 16, 2023 at 5:21
  • $\begingroup$ What do you mean by 'use the script'? $\endgroup$ Aug 16, 2023 at 6:27
  • $\begingroup$ Python scripting in Blender Text Editor. For example, this is a "Make all subgroups single" script. blender.stackexchange.com/questions/298986/… $\endgroup$
    – X Y
    Aug 16, 2023 at 6:34
  • $\begingroup$ And there is a similar post to your question: blender.stackexchange.com/questions/298795/… $\endgroup$
    – X Y
    Aug 16, 2023 at 6:38
  • $\begingroup$ I investigated that issue in the past and unfortunately there is no better solution than the one proposed by XY. Maybe you can get rid of the requirement to use a script to randomize inputs in the modifier stacks of all objects, if those objects reside in a a single collection, and you have a single geonodes object 'drawing' stuff for all objects in that collection… $\endgroup$ Aug 16, 2023 at 10:03

1 Answer 1

1
$\begingroup$

A simple solution

The simple solution assumes objects don't move and you never have objects with same location (or you're fine with them synchronizing the random values in such case):

If you want to be able to move those objects without rerandomization (for animation purposes), you could use a Simulation Zone:

XY's solution

random_type = 0 
"""
random_type = 0 - same behavior as "Random per Object" in shaders, value depends on object name
random_type = 1 - as above but multiple modifiers on the same object 
random_type = 2 - the script randomizes different numbers for the same object each time it is run
"""
from bpy import context as C, data as D
from random import seed, randint
randomizer = D.node_groups['Randomizer']
input_id = next(i.identifier for i in randomizer.inputs if i.name == 'Seed')

for ob in C.selected_objects:
    if random_type == 1:
        seed(ob.name)
    mods = (m for m in ob.modifiers if m.node_group == randomizer)
    for mod in mods:
        if random_type == 0:
            seed(ob.name)
        random = randint(-2**31, 2**31-1)
        mod[input_id] = random
    ob.data.update()

  • Random Value node is there, because Noise Texture's $W$ dimension is limited to $-1000...+1000$ range [it isn't! Only the interface limits the input in that range; Learned it thanks to folks on Discord]; the code could be modified to generate a random float in that range, but this way randomizing seeds is decoupled from the node trees using those seeds.
  • The script has to be run each time you add a new object, and - if you want the seeds to be synchronized with object names - each time you rename an object.
  • You need to select all relevant objects before running the script but that could be trivially changed if needed…
  • Notice how I usually don't screenshot a node tree name, but in this case I did because that's how the script discriminates the correct modifiers: there could be Geonodes modifiers with a seed input that is not supposed to be randomized.
$\endgroup$
3
  • $\begingroup$ Thank you Markus! It does seem that these are the best and (so far) only methods for achieving this effect. In particular I like the Simulation Zone combo, I've never seen that one. How do those nodes work, exactly? $\endgroup$ Aug 17, 2023 at 22:51
  • 1
    $\begingroup$ @GlenCandle on frame #1 the "Simulation Input" evaluates data connected to it (like a normal node). Then inside the zone stuff happens, and passes data to "Simulation Output". The "Simulation Output" passes it further to the right (like a normal node), but also saves this data in cache. On all subsequent frames it's the same, except the "Simulation Input" ignores nodes connected to it from the left, and instead reads data from cache - the one saved by "Simulation Output" on the previous frame. $\endgroup$ Aug 17, 2023 at 22:55
  • $\begingroup$ Thanks to folks on Discord I learned the W dimension is limited to -1000...+1000 range only in the interface (can put a value outside that range numerically or through a link). Rerandomizing to a small range was still reasonable, considering a reasonable assumption the W dimension will have similar precision errors to XYZ (bu it doesn't! W behaves differently!) $\endgroup$ Aug 17, 2023 at 23:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .