Random color for particle based on a gradient !

Hello !
I got a prt sequence where i’d like to give particles a random colors based out of 2 color that i picked. So far i am, i can’t find why it doesn’t work … Here is my magmaflow script :


And all my particles appear purple in the viewport :confused:
Thanks :slight_smile:

Hi!

Since the ID is an Integer and the Noise tends to produce the same value on integer values, I recommend you introduce the Multiply node BEFORE the Noise (after the ToFloat). This will scale down the noise pattern not to hit the integer values and you should get different colors.

Also keep in mind Noise produces values between -1.0 and 1.0 when Normalized, so you might have to add 1.0 and divide by 2.0 to keep it between 0.0 and 1.0.

Thanks a lot !
Is there a way to know wich value output a node ? I mean, is there an other way than asking you to know that the noise node create a value between -1 and 1 ?
Thanks :slight_smile:

Check out the Debug menu in the Magma Editor. :slight_smile:
It will show you the actual values of all node outputs per particle, and the Min and Max values of every output, so you should see values CLOSE to -1 and 1 for the Noise, but not exactly that, depending on the sampling, Noise settings and other things.

Also, the Krakatoa Particle Data Viewer shows you the final values in all particle channels, but you wouldn’t be able to see the Noise value (unless you output it to a custom Float channel), you would only see the resulting color values.

Last but not least, the documentation says:
thinkboxsoftware.com/krak-magma-2-nodes/

I am now testing Krakatoa and I wanted to add some variation to some krakatoa particles and just saw the thread. Here is what works for me. It’s really cool.

I tried it on a HUNDRED millions particles!

The problem with randoms sometimes is that they don’t have spatial meaning - you’ll get a noisy result seeding it with the ID (not sure how that gets built, maybe there is some visually meaningful sequence? :slight_smile: ) So a lot of the times I get a vector channel that’s constant per particle - like the initial position - and use that as a noise seed - gives noise patterns that you can visually see, usually looks better :slight_smile:

ID is not “built”, it should be a constant per-particle channel coming from a simulator that assigns it at birth (e.g. PFlow, TP, RealFlow, Naiad etc.).
The “Index” channel on the other hand is being built using the order of particles and might not be constant.

So if the ID channel is native to the particle, it should be great for generating a consistent noise.

Ah yes, I got ID and index confused :slight_smile: Sorry :slight_smile: