skeeto / webgl-particles

WebGL particle system demo
http://skeeto.github.io/webgl-particles/
The Unlicense
221 stars 46 forks source link

Question :) #2

Open devvvshin opened 8 years ago

devvvshin commented 8 years ago

@skeeto Hi :) I'm glad to see your codes. And I have a couple of question. In https://github.com/skeeto/webgl-particles/blob/master/js/particles.js#L15, What does mean in dividing by 3 ? and In https://github.com/skeeto/webgl-particles/blob/master/js/particles.js#L16, Why did you multiply 100 to channel1's(?) scale? Thank you :)

skeeto commented 8 years ago

I should have made some comments, or at least named these magic numbers! I think the 3 is an arbitrary number I added to tweak it while I was playing with it. This was done in c703b29 where it was changed from 2 to

  1. Try changing this number so you can observe its effect.

The 100 is to make better use of the dynamic range of the texture color/alpha channels. Velocities are much smaller values than the position, so they're multiplied by 100 (chosen arbitrarily as I tweaked) to minimize precision loss. This was done in 51f4fa03. There's probably a better value for this, but this should at least be the right order of magnitude.