Smoke Simulation banner

Smoke Simulation

21 devlogs
66h 8m 19s

Simulating smoke in 3D using C + OpenGL 3.3

blob blobbing

Smoke can now be colored! Should make creating emitters easier and should implement wind now

Attachment
0
blob blobbing

actually improved ray marching :) damn does it look good

Attachment
0
blob blobbing

Cleaned up the code, realised vorticity confinement has some bug that leads velocites to explode after a while :/ they don’t explode for the first 10 seconds or so tho so it kinda works there? That will be something I’ll fix after school trip.. it’s headache inducing…

Attachment
0
blob blobbing

No way I just spent an hour looking at all shaders code, trying to understand whats wrong ,double checking math just to realise I was not binding the damn buffers on the gpu before initializing solid map.. how did I not notice from the start.. in the pic velocities are finally properly contained in the grid.. wow what an overlook

Attachment
0
blob blobbing

Ugh.. while working on vorticity confinement i noticed my damn velocities are slipping into solid cells. no idea where this is happening but its making smoke escape..

Attachment
0
blob blobbing

Temperature introduced! now onto vorticity confinement, afterwards i can finally work on tidying code up, adding external forces and making my smoke more smokey

Attachment
0
blob blobbing

Implemented some rudimentary ray marching. I hate pretty much everything about it, how flat it looks, how SAD it looks, but its fine as for now I just need to be able to see what my smoke is doing.. Will work on buoyancy and then I should be done with most of 2d -> 3d port, allowing me to work on a more exciting way to visualize this smoke..

Attachment
0
blob blobbing

finally managed to draw some kind of arrows ( i hate them, but they do their job quite fantastically for debugging purpouses ). Without them i would not have been able to get advection working.. at all. In the attached photo, properly advected +10.0f velocity at P(2,4,4) (grid size: 9^3)

Attachment
1

Comments

YourLocalSatyrFlip

SO COOL!

blob blobbing

Well the grid looks good.. time to move into coding the smoke..

Attachment
0
blob blobbing

slowly transitioning to 3d.. got the axis drawn! well, more importantly, started implementing the camera system and everything that could be completely ignored in 2d.

Attachment
0
blob blobbing

Cleaned up some code. Kind of happy with how my smoke behaves. Will now move to 3D! this is gonna be painful and im gonna regret this.. will backup all files because I know many things will break :/
Don’t even know where to start with visualization

Attachment
0
blob blobbing

temperature introduced! cold smoke falls, hot smoke rises!
as always it initially broke everything! had some issues with buffer swapping functions

Attachment
0
blob blobbing

it finally works on the gpu… man did it make me lose my mind… I was sampling incorrectly as i didnt realise how opengl’s texture() works.

1000x1000 grid. Gpu starts getting hot..

Attachment
0
blob blobbing

10h in im losing my mind. It’s way smoother on the gpu, but my advection program was wrong: it was for whatever reason advecting diagonally (??!!??!!) so I tried to fix it, just to end up with velocities completely disappearing (?!?!?!). Because of that i can’t even show how smooth it was, so this devblog will just be a high resolution grid being drawn…
I liked cuda way more. way more.

Attachment
0
blob blobbing

With velocity advection figured out I finally implemented smoke which is the main point of the simulation. Looks good, and as expected FPS are horrible and we’re still in 2d with an extremerly small resolution. I will start learning about opengl compute shaders now and will port most of the code to those.

I hope they are similar to CUDA ones otherwise this is gonna be rough

Attachment
0
blob blobbing

Arrows are drawn properly and divergence is finally being resolved.. fixed the math issues

Attachment
0
blob blobbing

Working on some arrows, I understood my grid was being drawn incorrectly. It took me 5 whole hours for one of my dumbest mistakes ever.. this was a headache (10x10 grid was drawn as 8x8. Now its properly drawn)

Attachment
0
blob blobbing

Got a way to visualise divergence. Will work on 2d until math works, then Ill port to 3d.

Attachment
0
blob blobbing

Got to transformations, textures. So far enjoying the OpenGL learning experience. Should soon start working on the smoke sim!

Attachment
0
blob blobbing

Got to the rainbow triangle, implemented shader source parser

Attachment
0
blob blobbing

This will be a fun transition from my previous fluid sim project. Decided to drop WinGDI which I previously used as it proved to be painfully slow (I mean, part of the reason I chose wingdi was because I knew it was painfully slow) and CUDA as I want it to be usable on as many platforms as possible (Even if I really enjoyed CUDA programming!). I know NOTHING about openGL so my first project hours will probably be spent on learning opengl. So far? Set it up and got a window running! Good start. As soon as opengl clicks in I will start working on the smoke simulation math. First CPU; then slowly will transition it to GPU.

Attachment
0