Experimenting with Alchemy: of Smoke, Milk, and Ink

Smoke and Milk simulationThanks to Ralph Hauwert’s blogpost pushing a baffling >300.000 particles using Alchemy, I finally got the much needed motivation to try out Alchemy myself. To be able to get started asap, I decided to return to something I’ve done before: fluid and smoke dynamics, but with a different algorithm (see Mike West’s article on Gamedev). It took me a while to figure it out, but it’s up an running! It’s a faster algorithm, but less physically correct.

While I typically would do most of these kinds of calculations in Pixel Bender, for the examples below, I decided to try it all in C and see how far Alchemy can be pushed. The grid is bigger than before, while the framerate is steady around 20 on my machine. Ralph has suggested some improvements for the rendering step already (thx! ;)), so I’ll have some more experimenting to do :D

It was great to return to C, especially since it’s been 8 years since I’ve written my last line in that language. Quite a rush of nostalgia!

Source is included with the demos, tho it’s not the most reusable I’ve ever written :)

The HiRes FPS counter is done by Mr. Doob.

20 thoughts on “Experimenting with Alchemy: of Smoke, Milk, and Ink

  1. Nicely done. I did hit a range error at cmodule.FluidSolver::FSM_advectBackward$/start() after some time, but I know first hand how tricky Alchemy can be to debug. :) Inspiring stuff!

  2. Peter: Ah yes, I’ve come across that as well. It happens when air velocities grow much to large, since there’s no real relaxation step. After some tweaking it didn’t seem to occur anymore, but it seems it is. Capping the timestep at a lower maximum should be a quick fix, I think.

    Subblue: Thx, it’s definately worth checking out! :)

  3. This smoke air is good whell for me! But spread of smoke from source is not so good. But it so cool David, because u use alchemy with this experience! I have a small bug when try to view source by right-clicking on swf window. My browser become inactive. I think it show signs of threads lack.

  4. Pingback: More play with Alchemy : Lookup table effects. | UnitZeroOne

  5. Foreground: Thanks! The context menu is often a bit unresponsive when the cpu is taxed, I’m not sure if anything can be done about that.

    Nicoptere: Cheers. I’m liking your blog a lot, just subsribed (and pushed a link on twitter ;) )

  6. Pingback: Smoke effects using Alchemy Particle System - peter nitsch.net

  7. oh how very neat!
    glad you put a stormy cursor in there this time, really adds some realism to the whole thing and makes it fun to play with.

  8. Pingback: More play with Alchemy : Lookup table effects. - unitzeroone(beta)

  9. Pingback: Hello World « Flash Toys

  10. Very nice, i would like use the smoke simulation in flash cs4 (.fla) but i don t know how implement your source in it. Can you explain me? tank you a lot

  11. Wor: You’ll need to include the FluidSolver.swc to your CS4 project, and copy most of the code to your timeline or document class. Since it’s using Alchemy, I don’t recommend using it in a real project tho.

  12. Pingback: Smoke #1 • Blog Archive • Visual Gratis

  13. Hello,

    I would like to create a simple online 2D wind tunnel. I do not need a physically perfect result. but something like in http://algorizk.com/windtunnel/. I have tried to understand navier stoke algorithms for hours and make some progress. That wasn’t a surprise to see that flash is not fast enough to make a grid bigger then 20×20 while having 20+ fps without using pixel blender or alchemy. And now I’m lost in your pixel blender example. It looks really good but i would like to know if it possible to add internal boundaries ?

    Best,

  14. Baris: Technically, that’s definitely possible, but not without some work to take into account arbitrary boundaries. Don’t have any resources on hand right away, but a quick web search should help you along :)

Leave a Reply

Your email address will not be published. Required fields are marked *