0
$\begingroup$

I need to animate particles following a convoluted pipe. I need to change the color of the particles at a certain length of a curve.

Is it possible to change the colors of the particles at a certain point of a guide curve?

The effect I like to achieve by this is similar to the short video. Thanks! https://www.youtube.com/watch?v=nfz0z3rtpZg

$\endgroup$

1 Answer 1

2
$\begingroup$

If this is done with a Curve Guide force field to guide the particles along the path, there is as far as I know no way to get a particle's position on the curve directly.

However, the way this can be achieved is by using the fact that the Lifetime of a particle determines its speed to move along the curve. This way the age of a particle is telling you how far it has already come - and I guess this is how it's done in the reference video.

In the Shader Editor you can use a Particle Info node which provides the Age and Lifetime of a particle. If you take a Math node and divide Age by Lifetime you get the percentage of the distance it traveled along the curve.

You can then plug the result into a Color Ramp to color the particles according to their age and by this also the traveled distance. It doesn't matter if you have a fixed Lifetime for all particles or set a Random value to vary the lifetime (and speed thereby).

Notice that this Particle Info node only works in Cycles, not in Eevee. The material has to be put on the object which you instance for rendering, in my example it's an icosphere:

particle colored by age

Quick sidenote: this is a solution for particles. If you are doing this with Geometry Nodes and instance objects along a curve by Spline Parameter > Factor node, you get the position in percentage of travel distance directly. If you take this as an attribute to reference in a material shader, this will work in Eevee, too. I made the particle version because you asked for particles, but I guess someone can provide a good answer using Geometry Nodes as well.

$\endgroup$
3
  • $\begingroup$ Wow, thank you! This works really well. Thank you very much!! $\endgroup$
    – Quan Lee
    Feb 22, 2023 at 1:31
  • $\begingroup$ @QuanLee If this was what you're looking for you might consider accepting the answer. You can use this quotient for other effects as well, like sparks that glow at first and get dim, glass that turns from transparent to opaque etc. $\endgroup$ Feb 22, 2023 at 5:13
  • $\begingroup$ I am sorry, now I accepted the answer. Thanks again for the answer, helped me a lot, thanks! $\endgroup$
    – Quan Lee
    Feb 23, 2023 at 15:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .