Hey! Been a looong time since I posted anything here. I just wanted to share what I’ve been working on the past few days as I thought I could get some cool gifs out of it.
This here is the beginning of an experiment to simulate some kind of particle motion in realtime. If I just figure out how to do this properly I can eventually use it for e.g. smoke, fire, cloud formations, water or cool displacement effects in my future applications. But it’s really haardd x) Fluid dynamics is one of my goals, I’ve been reading up on it, but as it’s based on complex physics equations, a lot of it is still incomprehensible to me. And my programming environment is lacking many features.
Anyway, this is what I’ve got so far. It’s done on my pc’s gpu in a glsl es shader so I’m constrained to parallell programming. But that’s a good thing; it allows me to render and update more than a million particles 60 times a second. A texel works like a particle storing information in its rgba channels. I store the visibility of the fluid in the red channel, and the velocity (vx,vy) in the green and blue channels. (Not using the alpha channel atm.) I draw the texture onto itself to update the particles. Since it’s parallell programming, I can’t actually move the particles. Instead I’m using what’s known as reverse advection to take the information from another texel by using the current texel’s velocity and “look back in time” advecting the visibility and the velocity itself. There are some really ugly artifacts in the gif though. I’m far from done if I want something near real fluid dynamics. Maybe I can use a blur shader to spread the velocities thereby removing the border artifacts, or just some kind of interpolation, or try to understand how others did it with the very limited number of resources I’ve found on the inernet x)