Assign colors to particle SOP?

How do you assign a color to a particle SOP so every particle can have a different color - which is kept until the life of the particle has ended.

I tried using a toptochop and used a TOP for the coloring, but the particles change colors depending on their UV coordinates. I’m trying to assign it a color when it’s first created and then have it retain that specific color until it dies. Any thoughts?

Hi @Flowtricks,

the Particle SOP has a parameter called Add Particle ID which when toggled on will create a point attribute called “id”. This attribute can be fetched via a SOPTo CHOP and used via a Lookup TOP to pick a color and write it back to the particle with a CHOPTo SOP.
The Lookup CHOP would require you to set an index range that is greater the default 0 to 1 and for example reflects the number of particles active in the simulation.

Attached is a little component illustrating this approach. Main point is that you have the particle ID attribute to work with as a static identifier for each particle.

Hope this helps
Cheers
Markus

colorsPerParticle.tox (894 Bytes)

This looks fantastic, thank you so much for your help in this! I don’t understand the lookup chop enough it seems. Is it pulling the color info from one set and applying it to another? I’ll look it up so I can understand it better.

I’ve been tracing SOPs from TOPS and then running particles on the edges - then bringing the color back but the colors would change because as they moved, it’d be in a different location. It seems the lookup CHOP really keeps those colors in place. Thank you!

Shoot, I was wrong about that. Pattern works awesome though. But do you have any suggestions for how I could pull color from a TOP to color a particle (from a particle sop) and retain that color until the particle dies? That way, it looks like the object is emitting particles that match the color from where it was emitted from - but if the TOP is a movie and it changes, it won’t affect the particles that are already out there.

I’m guessing there might be a way to set RGB values once as soon as the particle ID is set. Any thoughts?

Hi @Flowtricks,

i think the attached is a better solution for your case:
Here we are using the original geometry and generate uv lookup values from it to fetch a color per point from a TOP. Your source geometry might be a rectangle that is not square but uv values to lookup from a texture are generally in the range of 0 to 1 - hence the little Transform SOP node chain that takes the source geometry and translates and scales it into place.
These channels are then reapplied to the source geometry of the particle sop. With this, the particle SOP will pick the color for each particle from the source geometry when it is born.

Hope this helps
Cheers
Markus

colorsPerParticle.tox (1.1 KB)

Snaut, this is AMAZING. I was up until 3am trying to make tables and CHOPs to try to do this - but it was way too complex and CPU hungry. Can you help me solve one more thing? I have a rotating bannana that I want particles to shoot from - but I don’t necessarily want it to shoot from a grid. I used your example and it’s almost there - but I’m not sure how to calibrate it right? Mainly the chopto1 doesn’t line up with the image and leaves black spots. Again, thank you very much for your help!

colorsPerParticle-2 Almost.toe (5.8 KB)

Hey @Flowtricks,

if you are using a Trace SOP, it actually creates the uv point attribute for you - so you can use this to lookup the color. A consideration might be that you want to create the particles not just from the edges but from the whole shape - in which case you would have to create some inline points which can be done with a Divide SOP and the Bricker Polygons parameter. Now this is getting a bit heavy but it might be what you are after?

cheers
Markus
colorsPerParticle.tox (2.9 KB)

Yessss! Snaut, you are amazing. This hit the nail on the head. Thank you so much. The divide SOP - I’ve never used that one before either. It’s great! That allows for even more particle option madness. Thank you!