Author Topic: Smoke animations  (Read 14370 times)

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Smoke animations
« on: May 11, 2009, 01:38:40 pm »
I have been playing around with Photoshop to try and create some billboardable smoke animations with alpha (keyframes in .png format).  What I've been doing is drawing some grey cloud shapes and applying blur effects to them.  My results thus far have been ok, but I can't seem to make the smoke "lumpier" (areas inside the shape that are more transparent than other areas).  Does anyone have experience with this, or know of some good photoshop tutorials?

Offline C3R14L.K1L4

  • int
  • **
  • Posts: 54
    • View Profile
    • CK's place of many works
Re: Smoke animations
« Reply #1 on: May 11, 2009, 08:39:23 pm »
Holy s*** :P doing that work by hand and frame by frame... mercenary job... and if you want it fluid (with high fps) -> more job :o
I have no experience in photoshop's masks (I think they're related to transparency, right?) but in paint shop pro you can easily do that by taking the original smoke image and create a new mask from the pixel's intensity value so you'll end with a graymap as alpha map. Then you can go back and forth between the smoke and transparency images refining what you want.

Look at the following skillfully drawn images:  ;)



nice smoke hein?



creating the mask



from illuminance



result



viewing the mask, then allowing editing it



inverting the mask and doing some excellent painting work -> extremelly sexy smoke ;D

I think it's this you wanted to know but as I said, doing this is boring... Doing a "simple" program to generate smoke and save it's animation may prove worthwhile on the long run... And there must be free software for this (procedural generation and animation?...)
« Last Edit: May 11, 2009, 08:44:54 pm by C3R14L.K1L4 »

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: Smoke animations
« Reply #2 on: May 11, 2009, 10:44:02 pm »
Thanks for the illustrated explanation!  After looking over this, I think I have figured out what I am doing wrong.  This appears to be more or less the same procedure I am using in Photoshop, the only difference is that I am starting with a single solid black-and-white cloud shape and applying a Gaussian blur filter to it.  The result is unlike your nice lumpy/billowy starting image, in that the entire shape is darker toward the center and lighter toward the outside, rather than having a lumpy look to it.  That seems to be the part I am missing to make my smoke more cloudy.  From the look of your image, I assume you started with unconnected shapes of various sizes rather than a single shape, correct?  I'll try playing around some more to try and get a starting image like what you have here.

Holy s*** :P doing that work by hand and frame by frame... mercenary job... and if you want it fluid (with high fps) -> more job :o
Well, my plan is to only procude like 3 or 4 keyframe images with incremented alpha intensities.  Then in my game I would cycle through them on a billboarded quad with TRANSPARENCY_MODE_ADD and LIGHTING_NO_LIGHTS.  But rather than simply jumping from keyframe to keyframe, instead I would transition between them using setAdditionalCollor with an intensity-per-milisecond value, setScale with a scale-per-milisecond value, and translate with an offset-per-milisecond value.  That way, faster fps should result in a more fluid animation without having to draw more keyframes.  I have no idea how this will end up looking, but I'll post an example when I get it working.

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: Smoke animations
« Reply #3 on: May 11, 2009, 11:46:50 pm »
Ok, I found a pretty good method for creating lumpy smoke.  I start with a simple spray-painted image with areas of different saturations to give it some feel of depth:



I then invert that, apply the Gaussian blur, and use it as a mask, resulting in:



This was only my first attempt, and it is already much closer to the kind of look I was trying for.  I still want even more depth, but at least I am on the right track now.  I'll probably try playing around with different color combinations to see what I can come up with.

Thanks again for the help!

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: Smoke animations
« Reply #4 on: May 12, 2009, 02:17:49 am »
After playing around with this some more, I have finally been able to achieve my goal of nice fluffy smoke images.  I thought I would outline the procedure for anyone interested (using Microsoft Paint and Adobe Photoshop).

1) In Paint, use the Airbrush tool to draw a simple smoke sphere.  Use white, black, and shades of gray to make it look "lumpy" like a cloud, something like this:


2) Load your cloud in Adobe Photoshop, and go to Image->Adjust->Invert.  The result should be a mask that looks like this:


3) Open an image of some real-life smoke.  I used the following jpeg of cigarette smoke:


4) Go to Image->Image Size, and make your smoke image the same size as the mask in step 2 (make sure "Constrain Proportions" is not checked).

5) With the "Select" tool on, right-click the resized image and choose "Select All".

6) Go to File->New, and make a new image the same size as the mask in step 2 (make sure "Transparent" is selected).

7) Go to Edit->Paste.

8 ) Go to Layer->Add Layer Mask->Hide All.

9) In the Layer Pannel, choose the "Channels" tab.

10) Turn on the Eye next to "Layer 1 Mask":


11) Go to the mask image created in step 2, select all, and copy.

12) Return to the new image from step 6, and paste.

13) Go to Filter->Blur->Gaussian Blur

14) Move the slider to achive the desired fuzzyness, and click Ok

15) Return to the "Layers" tab in the Layer Pannel, and select the "Layer Thumbnail" to see the final result:


I will now begin programming the smoke animation in jPCT, and I'll post a demo applet when I get it working properly.

Offline C3R14L.K1L4

  • int
  • **
  • Posts: 54
    • View Profile
    • CK's place of many works
Re: Smoke animations
« Reply #5 on: May 12, 2009, 01:37:07 pm »
Humm, I want to see the ending result ;)
What kind of smoke are you trying to produce? From a cigar? Fire? Soot?

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: Smoke animations
« Reply #6 on: May 12, 2009, 03:34:57 pm »
For now I want something like exhaust smoke.  However, this procedure could be used for many kinds of smoke and explosions by simply changing the shape of the mask, the photo, the amount of blur, and the alpha channel.

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: Smoke animations
« Reply #7 on: May 13, 2009, 04:02:57 am »
Ok, I have finished writing the demonstration:

http://www.paulscode.com/demos/SoundSystem/12MAY2009/Helicopter.html

This is a proof of concept more than anything.  I only used two keyframes and a simple sphere shape moving in a straight line.  The affect could be improved with more keyframes and using something like a cosine function for more realistic movement.

The code is still pretty ugly at the moment.  This is going to be the new and improved helicopter demo when it is finished, and I'll post the source code on my 3D Sound System thread when it is complete.

Offline C3R14L.K1L4

  • int
  • **
  • Posts: 54
    • View Profile
    • CK's place of many works
Re: Smoke animations
« Reply #8 on: May 13, 2009, 10:15:08 pm »
Ehehehe, a smoking helicopter ;D
Well done, and if you animate the smoke clouds (and perhaps some kind of morphing between frames) that would be perfect.

Offline JavaMan

  • long
  • ***
  • Posts: 231
    • View Profile
Re: Smoke animations
« Reply #9 on: May 14, 2009, 01:37:10 am »
Cool, it looks like its about to sputter out.  ;D Very smooth animation on my box.

I know this is just test for smoke and nothing to do with sound, but as a side note, I opened up the applet in new tab in FireFox3. When I closed that tab, the helicopter sound continued to play until I ended the java thread in Vistas task manager.   ::)
« Last Edit: May 14, 2009, 02:03:08 am by JavaMan »

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: Smoke animations
« Reply #10 on: May 14, 2009, 02:44:19 am »
I know this is just test for smoke and nothing to do with sound, but as a side note, I opened up the applet in new tab in FireFox3. When I closed that tab, the helicopter sound continued to play until I ended the java thread in Vistas task manager.   ::)
Thanks for noticing that.  It is because I never called SoundSystem's cleanup() method.  In JavaSound (which this applet is using at the moment), looping sources will continue to play until Java is shut down (usually by closing all browser windows).  If I had used OpenAL, even worse things could happen (for one user, forgetting to call cleanup resulted in the OS crashing and his computer had to be rebooted).  This is a great example of why it is always important to call the cleanup method at the end of a program when using SoundSystem.

Offline JavaMan

  • long
  • ***
  • Posts: 231
    • View Profile
Re: Smoke animations
« Reply #11 on: May 14, 2009, 12:45:59 pm »
Quote
(for one user, forgetting to call cleanup resulted in the OS crashing and his computer had to be rebooted

Gulp, uh I'm glad you were using JavaSound. With this Vista thing that might have happened!

« Last Edit: May 14, 2009, 12:59:20 pm by JavaMan »