

WebGL GPU Particles - ingve
http://soulwire.co.uk/experiments/webgl-gpu-particles/

======
willvarfar
I've been playing with webGL particles and I'm surprised that texture upload
is chosen over normal attribute arrays. I'll have to try it out and see if its
faster.

I've found it best to not update anything if you can help it, so use
procedurally generated particle effects.

For example, to follow the mouse, I'd be passing in a smoothed curve the mouse
has recently travelled down as uniforms. This doesn't work the same way, and
won't give as exact results, but does look nice.

One of my blog posts, related:
[http://williamedwardscoder.tumblr.com/post/43800948133/effic...](http://williamedwardscoder.tumblr.com/post/43800948133/efficient-
procedural-flame-particle-effects)

More recently I've been doing effects using Perlin Noise at an extra dimension
- time - and that works great for stuff like plasma effects that don't have to
react with the environment.
[http://williamedwardscoder.tumblr.com/post/57181055984/perli...](http://williamedwardscoder.tumblr.com/post/57181055984/perlin-
noise)

~~~
kevingadd
Texture upload is a great choice because it means your particle update routine
can be a pixel shader that you run the current 'state' texture through to
produce a new 'state' texture. Then you're literally running the whole thing
on-GPU. Not aware of ways to do that at present with DX9-class hardware or
with the WebGL feature set. Modern desktop GL and DirectX let you write to and
read from basically anything, as I understand it.

~~~
exDM69
> Texture upload is a great choice because it means your particle update
> routine can be a pixel shader that you run the current 'state' texture
> through to produce a new 'state' texture.

Yep. This is how GPGPU programs were done some 10 years ago when there was no
API to deal with GPU buffers in a more flexible way.

These days we've got Transform Feedback (aka. Stream Out in D3D) and Compute
Shaders that are more flexible. And Cuda and OpenCL, of course.

One thing you should be aware of when doing this kind of texture-to-texture
GPGPU is that the internal GPU pipeline in GLES2 (and thus, WebGL) may be less
than full 32 bit floating point. Also the texture formats being used are not
full floats. So watch out for numerical precision issues!

------
KillaW0l04
I actually cant manage to get this page to work for me. Could it possibly be
something to do with the fact im running Linux? Does chrome for linux support
WebGL yet?

~~~
exDM69
>Could it possibly be something to do with the fact im running Linux?

No.

>Does chrome for linux support WebGL yet?

Yes.

I can run this on Linux with Firefox and Chromium.

Check that you have OpenGL properly set up (e.g. correct gpu drivers).

In addition use the WebGL extension check to see that your OpenGL version (ie.
GPU and drivers) can access textures from the vertex shader. It's a feature
that was added a few years ago, there may still be hardware/software versions
that doesn't allow this.

