1
$\begingroup$

I have a point line and am instancing this Parasol object along the points. I only want to alter the specific colored portion of the object so that each instance is a different color in relationship to its index number, so that each instanced object would be the next color of the rainbow in accordance with the color ramp. I'm having trouble knowing if I should realize instances, because all of the model's textures change when I am only wanting to affect a certain texture in the model.

I thought I could do this by storing the object index as a Stored Attribute, but every instance is the same color no matter what I do. my geo nodes setup my shading setup the instanced objects

$\endgroup$
5
  • $\begingroup$ In Shading, change "Attribute" node's "Type" to "Instancer". $\endgroup$ Sep 29, 2023 at 22:57
  • $\begingroup$ Thanks for answering, but this didn't seem to change the outcome any. All of the instances are changing color as one unit. However, if I use object info node and connect "Random" into the color ramp, each instance changes individually, so i feel there must be some way to influence them all individually to change. $\endgroup$
    – Connor m
    Sep 30, 2023 at 0:38
  • $\begingroup$ Color Ramp clamps inputs to 0..1 range. This means you still should get one blue instance for index 0 and other instances should be red. Since you don't report that, there mush be some other problem, upload your file to blend-exchange.com $\endgroup$ Sep 30, 2023 at 8:35
  • $\begingroup$ @MarkusvonBroady for such effect there should be Realize Instances after Store Name Attribute ... right? $\endgroup$
    – vklidu
    Sep 30, 2023 at 14:29
  • 1
    $\begingroup$ @vklidu not since B3.4: Is where a way to pass data to material without realizing instances? $\endgroup$ Sep 30, 2023 at 19:28

1 Answer 1

3
$\begingroup$

ColorRamp node operates in a range 0-1 ... using your setup should result at least with one instance blue (because of index number zero) and the rest of instances red (because their index number is 1, 2, 3, ...)

Note: Since all your instances are blue (=0) you probably need to add Realize Instances node after Store Named Attribute node (that is not needed for Blender 3.41 as mentioned in Markus comment).


To apply ColorRamp gradient across all instances you have to shrink all the index values down into 0-1 range. Like in this example - the first instance with index 0 should give the value 0 and the last instance with index number 35 should give the value 1.
Note: The grid contains 36 instances, but since the numbering starts with 0 and not 1, the highest index number is 35.

There are several ways to do that ... you can just simply add a Map Range node into your shader node tree with From Min set in this example to 35:

... but it is more efficient to scale the range with Geometry Nodes. There can be range scaled into 0-1 automatically for a given number of instance points. The math here: Index node values Divided by the number of instances taken from Domain Size > Instances. And because index list operates in the range 0-35 and instances 1-36 you have to Subtract the list by 1:

Alternatively, in case your instance object contains a single mesh (island) or you connect all separate parts of the mesh by edge, you can use the Mesh Island node https://imgur.com/0UUG3uf

Thanks @MarkusvonBroady for corrections in the comments ... works for Eevee now too.

$\endgroup$
4
  • 1
    $\begingroup$ You could divide in geonodes to only use a single attribute in the shading, maybe this could fix the problem in Eevee (maybe it doesn't support integer or larger than $1$ attribute in your version? And as said under the question, you don't need to realize in B3.4+ $\endgroup$ Sep 30, 2023 at 19:31
  • 1
    $\begingroup$ @MarkusvonBroady it seems to be 100% correct :) My issue was Integer ... switch to Float works. Edited. Thanks a lot :) $\endgroup$
    – vklidu
    Oct 1, 2023 at 5:53
  • 1
    $\begingroup$ Be careful with mesh islands, if your instance is Suzanne for example… :) $\endgroup$ Oct 1, 2023 at 12:00
  • 1
    $\begingroup$ @MarkusvonBroady ... correct again :) +1 $\endgroup$
    – vklidu
    Oct 1, 2023 at 12:05

You must log in to answer this question.

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