1
$\begingroup$

i have a particle system hooked up to a color ramp so that the particles change color based their age. the only problem is once the reach a certain age they stay a certain color because the color ramp value becomes greater than 1. is there a math function to make the value progress back to 0 once it hits 1 and vice versa so the colors can continually cycle back and forth?

$\endgroup$
1
$\begingroup$

Sounds like you want a sine wave! Just multiply your incoming value by sin (with a multiplication node and sine node, respectively) and you'll get your oscillation of 0 to 1 and back again. There's some official documentation on just that use case here: https://docs.blender.org/manual/en/dev/compositing/types/converter/math.html#using-sine-function-to-pulsate

Then, add one 1, and divide the result by 2. This is a much smoother way of interpolating between 0 and 1 while avoiding negatives, as Rich Sedman suggested!

In other words, this set-up should go between your existing "Divide" and "ColorRamp" nodes: enter image description here

$\endgroup$
  • $\begingroup$ It would be good to provide an image of the nodes for your solution so people can see what you mean and how to replicate it. Also, instead of using Absolute to avoid negatives, how about add 1 (so it varies between 0 and 2 instead of -1 and 1)then divide the result by 2 - this way it will vary smoothly between 0 and 1. $\endgroup$ – Rich Sedman Oct 20 '17 at 9:37
  • 1
    $\begingroup$ Much better solution, edited to use that! $\endgroup$ – revereche Oct 20 '17 at 10:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.