5 ms·
I'm using GPU.js for a nbody gravity simulation in three.js. So far I'm liking GPU.js but it has it's limitations. only being able to return a single float from
by gnarbarian 9y ago
I'm using GPU.js for a nbody gravity simulation in three.js. So far I'm liking GPU.js but it has it's limitations. only being able to return a single float from any function causes a lot of redundancy. For example, in order to get the 3d acceleration vector for one body I have to call the function once for each dimension, recomputing all of the temporary variables each pass. Then I have to make another pass for collision detection so it ends up being about 4n^2 vs just n^2
nonetheless it's still about an order of magnitude faster than the pure CPU implementation I have.
In the future they plan to add webGL 2.0 and OpenCL support which should improve the flexibility of the library.
http://thedagda.co:9000/?stars=true&bodyCount=1000 http://thedagda.co:9000/?stars=true&bodyCount=1000
you can toggle CPU nbody computation with:
?CPU=true in the url. remove it for GPU computation.
you can toggle the number of planets with the bodyCount variable. default is 1000
if you have a beefy computer try bodyCount=4000
gamepad=true works if you have a xbox controller hooked up.
on gitHub:
https://github.com/ubernaut/spaceSim https://github.com/ubernaut/spaceSim
- Zelizz 9y agoWhy not calculate the unchanging intermediate results in separate functions so that you can pass them as arguments to the final function?
- gnarbarian 9y agoEasier said than done. I can't get superkernels to work at all. I've tried.