3 ms·
I've looked over the code and I can't figure out what makes the particles brighter. Some of it is when the particles overlap, they appear brighter, but if you d
by merpnderp 12y ago
I've looked over the code and I can't figure out what makes the particles brighter. Some of it is when the particles overlap, they appear brighter, but if you don't touch the screen, all the particles fade out to black. Anyone know how that is done?
- teraflop 12y agoThe particles are drawn as line segments, with lengths proportional to their velocity. As the velocity approaches zero, each line segment covers a smaller and smaller fraction of a pixel. Because the lines are drawn with antialiasing (at least in Chrome) this causes them to fade into transparency as the pixel coverage approaches zero.
- deleted 12y ago[deleted]
- flohofwoe 12y agoThe particles are rendered with additive blending: gl.enable(gl.BLEND); ... gl.blendFunc(gl.SRC_ALPHA, gl.ONE); It basically means that the particle color is added on top of the already rendered particles (with the alpha value used to modulate the particle color, which is a bit strange, it would be more usual to use gl.ONE for both parameters). The more particles overlap, the brighter that pixels becomes. Details are explained here: https://www.opengl.org/wiki/Blending#Blend_Equations https://www.opengl.org/wiki/Blending#Blend_Equations
- flohofwoe 12y agoPlus what teraflop writes about particle velocity being proportional to their line length. The 'overbrightening effect' should be caused by the blending however.