Chain Smoking

October 21st, 2006

Two days left.

Jason Harris, the mind behind Shapeshifter and other amazing technologies (read: Disco’s smoke effect) has some comments on the smoking Disco window.

So sit back and check out the story behind the feature that makes Disco a true product of Amsterdam.

The Challenges of Being a Smoker by Jason Harris

Austin gave me a sneak peek at Disco this summer at WWDC. Jasper’s graphics were simply stunning, even at that early stage, and the workflow had already come together enough that I instantly saw what a great success the app was going to be.

But then Austin said, “And check it out, it smokes while it’s burning!” And proceeded to show me the most vile puke yellow Quartz Composer rendition of the built-in graphics card fog effect possible. It was brain-searingly horrible.

Well, I like hard problems, and I have a background doing turbulence modeling of quantum probability flows, so I’ve seen the math before. I thought about it for a few minutes and then offered to help out on the smoke end. Austin and Jasper took me up on.

Here’s the trick: They wanted the user to be able to swirl the smoke around with the mouse. Now, smoke is a pretty complex phenomena, and moreover, there are a bunch of different types. Smoke from a point source (like a cigarette) tends to go up in a straight column which suddenly turns chaotic at a phase change boundary. But smoke from a line source (like the top of Disco’s window) behaves completely differently. Putting the user into the picture meant that the smoke had to model turbulence properly, or at least convincingly.

So, I spent about a week just thinking about it, and staring with fascination every time I saw any sort of smoke. People must have thought I was insane. Then I spent a week doing math. Just writing down equations, staring at them, thinking about them, erasing them. Then I spent about a week coding. I finally got to the part where I entered in all of the equations. I compiled (no errors!) and ran it. Holy smokes! It looks like smoke! I did a weeks worth of math and a week’s worth of coding and it worked on the first try! (For the non-programmers among you, this never, ever, ever ever happens. Ever.)

But then came a month of optimization. During this optimization, the smoke algorithms moved from the CPU onto the graphics card, back to the CPU, and then to a hybrid of both. Now, the GPU is acting as a fast parallel processor - it’s doing most of the work, but most of what it’s doing are the science calculations, not just rendering. That’s pretty cool, and my Googling tells me that the science visualization peeps think it’s a good plan, too.

Unfortunately, doing the computation on the GPU means that the GPU needs to be able to talk about floating point numbers. Intel GMA 950 integrated GPUs don’t, which is why we’re not currently supporting Smoke on the new MacBooks and Mac Minis. I hope to have a solution in place that will work on these machines, without the mouse interaction, sometime soon. And, just by the way, the GMA 950 pisses me off. Who doesn’t support floating point textures in 2006!!??

So that’s it! And, just in case you’re curious or want to brag to your Windows friends, the smoke you’re seeing in Disco is a particle dynamics simulation that balances atmospheric pressure diffusion, heat diffusion, buoyancy principles, brownian motion, velocity damping, and external wind forces. And audio processing. The simulation is performed discretely on a mesh with Dirichlet boundary conditions and a central weighting scheme for the derivatives and Laplacians.

Enjoy the cancer discs!

Posted by Austin
Filed in Disco

37 Responses to “Chain Smoking”

  1. flinch13 Says:
    October 21st, 2006 at 3:00 pm

    I like, is nice!

  2. evariste Says:
    October 21st, 2006 at 3:09 pm

    I am not intelligent enough to understand the above, but I am intelligent enough to be impressed.

    Ooh, pretty smoke!

  3. Matt Tavares Says:
    October 21st, 2006 at 3:10 pm

    What would be amazing is if you use CGSWindowWarp to distort the top of the window. If you ever look at the top of anything hot (e.g. toaster) their is always a wavy distoration around the top.

  4. Dinesh Cyanam Says:
    October 21st, 2006 at 3:10 pm

    Wow….the equations part is amazing.
    Can’t wait to get the beta.

  5. Schlaeps Says:
    October 21st, 2006 at 3:35 pm

    Awesome.

  6. Joel Longtine Says:
    October 21st, 2006 at 3:36 pm

    That’s awesome! As a computer science major/physics minor at the Colorado School of Mines, I have some interest (and a very small bit of experience) in simulation, so to hear about the actual math is rather fun. I’m a geek that way… and in plenty of others, if you ask my friends. spacer

    Thanks for the insight, and congrats that you got it working first try. I’m very impressed, especially with a mathematically and computationally difficult problem like the one described, that you were so successful the first try.

    Looking forward to using Disco (and playing with Jason Harris’ sim!). Good Luck!

  7. oakleaf Says:
    October 21st, 2006 at 4:07 pm

    Jason, you truly are an artiste.

  8. zeno Says:
    October 21st, 2006 at 4:28 pm

    Jason, you’re a geek. Cool!
    Now, I have a question…(the answer will be easy once the app is released but I’m really freaking curious to know it now):
    you have a document on your Desktop, you adjust Disco’s window so that it “smokes” over that document icon (you can see the icon through the smoke), then you click on the document icon…what happens?
    - will the document get selected?
    - will Disco remain the front-most application?

    Sorry, it’s not that important, it’s just a developer curiosity

  9. Logan Rockmore Says:
    October 21st, 2006 at 4:29 pm

    awww… no MacBook smoke…. that makes me sad….

  10. Kodac Says:
    October 21st, 2006 at 4:53 pm

    Wow, gotta love that last part. spacer If they’re not in the least bit geeky, I can just see their eyes glaze over… spacer

  11. Kisco Says:
    October 21st, 2006 at 5:28 pm

    only 2 times two words :
    thank you !
    “vivement lundi !” (sorry for the french)

  12. Ola Bungum Says:
    October 21st, 2006 at 5:55 pm

    Great story I must say…
    Fantasticular

  13. Ryan Miglavs Says:
    October 21st, 2006 at 5:57 pm

    Wow. That’s genuinely incredible.

    If I just read that last paragraph, I would never guess Disco is a disc burning tool.

    Sweeeet.

    (beautiful work, by the way)

  14. mike Says:
    October 21st, 2006 at 6:02 pm

    I don’t know what half that means spacer but it sounds fantastic…

  15. lgc90 Says:
    October 21st, 2006 at 6:04 pm

    Thanks for working on a solution for the intel integrated graphics users out there. I really don’t care about being able to stimulate it with the mouse, but the thought of the window actually appearing to be “burning” just seems completely awesome. Keep up the good work!

  16. Chris Says:
    October 21st, 2006 at 6:12 pm

    Ok he totally lost me in that last paragraph….buts awesome none the less…Amazing what the mind can come up with and do. Awesome work guys…Can’t wait till Monday.

  17. c. Says:
    October 21st, 2006 at 6:16 pm

    it’s amazing.

    boggled.

    c.

  18. Danny Cohen Says:
    October 21st, 2006 at 6:36 pm

    Is there a way that if a burn goes wrong, the whole window just FOAMS up?

    congrats on the smoke system. what does the blowing into the microphone do?

  19. Anson Says:
    October 21st, 2006 at 7:50 pm

    Wow, I thought that it was just some kind of library that was already available. I’m very impressed. Great work, Jason!

  20. Joel Heflin Says:
    October 21st, 2006 at 8:06 pm

    Still sad the smoke won’t work right on my MacBook, but at least it will work on my older Mac mini.

    I’m super excited!!!

  21. evil_marty Says:
    October 21st, 2006 at 11:57 pm

    Thats some pretty intense computation for something nothing more then eye candy. Just the length and breath of work involved is incredible. So in total does the cpu usage in disco get heavy to the point u cant really do anything else?

    Kudos for the effects though, I’m loving this app more and more =)

  22. Disco - I told you at keep me from blogging Says:
    October 22nd, 2006 at 1:08 am

    […] Übrigens: Jason Harris, der Kopf hinter ShapeShifter, schreibt über die technische Umsetzung des Raucheffekts. Filed under Web.  | Tags: Apple, disco, icon, jason harris, shapeshifter. […]

  23. luke Says:
    October 22nd, 2006 at 7:16 am

    My Macbook certainly gets hot enough to produce smoke - so it should work no??

  24. DK Says:
    October 22nd, 2006 at 10:59 am

    What about older pre-intel Macs? Will the smoke effect work on my PowerBook G4 with GeForce4 MX/32MB VRAM?

  25. some dude Says:
    October 22nd, 2006 at 1:30 pm

    luke, well…yeah…you’ve got the real thing instead of something simulated. Lucky bastage.

  26. Disco-a-go-go! Says:
    October 23rd, 2006 at 12:01 pm

    […] One of the cool features was some of the extra little UI things like smoke, that had enticed me as the development of the project wore on. Unfortunately, as detailed on the Disco blog, MacBooks are not yet supported . While I hope this changes soon (check out a video demo of it here) it certainly doesn’t impact the day to day usage of Disco. […]

  27. Tom Dibble Says:
    October 23rd, 2006 at 2:58 pm

    Interesting.

    I did a flame/smoke/slime simulator in Intel ASM on a 386-SX/16 back in 1994. It was a rather convincing effect. Granted, I was operating on a 320×240 (or was it 320×200? I forget the details on VGA modes nowadays …), but it was rather realistic. Looking at your video clip, I didn’t have any “fall back” at the top (the visible flame portion ended about mid-screen, and heat-distortion portion was above that straight up to the top of the screen) … but then, that’s the part of the effect I like least on your implementation, primarily because thermal layer interaction and/or major soot fallback isn’t something that I see very often in real flames.

    Seems like the math was fairly straightforward to get a convincing display back then, and that was without an FPU, much less a FP-enabled GPU! Um, and, yea, it was running at around 5-10 fps average on that old 386-SuX, along with cycling colors in the pscycariffic plasma background. IMHO, the things that made more people say “wow” were the starting of the flames (ignition) and the “cutting off” of the flame source (stop generating seed cells, but allow the existing heat cells to continue rising up the screen and dissipating away).

    Other things I had going were “slime” mode (different coloring and dissipation factors, reversed to flow down as from gravity instead of up from convection) and heat/waterwall effects (no visible effect from the flame/slime, just rippling).

    Anyway, it was a fun little useless eye-candy project to work on, as I imagine this was!

    [Side note: I looked “TPlas” and “Tom’s Plasma” up in Google to see if there remained any mention of my little app, and found an old version of the source (prior to the flame/slime/etc overlays) and the manual too. Unfortunately, that version was just the “plasma” generation/display stuff. Cool, but not exactly relevant here … TPlas 2.0 I believe added all the flame stuff, whereas TPlas 1.1 was just the plasma/swimming/clouds effects. One of these days I’ll sit down and recode the whole thing in Cocoa just for grins …]

  28. Tom Dibble Says:
    October 23rd, 2006 at 3:16 pm

    Ahh … Search for “tplas20.zip” … the .doc file there gives a better explanation of the effects used, a bit better than my rambles above, for anyone interested in old DOS non-utilities spacer

  29. Chris Howard Says:
    October 23rd, 2006 at 9:53 pm

    “I did a weeks worth of math and a week’s worth of coding and it worked on the first try! (For the non-programmers among you, this never, ever, ever ever happens. Ever.)”

    LOL! That’s a programmer’s worst nightmare. You just don’t know where to start debugging.

  30. Emberek a szoftver másik oldalán - Worldshots Says:
    October 24th, 2006 at 1:27 am

    […] Chain smoking - hogyan lehet élethű füstszimulációt írni a készülő cd író programunkhoz. […]

  31. Step Says:
    October 24th, 2006 at 4:56 am

    Very impressive - glad to hear you’re trying to get it working on the new Mac Mini’s, as that’s what I have. I didn’t understand half of the last paragraph, guess I’ve got something new to go learn. spacer

  32. Disco! Disco! Disco! « blindapeinc. Says:
    October 26th, 2006 at 3:17 am

    […] Yes, your dvd is burnt, so, there’s gotta be smoke. A great feature. You can read more about this feature on their website… here: discoapp.com/blog/?p=23 […]

  33. BabyBlue Says:
    October 27th, 2006 at 9:01 pm

    Here’s a tip for Jason -

    www.siggraph.org/

    Rather than re-inventing the wheel - just get the code and published papers there. I believe I read about smoke simulation at least 5-6 years ago or more.

    But, your story sounds more impressive to the kids.

  34. Jason Harris Says:
    October 28th, 2006 at 7:44 am

    BabyBlue, I looked at the siggraph code during development. It’s not suitable for Disco’s purposes because of the mouse interaction - that adds a lot of difficulty to the implementation, as it constrains things on both the input and the output sides.

  35. Stephan Says:
    October 30th, 2006 at 2:40 pm

    You really rock! I like DISCO very much. And the SMOKE EFFECT is stunning… So, keep on developing great apps. Best wishes, from Germany!

  36. Vacuous Virtuoso » Blog Archive » Passive smokin’ Says:
    October 31st, 2006 at 11:09 pm

    […] With all the fuss over Disco and it’s smoke effect, Jonathan Wight decided to take a deeper look. The result of his labor - anyone can integrate smoking windows into their apps. Stick around and let me show you how. […]

  37. Bret Says:
    November 4th, 2006 at 7:15 pm

    >> For the non-programmers among you, this never, ever, ever ever happens. Ever.

    Actually… that did happen to me once… once. Never seen it since thou…

Leave a Reply

spacer spacer spacer spacer spacer spacer spacer