3

I generate some instances using geometry nodes, each instance has an id attribute.

Here is a spreadsheet snapshot showing generated instances :

Spreadsheet showing generated instances

My geometry nodes are seen below :

Geometry nodes generating instances

I'd like to use this id from the Cycles material applied to the instances.

So far, I've tried using the Attribute node, Object Info / Object Index, and Particle Info / Index - without success.

My current attempt of shader nodes looks like this :

My current attempt of shader nodes

Is there a way to access the id value from the material shaders nodes ?

I'm aware that using the "Realize Instances" nodes I could create a mesh with custom attributes - but I need to preserve the actual instancing for complex geometry.

rotoglup
  • 353
  • 2
  • 10
  • AFAIK this is not possible with complex geometries and without realize instances right now. – Chris Jan 03 '22 at 12:18

1 Answers1

3

you can use this node setup:

enter image description here

spreadsheet:

enter image description here

shader:

enter image description here

result:

enter image description here

Chris
  • 59,454
  • 6
  • 30
  • 84
  • 1
    I'll edit my question to be more specific, but I want to preserve my instances - as I need to have many of them, with complex geometries - so "Realize Instances" is too memory hungry for my needs. – rotoglup Jan 03 '22 at 12:15
  • AFAIK this is not possible at the moment without realize instances and with complex geometries. If you would have simple spheres....there are some mathematical workarounds... – Chris Jan 03 '22 at 12:19
  • I've created the same setup here, now I'm a bit confused... when I use the Set Material node on the original geometry of the cube, the 8 vertices show values 0.000 to 7.000 for myID - and the cube is colored according to the vertex indices. But when I try to do it with the realized instances, the column myID reads 0.000 for all vertices and so the cylinders (or in my case icospheres) get the color for 0. I switched from the Index node I used originally in my setup to ID like you, but nothing changes. The results are exactly the same, the cylinders stay at the color for 0. – Gordon Brinkmann Jan 03 '22 at 12:26
  • what version r u using? If you provide your blend file, i will check it out ;) – Chris Jan 03 '22 at 12:27
  • so it doesn't work with realize instances and it does work without realize instances!? wow....show me your blend file! ;) – Chris Jan 03 '22 at 12:30
  • did you change the output value to float? i had problems when it was on integer...although THIS was/is really weird... – Chris Jan 03 '22 at 12:31
  • 3.0.0, and I tried it with 3.1.0 Alpha. Yes, I tried default float at first, then integer and now I'm back to float. No, I didn't say it works without realize instances, no need for "wowing" here. I said it works with the original cube geometry. – Gordon Brinkmann Jan 03 '22 at 12:34
  • ok, then i don't understand what you did... – Chris Jan 03 '22 at 12:39
  • Me neither. By the way, on the original cube mesh it works with Float and Integer. – Gordon Brinkmann Jan 03 '22 at 12:42
  • as i said...if you provide your blend file, i will give it a try – Chris Jan 03 '22 at 12:44
  • @Chris habe im Chat ein Bild und einen Link gepostet – Gordon Brinkmann Jan 03 '22 at 13:28
  • 1
    @Chris I wish this bloody chat would sent notifications that someone posted something ;) – Gordon Brinkmann Jan 05 '22 at 07:02