Why do i get these dark grey trails ?
I’m drawing a new background with alpha set to 7 at each frame, so i guess at some point it should get full black. But it isn’t…
How do I fix this ? I tried using the trails method described here : https://www.youtube.com/watch?v=vqE8DMfOajk …but this takes much much more cpu for 10K particules. So I want to use this method of low alpha background drawing in draw(). The only issue is the persistant dark grey trails…
Yes, it’s a rounding error in the math that blend uses because colors are stored as 8-bit numbers.
One possible “solution” is to initialize the background to the same dark gray color as the trails. It won’t be black, but at least the trails won’t be visible. During animation, keep drawing the background as black with alpha. The initial gray color shouldn’t be further changed. I guess it shouldn’t matter what color you initialize the background to as long as it’s brighter than the dark gray since the animation will quickly fade it to that color.
Another solution would be to write your own darkening shader and render a fullscreen rectangle that checks the pixel value and does its own thing with it. When the value is dark enough, just go to black. I haven’t played with p5.js shaders, so I don’t know exactly how to implement it.
Mathematically it should always work out to the same gray value.
Yes, initialize in setup(). Look at what happens if you set the background to white in setup() and then set it to fade to black with alpha value in draw(). Play with setting the alpha to a bunch of different small values. If the alpha is too small (which would give you very long trails), then it only fades to a fairly light gray. Larger alphas (giving shorter trails) will fade closer to black. Pick your balance between length of trails and how black you want the background to be.
For 10k particles, you’re not going to have room for very long trails, so you can probably use a high enough alpha value that will let you fade pretty close to black.