Updated: much higher res at 60fps, thanks to indexed userdata copies!
Yup, it's a smoke simulation toy for Picotron! Use your mouse to play. Should run at a nice steady 60fps after the first ~1s.
Uses userdata to make pressure projection steps almost free. That's great, since those steps were super-expensive in the PICO-8 version! Unfortunately, advection still has to be done with loops in userspace Lua code, and so that part didn't really see any speed increases, and is the new bottleneck.
There might still be some rendering tricks to speed this up, and I need to see whether some tricks I gave up on in the PICO-8 sim, like a MAC grid or vorticity confinement, might be viable here. Unfortunately higher-order interpolation, which I know would help a lot, is probably not happening without major new userdata features.
this is really cool! I added some color and auto-motion to make a screensaver version:
@pancelor: That's awesome! Makes me wish I had gotten this to be higher-res :)
@merwok: It's pretty much following Jos Stam's Stable Fluids method: https://pages.cs.wisc.edu/~chaol/data/cs777/stam-stable_fluids.pdf / http://graphics.cs.cmu.edu/nsp/course/15-464/Fall09/papers/StamFluidforGames.pdf
@zep: I'm not sure what your goals for userdata are, but this is perhaps a somewhat interesting "real"-ish test case for generalizing to more complex systems.
I think what would be necessary to completely vectorize this is:
- min/max (and ideally abs - required for e.g. vorticity confinement)
- float->int conversions, or a fast way to do fixed point (shifts?)
- indexing userdata with userdata
... I think those three things would make it possible to implement the backtracing/sampling step without explicit loops?
This is awesome. Hope you don't mind, but I borrowed your colour re-mapping code and wrapped it in a function to map a palette entry to any RGB value.
function rgb(colorNum,r,g,b) r,g,b=flr(r),flr(g),flr(b) pal(colorNum, (r<<16) + (g<<8) + b, 2) return colorNum end |
[Please log in to post a comment]