Is there a way to get a random value for each object in geometry nodes?

I want to get a different a seed for a point distribution that is unique for each object.

As a minimal working example, i want to each square to have a different point distribution:

But I don’t know what can I put on the Seed input

When i need something similar for a shader I use the Random attribute from the Object info node.

Random value gives a “input expects single” value error, which is reasonable.

I ended up using a script that sets a random input value per object, which I don’t like for many reasons.

import bpy;
import random;

for obj in bpy.data.collections['Collection'].all_objects:
    if obj.name.startswith("Plane"):
        obj.modifiers["GeometryNodes"].properties.inputs.Socket_2.value = int(random.random()*1000)

#update the modifiers
bpy.context.evaluated_depsgraph_get().update()
   

Here is the file in anyone needs it

randomseed.blend (111.9 KB)

These are the closest solutions I have found inside the node editor:

https://blender.stackexchange.com/questions/299150/geometry-nodes-random-per-object-per-modifier-randomize-a-noise-pattern

https://blenderartists.org/t/random-values-geometry-nodes/1583621

I would still prefer to get something more straightforward that uses less nodes. I can’t find a way to access an object custom property, which would be a better solution for me.

Setting the same value for a mesh attribute with the same value doesn’t work either, as the seed only works with a single value.

Is there something I’m missing? I’m actually considering on implementing this into blender, but I wanted to get sure this is not doable before talking to the dev community.

Expose the seed parameter to the modifier level

Self Object into an Object Info node gives you the object’s Location, and that’s a single value, so the Seed accepts it. On 5.2 I put a Hash Value node set to Vector between Location and Seed, and four planes sharing one node group all got different points. 4.2 doesn’t have Hash Value, so there Location goes straight into the Seed, but two of my four planes 2.2 m apart got the same pattern that way. Leave Object Info on Original, because Relative gave every plane the same points. Moving an object reshuffles its points, even a 1 mm nudge, and I couldn’t find a node that reads custom properties in 5.2.

The only way to access that is to use drivers…
And even so, it won’t be very usefull in this situation, because the driver will be directly linked to the object property, and every GN instance (on every other object) will get the same value, unless each GN modifier is made unique, with an unique driver.

It would be nice to have access to other properties in GN, like the Attribute node in shaders; but for now, it’s all we got.

Yeah, it would be nice to just have random per object in geometry nodes. I just make seed an input and set per object manually as Hadriscus suggested. Location sometimes doesn’t have to differ or objects may need to remain consistent when moving - I don’t think that’s very practical…

@Aisol_Studio Oh that’s a nice workaround for my project, thanks, although it has the limits noted by MartinZ. I’ll wait before marking it as solved in case someone has a different solution.

@Hadriscus Are you talking about connecting the seed to the input group or is it something else?

Maybe as mentioned here (not using the random distribution but set the position randomly ) ?? :

Just curious, did you read that BA topic you linked in the original post? Because both of those workarounds were already covered in that topic.

Use lists and a collection.

This was discussed at some point to be included in GN, but eventually this was moved to something else. IRRC devs wasn’t convinced by the way it’s actually done in blender, basically by using object’s name as a random seed.

But !! Maybe if something have to be added that could be exactly that : in the object info node adding the object name as output and feed that into an hash value.
Or a dedicated object name node… IDK how difficult is that but then we would get the name as extra bonus. And eventually if they like they can build a stronger system that doesn’t rely on object’s name.

Just food for thoughts !

Anyway, if I had to do that I would do just like you did with the script, or something like what Night suggested if that’s ok to use a collection as input.

I don’t understand why not make all object properties accessible to be honest, not only name. Custom properties for example not being possible to access from geometry nodes feels weird. Object Info node does not even deserve the name at the moment in my opinion. It’s object geometry and transforms.

I would add “and scene/view_layer properties”.
There so many situations that you want a global property to alter different aspects of multiple objects…

Yeah that makes sense, I think it’s easy to access via python but if you want to avoid that to get better performances stuff needs to be added on a case by case basis.
But hey, software like good cheese needs years to mature !

  1. Find PR that Blender developers chose to not approve because #whatever.
  2. Fork Blender.
  3. Add code.
  4. Enjoy feature. :wink: