1
$\begingroup$

I have a simple geometry node setup, where I instance objects on a mesh line. My issue is that the shader is exactly the same in all instances. My question is would it be possible to randomize it somehow?

Geometry nodes setup

Shader setup

$\endgroup$
4
  • $\begingroup$ Hello, are you using Cycles or Eevee ? $\endgroup$
    – Gorgious
    Feb 25, 2023 at 10:42
  • $\begingroup$ I'm using Cycles. $\endgroup$
    – Licheff
    Feb 25, 2023 at 11:00
  • 1
    $\begingroup$ Did you try to use the Random per island node in the shader to offet the textures? $\endgroup$
    – Carlo
    Feb 25, 2023 at 12:01
  • $\begingroup$ Also if your usecase is only to do that , you should try the default array modifier, it has a builtin UV offset setting $\endgroup$
    – Gorgious
    Feb 25, 2023 at 18:48

1 Answer 1

2
$\begingroup$

It seems likely in your case that it would be more economical, and simpler, not to realize the instances in the GN tree?..

If so, at its simplest,you can store the index as a named attribute on instances:

enter image description here

..and let the shader do what it will, with the per-instance number, calling it up as an 'Instancer' attribute:

enter image description here

Here, the instance-index is used to look up the colour from [a multiple of (index,index, index)] vector in a Voronoi texture. The Index could equally be used to offset U and V in an Image, or in any other texture lookup.

enter image description here

If you want the input geometry's UV to survive on its GN-Generated instances, you can capture it:

enter image description here

... and then call it up explicitly as a 'Geometry' attribute, in a shader:

enter image description here

Here, the instance index is used, crudely, to offset the original geometry's UV by a little in X, per instance. The offset could be organized, for example, to pick up a different value for every note in a stack, from an appropriately tiled Image texture, or a mapping of the index could be used as a factor to mix between textures.

$\endgroup$
5
  • 1
    $\begingroup$ your solution seemed to work, but I also had to mix the UV map with the attribute node. I would assume it's because my object is unwrapped and I'm also using image texture. I'm added the realize instances nodes, because I'm also using Noise to distort the instances. $\endgroup$
    – Licheff
    Feb 26, 2023 at 8:48
  • $\begingroup$ @Licheff If you capture any attribute-per-instance before realizing, I think you should be fine.. (Index is plain) you can use it to offset UV's in the shader. $\endgroup$
    – Robin Betts
    Feb 26, 2023 at 9:07
  • $\begingroup$ as soon as I add the realize instances node the textures start repeating on each instance. I couldn't figure it out. $\endgroup$
    – Licheff
    Feb 26, 2023 at 11:27
  • $\begingroup$ I figured it out - I had to set the attribute node in the shader to Geometry, instead of Instancer. $\endgroup$
    – Licheff
    Feb 26, 2023 at 11:46
  • $\begingroup$ @Licheff Great! .. also see edit, which is about preserving the original plane's UVs on each of its instances. $\endgroup$
    – Robin Betts
    Feb 26, 2023 at 12:37

You must log in to answer this question.

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