Smoke/fluids simulation using Pixel Bender – part III

smoke-v3The third pass at smoke/fluids simulation again looks quite different from the previous two attempts, but this time it’s stable both when keeping still as while moving. Not surprisingly, as the current approach is more like Stam‘s fluid solver. The downside is that it’s much less processor-friendly: every new step (adding forces, diffusion, advection, updating boundaries, …) needs the previous step to be completed over the entire velocity or pressure field. As a result, this simulation is using 9 different Pixel Bender kernels. In total, 49 pixel bender filters are executed per frame, some more intense as others, along with some BitmapData methods. Consequently, the grid size needs to be scaled down a lot  (64×128 in the example). All in all, I’m still surprised that it doesn’t slow down to a crawl!

The FluidBitmap class has some properties such as timeStep, buoyancy and viscosity, which can influence the look and tempo of the fluid, but can affect the stability of the solver due to precision errors using BitmapData. There is support for forces, encoded in a BitmapData, similar to the velocity field (red = x, green = y). Maybe some day, I’ll make working with these forces a bit easier, but for now I’ll focus on other things than fluids ;) 

The demo – A smoke simulation using positive buoyancy. Click to show the red and green channels representing the velocity field.

The source

Oh, and a happy new year! :)

19 thoughts on “Smoke/fluids simulation using Pixel Bender – part III

  1. It is interested smoke. It visually more beautiful. But my computer had braked with mouse moving. In Process Explorer FF shows ~30% CPU. I don’t know why slow down had been 8-)

  2. Thanks all!

    Foreground: only 30%? That’s quite a surprise, mine is pretty much maxing out!
    Taha: Yeah it’s rather intensive. Tuning down the grid size wouldn’t be a bad idea :)

  3. kevin: thanks! (and thanks for PB in general ;))
    Subblue: Thx, I thought it’d be interesting to show what’s under the hood; it turned out rather trippy :)
    Foreground: Hmm, guess it was something temporary, it seems to work again.

  4. David,
    I can get the demo to work in FireFox. All I get is the “Der Schmale” logo. Works fine in Internet Explorer (6.0)
    I’m using FireFox 3.05 on Windows XP. Flash version 10.0.12.36. I suspect its something to do with the Flash detection you’re using.

    Still once I got it working its a really impressive demo. Well done.

    Cheers

    Joe

  5. Joe: Hmm that’s strange, I have the exact same configuration here. The version detection is straight from what Flex Builder 4.0 builds (tho I have had issues with the Flex 3’s version detection before) :/

  6. David,
    Hmm, works now in FireFox. It prompted me to update my flash player and then updated it again to 10.0.12.36 and now works. I don’t know if you changed anything but many thanks :)

    J

  7. hi there,

    nice way of using pb. have you thought about a addition displacement-like map so the cursor creates turbulences as well?
    just thought of that because that was a damn cool effect in a snow simulation of mine years ago ;D

    cheerio

  8. Hi Kris, instead of using a displacement map you could manipulate the force bitmapdata to create windflow caused by your cursor. It could take some effort, but it should have a more realistic impact on the smoke flow tho :)

  9. James: I’m not sure about exactly what you can do using Pixel Bender in After Effects, but seeing as there’s quite a bit of Actionscript logic behind the simulation, I fear that a conversion could be quite difficult.

  10. Pingback: Experimenting with Alchemy: of Smoke, Milk, and Ink | Der Schmale - David Lenaerts's blog

Leave a Reply

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