Live data from Hacker News

WebGL Fluid Simulation

paveldogreat.github.io

71–80 of 106 posts

Re: WebGL Fluid Simulation

#71
Such a nice demo! I'm amazed by how smooth it's running on my phone. Even if we already have seen similar shaders back in 2004, this is running on the web, available to everyone, with no installation.

During my 3rd year at uni I played with webgl1 to create a fake fluid simulation, my demo looks crap nowadays http://jspdown.github.io/mod1/

Re: WebGL Fluid Simulation

#72
Re: everyone impressed by how fluid it is with multitouch: The number of touch points doesn't affect the performance of a grid simulation. Using 10 fingers just sets high values at more places in the initial grid. The effort to solve each time step is the same after that. The computational effort scales with the resolution, not the boundary conditions/input.

Re: WebGL Fluid Simulation

#73

Re: everyone impressed by how fluid it is with multitouch: The number of touch points doesn't affect the performance of a grid simulation. Using 10 fingers just sets high values at more places in the initial grid. The effort to solve each time step is the same after that. The computational effort scales with the resolution, not the boundary conditions/input.

I'm impressed it handles multitouch without scrolling or zooming the page. Many similar demos I've tried suffer from such issues.

Re: WebGL Fluid Simulation

#74

Re: everyone impressed by how fluid it is with multitouch: The number of touch points doesn't affect the performance of a grid simulation. Using 10 fingers just sets high values at more places in the initial grid. The effort to solve each time step is the same after that. The computational effort scales with the resolution, not the boundary conditions/input.

I'm impressed it handles multitouch without scrolling or zooming the page. Many similar demos I've tried suffer from such issues.

That's true. The actual UI implementation of the multitouch is great.

Re: WebGL Fluid Simulation

#76

Impressive demo! WebGL is an awesome piece of tech that only now starts to be largely adopted. I mean, it gives you access to 100s of cores to compute, run, display stuff :). Too bad Apple doesn't move forward with WebGL2 and Google splits the community in 2 with webgpu.

But WebGPU is more like Vulkan (in concepts) and WebGL is pretty much a 1-to-1 port of OpenGL.

It's not splitting the community. They needed a new modern API like what people behind Vulkan did.

Re: WebGL Fluid Simulation

#78

Here is the "main loop" for the simulation: https://github.com/PavelDoGreat/WebGL-Fluid-Simulation/blob/... I don't know enough about fluid dynamics to be the judge, but it seems like the engine is using genuine (2D) physics and it's not just "toy physics." Could someone who knows fluid mechanics comment on this?

Sure. It's a correct implementation of the projection method [1] for solving the 2D incompressible Navier-Stokes equations, so it is in fact using genuine physics. In terms of physical accuracy, there are some caveats - it's using the Jacobi method (chosen for its simplicity) to iteratively solve the diffusion and pressure Poisson equations, so the accuracy will be determined by how many iterations you're willing to do. That approach won't scale to larger systems. There are also some limitations from the choice of collocated (as opposed to staggered) grids and the approximations used for the boundary conditions. Nevertheless, for a small 2D simulation, you can get physically accurate results as long as you use enough Jacobi iterations and have a sufficiently fine grid.

[1] https://en.wikipedia.org/wiki/Projection_method_(fluid_dynam...

Post reply on HN