0
\$\begingroup\$

Is there any ways to fade mesh particles like color over lifetime method with addictive shader. I have little to no understandings of shader coding, and fade rendering issue kicks in even with vertex color shader. Any idea guys?

\$\endgroup\$
1
  • \$\begingroup\$ It seems this question has answer : A , B \$\endgroup\$ Feb 28, 2018 at 18:48

1 Answer 1

1
\$\begingroup\$

In a very general way of an answer, fading particles is done by reducing the colour or, more commonly, the alpha value (opacity) of the particle, as a function of time. The colour values of a particle are usually (R,G,B,A).

We can say that at the beginning of a particles lifetime, it's opacity should be 1.0, and when it's lifetime reaches zero, it's opacity should also be zero.

So let's say that the particles lifetime is 5 seconds, and that an average update is 16 milliseconds, or 0.016 seconds.

From this, we know that the rate of change in opacity will be -0.2 opacity per second (-1.0/5.0).

Now that we know how fast to reduce the particles opacity per second, we can interpolate per update:

Op + dOp * dT = Op'

first step follows:

1.0 + (-0.2 * 0.016) = Op'

= 1.0 + (-0.032) = 0.9968

If the particle effect is continuous, then when lifetime reaches 0, you can reset it's position to the emitter and set it's opacity back to 1.0.

Alternatively:

Op = current lifetime/max lifetime

This is simpler percentage based computation of opacity.

How you actually update the current values is more implementation specific, so I suggest you do some reading into Unity shader coding, to get comfortable with the basics, then experiment with the above information.

\$\endgroup\$

You must log in to answer this question.

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