3
$\begingroup$

I have a mesh with a UV-mapped texture. With Geometry Nodes, I would like to add beads to this mesh using Instance on Points, and these beads should take on the color of the underlying face. I tried using a texture to set the color of the instances, but the texture does not hold the UV map of the input geometry mesh. How can I connect Input Geometry -> Transfer Attribute (Color) to the Set Material node (color) of the Instance on Points node? I want the instances to "sample" the color of the input geometry.

$\endgroup$

1 Answer 1

5
$\begingroup$

The current solution for Blender 3.2+ is the following:

enter image description here

enter image description here

You simply get the UVMap of your mesh with Named Attribute and put it as a vector into the node Image Texture. Here you use the same image as in your shader.

The resulting color attribute is then stored in the geometry with Store Named Attribute.

As always in such a case, the node Realize Instances must be applied here after the instantiation, because only in this way the instances also receive different color values.

In the shader you can easily query these color values with the node Color Attribute.

Important to note in connection with Cycles is the following point:

If you want to use Cycles, you have to create a Color Attribute with the name Color in the Object Data Properties.

I'm pretty sure this is a bug (as is so often the case with Geometry Nodes), but as soon as you use the node Distribute Points on Faces instead of the existing points of a mesh, it all stops working for some reason I can't figure out. With an existing Color Attribute, however, it does. In Eevee it also works without the Color Attribute.

PS: If you are using an older version of Blender, this post may help you:
GN: How to pass an instancer's localized texture color to its instances?

$\endgroup$
5
  • $\begingroup$ Gorgeous example, thank you. Indeed this topic evolved a lot with the various versions. $\endgroup$ Jul 11, 2022 at 18:18
  • $\begingroup$ I'm actually pondering on a similar issue right now. In the past, I have used the same technique as you, but now I want to color the instances without using the UV. I want to create a toon shader in eevee (so shader to rgb node that also makes shadows) for both the underlying surface and the instances, and color the instances from surface color, regardless of it's rotation (instance should be darkened only if in shadow of an another object). Do you know if this is possible? $\endgroup$
    – Dalibor-P
    Jul 11, 2022 at 21:35
  • $\begingroup$ This worked great, I just want to add that "Color Attribute" in the shader does not take or need the name of the "Stored Name Attribute" in the geonode. $\endgroup$ Jul 12, 2022 at 4:51
  • $\begingroup$ @GregOttoNiemeyer That is correct ...if you use Eevee. This is only needed if you use Cycles (see notes). $\endgroup$
    – quellenform
    Jul 12, 2022 at 7:52
  • $\begingroup$ Ok so I added the Color Attribute to the Object Data Properties of the source mesh, and then called that with a Color Attribute Node in the shader for the instances, and now it works in Cycles! $\endgroup$ Jul 23, 2022 at 21:37

You must log in to answer this question.

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