[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Public WebGL] N-Body simulation on GPU

N-Body dynamics simulation for N = 1024,...8196
3D coordinates are stored in N×1 RGB float textures2D. One vertex shader uses texture2D too to show star  field interactively.
Very long (up to 8196) for cycle sums up all forces
   for(float t = d; t <  1.; t += d ){
     vec3 v = texture2D(samp1, vec2(vTexCoord + t, .0)).xyz - r1;
     float a = dot(v, v) + e2;
     f += v/(a*sqrt(a));
where d = 1/N.
For N = 8196 on Radeon 4870 I've got 45 integration time steps per second. For N = 16384 NVIDIA CUDA simulation (GPU Gems 3) performs 38 integration time steps per second on the GeForce 8800 GTX GPU. It is about 4 times faster than WebGL as since complexity is NxN.
I can see fast rotating core and running away halo formation from a slowly rotating random Gaussian disk. I can't make a spiral galaxy (I'm not an expert :)
 I'm collecting my "WebGL and simulations on GPU" notes at