How to apply both material and displacement individualy to instances?

I have some instances of mesh objects made with geometry nodes. I use a displace modifier after the geometry nodes modifier in order to displace them. This only works if I include the “Realize instances” node. I also apply a gradient material to each of the objects individually with the set material node. But this only works if I don’t include the “Realize instances” node!

Is there a good way to do both? Note I use Eevee, so I can’t do the displacement in the material shader.

Here is my setup with the material working as intended. The displacement doesn’t work:

Here it is with displacement working. But now the material doesn’t work - the gradient is put on top of all cyllinders at the same time, instead of a separate gradient for each cyllinder:

Apply the material to the cylinder before you instance it… optionally capture it’s position in a named attribute which you can then use in the Material editor for the gradient texture so it’ll not care about subsequent warping as each point will remember its original coordinates…

Good luck.

1 Like

The attribute solution worked! I would never have figured that out myself. Thank you so much.

Strangely, I couldn’t get the first solution you posted to work, but that doesn’t matter.

In case someone else has the same problem in the future, here is the setup that worked:

And in the shader editor: