super cool! i'm thinking webgpu might be usable for a speedup, not sure if webgl would be
A WebGL transform feedback shader would be 100% as performant as what you could write in WebGPU for this use case (independent particle updates).
Show HN: Simulating 20M Particles in JavaScript
31–40 of 73 posts
Re: Show HN: Simulating 20M Particles in JavaScript
#32Anyone else having trouble with that web vscode he's using?
Re: Show HN: Simulating 20M Particles in JavaScript
#33My custom engine is built on a very similar solution using SharedArrayBuffers but there are still many things in this article that I'm eager to try, so thanks!
Re: Show HN: Simulating 20M Particles in JavaScript
#34Anyone else having trouble with that web vscode he's using?
Yeah, no idea how to run the code. There are links to the final demo at the end, but everything else just links to this editor :/
In the future I will keep everything self hosted to avoid this issue. I appreciate the patience.
Re: Show HN: Simulating 20M Particles in JavaScript
#35Earlier quoted context omitted.
Actively in-progress, actually. [0] Since about 2016. [0] https://gws.phd/posts/fortran_wasm/
there's also numpy and scipy in the webassembly python distro (pyodide). but the "kinda not" part more refers to first class scientific/numerical computing support. it's possible, but the libraries are all disjoint or are webassembly ports, etc.
Which is why the flang port it's about is attempting to compile to the actual primitives.
Re: Show HN: Simulating 20M Particles in JavaScript
#36Random question (genuine, I do not know if it's possible): > I decided to have each particle be represented by 4 numbers an x, y, dx, and dy. These will each be 32-bit floating point numbers. Would it be possible to encode this data into a single JS number (53-bit number, given that MAX_SAFE_INTEGER is 2^53 - 1 = 9,007,199,254,740,991). Or -3.4e38 to 3.4e38, which is the range of the Float32Array used in the blog. Fo…
[0]: https://github.com/thi-ng/umbrella/tree/develop/packages/vec...
[1]: https://github.com/thi-ng/umbrella/tree/develop/packages/vec...
[2]: https://github.com/thi-ng/umbrella/tree/develop/packages/bit...
[3]: https://github.com/thi-ng/umbrella/tree/develop/packages/sim...
There's also Structura, which implements a few performant data structures:
[4]: https://github.com/zandaqo/structurae/blob/master/README.md#...
Re: Show HN: Simulating 20M Particles in JavaScript
#37Re: Show HN: Simulating 20M Particles in JavaScript
#38Oh, man, can't wait to send it to the UI team who write dead slow React apps. JS is blazing fast. Especially if written well.
Too bad we cant just rely on JS only and have to involve a bunch of DOM operations, which is usually the slow part of the UIs we create.