How to change the NME gradient in a separate thin instance

Hello everyone! I’ve found many examples of color changes for a single thin instance, but I can’t find a way to change one of the gradient colors. Is there a way to set the gradient or its components as an attribute or something like that?
Here’s the NME I work with.

Thanks!

Let me check what I can do for you :slight_smile:

So to be sure I understand: you want to use different color gradient PER instance? is that right?

Yes, and I think that could be achieved by interacting with the instanceId in NME, but I’m interested in dynamic changes, for example, to be able to change the color gradient of an instance by its index, using a ColorPicker.

well I guess you already spotted it. You can have several gradient colors and pick the one you want per instanceID

but you cannot change the colors of a gradientColor at runtime as they are static (they are textures generated at build time)

Currently, I’m changing the gradient of the ‘parent’ material of the thin instances, and then I’m using the build() method on the material, and this worked for all instances of that mesh. Is there no way to do something similar for a single thin instance, or is there perhaps some workaround? :grin:

to have a per instance approach you cannot use gradient as (as you said) they need to be build() first so nothing realtime

you could think of having 2 colors attributes per instance and then linearly interpolate with nme?

Great! Thanks for the idea. At this stage, I’ve managed to create a shader indistinguishable from the original using interpolation and three colors. I think I’ll now be able to achieve the desired result. As soon as I accomplish that, I’ll update the thread.

1 Like