Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

This topic is about fluid simulation, but it also references shaders as a way to performantly implement fluid simulation.

I've played around with shaders in the past to build particle simulations with millions of points, and it's always really tickled my mind. You basically write functions that operate against a big 2d grid of colors. But because colors are represented by a 4x1 vector [r,g,b,a], you can repurpose this pattern to do general purpose computation (e.g. you can represent a point in a 3D coordinate space as a [r,g,b] color).

You can see this in the codepen in this post. It's literally creating "materials" and "render targets" that are actually just intermediate computation steps in the fluid simulation.

  class Fluid {
      constructor(context) {
          this.context = context;
          this.speed = 4;
          this.forceInitMaterial = this.createShaderMaterial(forceInitFrag);
          this.divergenceMaterial = this.createShaderMaterial(divergenceFrag);
          ...
          this.divergence = this.createRenderTarget();
          this.advection = this.createRenderTarget();
          ...


that's pretty much how CUDA was born 15 years ago. Crazy how a few guys playing with shaders to simulate clouds led to the AI craze we have today.

Look up Mark Harris PhD thesis "Real-Time Cloud Simulation and Rendering" for more details.


I'm sure the origins of CUDA are very interesting in their own right, and it cannot be denied that the evolution of the GPU and GPU programming has had a huge impact on the growth of the field.. but, without the specific work of these specific people, at worst I think we'd only be a tiny bit behind where we are now.

The AI craze we have today is built on the continuous, sustained work of a huge amount of people over years and years.


yes, of course. I think this holds for pretty much all major inventions, which are attributed to single persons.

At some point in time, certain ideas are just inevitable. I'm certain back then many people were looking at GPUs and tricked them into performing non-graphics tasks.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: