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?
-
$\begingroup$ Hello, are you using Cycles or Eevee ? $\endgroup$– GorgiousFeb 25 at 10:42
-
$\begingroup$ I'm using Cycles. $\endgroup$– LicheffFeb 25 at 11:00
-
1$\begingroup$ Did you try to use the Random per island node in the shader to offet the textures? $\endgroup$– CarloFeb 25 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$– GorgiousFeb 25 at 18:48
1 Answer
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:
..and let the shader do what it will, with the per-instance number, calling it up as an 'Instancer' attribute:
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.
If you want the input geometry's UV to survive on its GN-Generated instances, you can capture it:
... and then call it up explicitly as a 'Geometry' attribute, in a shader:
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.
-
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$– LicheffFeb 26 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 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$– LicheffFeb 26 at 11:27
-
$\begingroup$ I figured it out - I had to set the attribute node in the shader to Geometry, instead of Instancer. $\endgroup$– LicheffFeb 26 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 at 12:37