I'm trying to use an attribute generated from an instance position to affect the geometry of the instances. For example with the below setup, let's say I want to shift just the 4 top vertices of each cube, along the x-axis, by the amount given by the noise texture. Is it possible to use the noise texture value after realizing the geometry, or modifying the geometry in some other way?
3 Answers
This problem has come up in a variety of guises: 'How do we get a per-instance attribute into realized geometry?' If you want a per-instance color, deformation, or anything else, the route isn't obvious.
The hitch in Geometry Nodes at the moment is that there is nowhere on an unrealized instance to store an attribute. This looks as if it's going to change; there may be an 'Instance' domain coming to the Capture Attribute node in Blender 3.1. At the time of writing, it doesn't yet work.
Edit: At 29 Dec 2021, in Blender 3.1 alpha, the 'Instance' domain is available and working. It makes the following hack unnecessary. See @qullenform's answer, instead.
If the instances are small enough, and don't overlap, you can often get away with direct transfer of an attribute to geometry by its vertex-proximity to the points on which the instances were generated, as shown in @Harisreedhar 's answer
If not, though, for now, you can employ some variation of this hack:
- Make a parallel branch of your tree, in which instances are scaled to 0 before being realized.
- Transfer the attribute to the scale-0 realized instances by proximity ('Nearest').
- Transfer the attribute back to the full-sized geometry by Index.
This makes the difference between the case on the left, below, (where the attribute is interpolated across vertices,) and the case on the right, (where the attribute is picked up per-instance).
- 76,260
- 8
- 77
- 190
In Blender 3.1+ there is the possibility to capture an attribute in the Instance domain, which makes various hacks superfluous.
Additionally, it is recommended to use a specific vertex group previously created as Group Input as Selection.
This selection is simply used as an input in the node Set Position.
Of course, the vertex group can also be used directly during instantiation in the Instance on Points node, depending on what result you want.
Why a vertex group instead of a mathematical solution?
If you want to instantiate different objects from a collection, you only need to create a vertex group in these objects with the identifier you chose before and define which points should be modified. This makes the selection easier to handle and less prone to errors.
To make a vertex group available in geometry nodes, simply create an Input of type Boolean, and specify the identifier of the vertex group.
- 35,177
- 10
- 50
- 133
-
I see... On realizing instances, the attributes on the instances get copied to all elements of resulting geometry. – Markus von Broady May 10 '22 at 12:57
-
@MarkusvonBroady Yes, and as long as the instance is not realized, it is treated as a point that is assigned exactly one value from the texture node. – quellenform May 10 '22 at 13:01
-
Can this technique be used to capture the texture color of an emitter mesh so that each instance receives the color from the area it was emitted from? (Something like this, except using GN instead of a particle system.) – Mentalist May 18 '22 at 08:42
-
@Mentalist I am sure that an interesting answer can be found if you post this here as a separate question. – quellenform May 18 '22 at 09:21
-
@Mentalist Did you mean something like that? http://e.pc.cd/s1gotalK – quellenform May 18 '22 at 11:12
-
@quellenform Sorry for the late reply. Yes! That's exactly what I meant. I have posted a new question. Please consider posting an answer. I even used your screenshot as a reference image. ;-) – Mentalist May 23 '22 at 08:19








Indexsocket, but it still is fed an index just like texture nodes in shaders are fed coordinates even if a vector is unconnected? I only just started learning geonodes so some rearranging my neurons hurt, like why two T.A. nodes are needed? Why the noise texture? I thought I connect an attribute I want to get from a given geometry, apparently that's not how it works – Markus von Broady Dec 14 '21 at 21:40