14
$\begingroup$

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?

setup

$\endgroup$

3 Answers 3

13
$\begingroup$

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.

enter image description here

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).

enter image description here

$\endgroup$
4
  • 1
    $\begingroup$ That's a nice trick +1 $\endgroup$ Dec 13, 2021 at 13:48
  • $\begingroup$ The T.A. node on the right doesn't have anything connected to Index socket, 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 🤔 $\endgroup$ Dec 14, 2021 at 21:40
  • 1
    $\begingroup$ @MarkusvonBroady That one made my neurons hurt, too. I have to confess, I found it only as the result of exhaustively stripping out as many nodes as possible. It's the first TA I find confusing, not the second. The second one is OK. It transfers from the target (the realized instances at scale 0) to the first geometry encountered on its little forward branch ( full-sized geo in the Set Position ,) using 'Index' as the key to match by ..(as opposed to 'Nearest', etc). It is not transferring 'Index'. It is transferring the 'Fac' from the texture it picked up earlier, by 'Index'. $\endgroup$
    – Robin Betts
    Dec 14, 2021 at 22:41
  • $\begingroup$ @MarkusvonBroady Ahh I see what you mean.. The 'Index' input to the TA defaults to the index you see in the left-column you see in the spreadsheet. You could replace it with a roll-your own 'ID' or any other integer. $\endgroup$
    – Robin Betts
    Dec 14, 2021 at 22:46
8
+50
$\begingroup$

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.

enter image description here

enter image description here

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.

$\endgroup$
6
  • $\begingroup$ I see... On realizing instances, the attributes on the instances get copied to all elements of resulting geometry. $\endgroup$ May 10, 2022 at 12:57
  • $\begingroup$ @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. $\endgroup$
    – quellenform
    May 10, 2022 at 13:01
  • $\begingroup$ 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.) $\endgroup$
    – Mentalist
    May 18, 2022 at 8:42
  • $\begingroup$ @Mentalist I am sure that an interesting answer can be found if you post this here as a separate question. $\endgroup$
    – quellenform
    May 18, 2022 at 9:21
  • $\begingroup$ @Mentalist Did you mean something like that? e.pc.cd/s1gotalK $\endgroup$
    – quellenform
    May 18, 2022 at 11:12
4
$\begingroup$

Something like this using Transfer Attribute node?

enter image description here

enter image description here

$\endgroup$

You must log in to answer this question.

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