"Realistic fire, Weta-style"

Yes, this was rendered in tS.
Realistic Fire tutorial © 2002 Christiaan Moleman a.k.a. Ninja Dodo. Stills and animations created by Christiaan Moleman.

Some time ago I read an article in
3D World magazine (issue 22) about The Lord of the Rings. There was a part in the article that I found particularly interesting...

As described by Tolkien, the Balrog is a demonic entity standing some 40 feet high, wielding a whip and a fiery sword.
(...)
CG flame effects are notoriously artificial looking, so the use of completely rendered fire was dismissed fairly early on during the production schedule.
"CG fire usually has a soft look to it that you can spot straightaway. We wouldn't have been very happy with that, so it was either a matter of actually setting fire to something and compositing that onto our model or coming up with a better way. We actually did shoot tests using gas jets, sort of doing shadow puppets with real flame, but it never looked close to being convincing. You just never got the right sense of scale."
Instead, the artists made use of Maya's particle system, but rather than rendering the fire as a pure particle effect, individual shots of real fire were added as sprites to each of the 50,000 particle elements. "It means each sprite is animated and then so is the particle itself. The results look pretty incredible."

So there you have it. That's how Weta Digital does CG-fire...
It makes sense and it occurred to me that this technique should work just as well in trueSpace.
So how to do this?
Obviously the main ingredient you're going to need is fire footage. If you're lucky enough to have the book "Inside trueSpace 4" (by Frank Rivera) you'll find excellent footage in the "Artbeats" directory on the CD. For this tutorial I will be using the "Funnel_T.mov" film from this very CD.

If you don't have the book I suggest you either get it (the Artbeats footage is just one of the great reasons to buy it),
or you could check out their website: http://www.artbeats.com

A quick overview...

First I'm going to explain how to turn footage into usable texture material. Then how to apply that to the particles.
The technique applied here can be used in many ways, but for the sake of simplicity I'm going to cover only two.
Method 1 - 2D (using Primal Particles FX) - quick, simple and with excellent results. And from the article ("... shots of real fire were added as sprites ..."), we can assume this is the method Weta used...
Method 2 - 3D (using Python Scripts) - doesn't yield as good results as the the other but if you don't have PPFX, it's a reasonable alternative... Keep in mind that the same process can be used with any type of particle system that creates actual tS objects (trueParticles, the old Primal Particles, etc...) and may in fact work better than shown here.

[edit: Primitive Itch, the creators of Primal Particles, have since closed shop and made their plugins publicly available for free , including PPFX... even trueSpace itself has recently become freeware]



(from here on I'm assuming you have the InsidetS4 CD)

Footage to Texture

1) Open "QT2TGA.EXE" in the "Artbeats\QuickTime to Targa Converter" subdirectory on the InsidetS4 CD.

!!! IMPORTANT: This converter only works with quicktime versions older than 4. What you need to do, is get an old version of Quicktime and install it. You don't have to uninstall the new version you have, though. The different versions operate alongside each other quite nicely.
If you don't have any version of Quicktime, I suggest you install the new version after the old one. If you've installed the new one first, you'll have to change the "File types" preferences back after you install the old one so that Quicktime files are opened with the new version, or you can just reinstall the new version.


2) Make sure the settings are like this (the letter of your cdrom-drive might be different though):
the converter


3) Choose a directory as the "Target Directory". I used "E:\tS5\textures\other\artbeats". Then click "OK".



Method 1 - Primal Particles FX
- back to top

1) Start a new scene in trueSpace and open PPFX. Create a new emitter.


2) Open the emitter properties and set the "Frame Offset" to -50. That way, the particle system starts moving 50 frames before trueSpace does and so you can see it in action at frame 0.


3) Render the scene. As you can see, this doesn't even look remotely like fire. The particles are sprayed in too many different directions and the particles appear to have too much weight. Fire is basicly hot air and hot air goes up, not down. Also, the source of the 'flames' seems too narrow.
the beginning


4) Press the "Play" button and go to the particle properties. Click on "System" and change the "Emitter Shape" to "Plane" and the "Emitter Radius" to 1.5. As you can see from the playback you now have a much more focussed particle system. However, the base of the fire is now also wider.


5) Now change the following settings...
"Lifespan" to 40
"Base Gravity" to 0
"Base Speed" to 0.3
"Base Speed Jitter" to 0.5
"Speed" to 0.8
As you can see (if you still have "Play" on) the movement is more like that of fire now.


6) For a finishing touch, change...
"Vortex" to 0.5
"Vortex Jitter" to 0.25
"Rotation" to 1
"Rotation Jitter" to 0.5
This will give the movement a more organic feel.


7) Now it's time to use the fire footage. Go to the "Render" options.
future flames


presto! 8) Click on the image and look for the "firesmall" image files. For some reason the first five frames are the same, so start with "firesmall005.tga". Set the "Alpha Master" slider to 255 and set "Render Mode" to "Illuminate". You might consider "Color Alpha" and I'll admit it doesn't look all that bad but it lacks the layering of brightness that makes the "Illuminate" mode so realistic.
Render the scene.

Now we're getting somewhere...


9) This still needs some work. Some more changes...
"Base Size" to 5
"Base Size Jitter" to 1
"Focus Jitter" to 0.5
"Flow" to 2.5
"Size" unlike the others shouldn't be constant:
the Size graph

1.5 at 0% and 1 at 100%
Also, edit the "Alpha" graph to look like this:
the Alpha graph

0 at 0%, 1 from 5 to 30% and 0 at 100%
The size change is fairly obvious. The flames need to start out big and become smaller over time.
As for the "Alpha"... Well, the flames need to fade away as they shrink until they are completely invisible, but to avoid new flames 'popping' into existence they also have to start out invisible and gradualy appear until they are fully visible. This effect has to be big enough to hide the fact that new flames appear out of nowhere and it has to be subtle enough to not be noticed itself.


Well, this looks pretty good, doesn't it? Now for a final render...
The effect looks best with dark backgrounds, so I changed the background to black, but it works with light surroundings as well...

Of course, this is just a still. You have the movement of the particles but if you want to render an animation you'll need to add the other frames of the flame footage (at the moment we've got only one).


10) Go to the "Render" panel, Click "Add" and select the next frame of the animation. In this case, that is "firesmall006.tga". You'll notice the "Alpha Master" slider is automaticly set to 51 for this new frame. Slide it back to 255. Add as many frames as you think you'll need. There are 210 in total so there should be more than enough. If I'm not mistaken, the footage is actually seamless so if you include all the frames (minus the first static four) you have an infinitely animated flame! For my test anim I'm going to add a 100 frames.


11) For the flame footage animation to actually work you need to set the option that says "Fixed" to "Cycle". This will make the particle cycle through all the frames you've added.
Fully animatable fire


If right, the final animation should look something like this.

To tweak the look of the fire, you're best off editing the following parameters:
"Lifespan", "Base Size", "Flow", "Base Intensity" and "Emitter Radius" (in the "System" panel).
For example, an increased "Emitter Radius" and "Flow" would result in something like the top image. "Lifespan" can be used to edit the height of the fire.



Method 2 - Python Scripts
- back to top

1) Start a new scene in trueSpace and create two (normal, not NURBS) Plane primitives.


2) Open the "Keyframe Editor" and rename the "Plane" object to "flame" and the "Plane,1" object to "emitter".


3) Select the emitter and open the "object info". Change "Location (X,Y,Z) to 0,0,0 and "Size" to 3,3,0. That gives it a convenient central location and a nice managable size. Next select the flame and set its "Rotation" to 90,0,0 so it stands up straight.


4) Change the view (and if necessary the position of the objects) to something like this:
the initial scene


fire material 5) Select the Sphere and open the "Material Editor".
First open the "Color" panel and select "texture map" as the shader.
Now select "firesmall005.tga" as the texture and turn on the "Flt and "Anim" options. The "Flt" (filter) option avoids pixels showing up when the texture gets stretched too much and "Anim" makes sure tS scrolls through all the available frames of the animation (the tga pictures) automaticly during rendering.
We now have an animated flame. However, we still need to get rid of the black background... Right-click on the "Transparency" icon, select "filter" from the "Transparency Shaders" library and set the filter color to pure black. We also need to set the "Reflectance shader" to "Constant". After all, fire provides its own illumination so it shouldn't be dependent on others. Apply the material to the flame object.
A quick render shows, however, that we're not quite there yet.
I don't know why - maybe it's just me - but whenever I apply a texture to a plane it always ends up upside down. Well, that's the obvious fault of the flame at the moment but if you look closer you may also notice the footage has become thinner. This is because the footage is rectangular but the plane is a square. So the texture is squashed to fit on the plane...
Let's fix it.
hm...


6) In order to fix the squashing of the texture, we need to change the UV-mapping. Make sure the flame object is selected and then click on the "Planar UV Projection" button and go to the "Front View". Now select the "Object Scale" tool and stretch the width of the UV-map as seen to the right and finally hit spacebar or click on the "Object Tool".
We still need to make the flame have the right side up, so go back to the "Perspective View", select "Object Info" and change "Rotation" to 90,0,180.
the UV-map is stretched beyond the plane itself


7) Now it's time to start with the particle system. You could use trueParticles or the old Primal Particles, but in this case we're going to use a Python script which I put together for the occasion from two existing scripts by Matthew Bennet and Awedin (Pyticles and Scatter).

Open the "Script Editor" and select "Scene" from the drop-down menu.
the Python ScriptManager


8) Next, open "scatticles.py" (included in above zip file) from the "Scripts" folder. Close the ScriptManager, select the Sphere and then click on the "Play Scripts" button.


Scatticles 1.5
9) The standard settings have been set to what appeared to work best for normal fire, but you're free to change whatever you want...
"Frames" sets the length of the animation and "Frame Rate" determines how many keyframes are made.
"Scatticle Count" sets the amount of particles that will appear during the course of the animation. This has a big impact on speed... both that of rendering and that of particle system creation.
"Time varient" is the frame at which all particles will have been 'born'. No new particles will appear after that frame.
"Velocity" is the average speed of the particles and "Velocity Mod %" is the amount of possible variation from that average for each particle.
If "Tightness" is set very high, particles will emit in virtually all directions, while if it's set to 0.01, all emission goes straight up.
"Size: max min" sets the maximum and minimum start size for particles. Each particle will have a size between the two.
"Grow-" and "Shrink Rate" control the size change that occurs each keyframe. The latter is an important detail because it means that if you change the frame rate, it also changes the amount the size changes over time...
The "Group after" option can be convenient if you want to be able to quickly select and delete the whole particle system afterwards but it's very time consuming so if you have a slow computer you may want to set that to "no".
When you have the settings you want, hit the "Scatticles" button. Python now starts creating the particle system.
This may take some time...

If it seems like tS has crashed (i.e. "Not Responding") don't worry, this is normal. Just wait longer... a small tip:
Look at the "Object Tool" button. Once it's selected, the script is done.


Looks okay...



Looks reasonable but not quite as good as the PPFX version, unfortunately.
This is especially visible if you compare this animation with the PPFX one...


So why does this one not look as good as the PPFX flames?

- tS has no "layered transparency" shader. Because of this, you can not make the flames fade away over time and make the black background of the footage dissappear. You can't make the flames more transparent in general either. Notice the PPFX flames are much more transparent than these...

- For some reason (I'm guessing a quirk in the Python api) the texture animation starts at frame 0 for every particle (even if it doesn't start moving until frame 100). The result is that all the individual flames look exactly the same, except for size differences.

- PPFX has more flexible options for the motion of the particles. Here the flames just go up and shrink. In PPFX you can aply rotation and vortex-motion...
However, you could probably also get better motion using trueParticles or the old Primal Particles and maybe I could try to develop the script further to fix the problem to some extent...


It seems I highly overestimated the possibilities of combining this method with elaborate camera movement... If you move the camera too much, the image on the right is what you get. If you'd rotate it around further the flames would become even thinner.
No matter what you do, the footage will always be flat, but with PPFX, at least it always faces the camera...
woops

To tweak the look of the fire, you're best off editing the following parameters:
"Shrink Rate", "Size: max min", "Scatticle Count", "Tightness" and the size of the "emitter" object.
For example, a bigger emitter and a higher "Scatticle Count" would make the fire wider. To increase the height of the fire you should decrease the "Shrink Rate". If you increase the "Tightness" the flames will move away from the emitter more...


© 2002 Christiaan Moleman a.k.a. Ninja Dodo.