# Blender 3D/Faire du feu

Ce tutoriel constitue une introduction au système de particules de Blender en proposant la création simple de feu et de fumée. Ce n'est pas la seule façon de créer de tels effets, et un expert de Blender pourra probablement le faire de façon plus économique et efficace. C'est un effet simple qui a pour but de vous permettre d'apprendre certains aspect de l'animation basique des particules.

## Prérequis

Pour pouvoir réaliser ce tutoriel, vous devez être capable de :
* sélectionner des objets et le manipuler dans l'espace en 3D de blender,
* sélectionner des option et modifier leurs valeurs numériques,
* créer et manipuler un simple maillage (mesh) et l'éclairer avec des lumières,
* ajuster la caméra,
* configurer les paramètres de rendu et d'animation (render and animation settings).

## Régler l'espace de travail

Démarrez avec la configuration par défaut de Blender et configurez votre vue comme un affichage à deux panneaux de la fenêtre de vue 3D principale et un panneau plus petit en dessous pour la fenêtre des boutons.
* Create a mesh of a 3-division icosphere in the center of the 3d window. This icosphere will be our first "particle emitter".
* Add a couple of area lamps at very low energy (about 0.075). Arrange the lamps on either side of the icosphere.
* Press the F10 key to display the render buttons window.
* Set up the render options to give you a quick, low-resolution render as follows:
** set OSA, SHADOW, ENV MAP, and RAY off (not highlighted)
** set image size to 50%
* Now, select the icosphere with RMB. Press F5 to bring up the material buttons. Beginning with Version 2.42, the Halo selection is on the Links and Pipeline tab. Under Links and Pipeline, Link to Object, click "Add New". Under Links and Pipeline, Render Pipeline, click "Halo".
* Press the F12 key to make a quick render, proving that you can see your icosphere centered in the view. If not, adjust the camera direction so that it points right at the icosphere as follows:
** In the view window, press KP1 to toggle to front view.
** In the view window, click on the camera to highlight and select it.
** In the view window, press Alt + R to reset camera rotation.
** In the view window, press N to edit the camera properties.
** Set LocX and LocY to 0 so the camera is centered above the icosphere.
** You can also set the distance from our icosphere with LocZ. a value of 15 or above (depending on the size of your icosphere) should be a good starting point.
** Press KP0 to return to camera view mode and press F12 to repeat the quick render. The icosphere should now be dead centre in the image.
(Note - you can also use the rotate widget to point the camera, but I'll leave that for a different tutorial).
(Beginner note: I had YaFray set as my Render Engine and could not see it. Switching back to Blender Internal allowed me to see it again. (i've noticed that YaFray doesn't recognize halo effects for some reason. i have the same trouble when i try to get it to render star effects too.)
(Note - you can also create a TrackTo Constraint for the camera, so that (almost) whatever you do to the camera, the icosphere will be centered. Do as follows: Select the camera, then the icosphere. Press Ctrl+T and choose TrackTo Constraint. Move the camera to test it out.)
You should now have an icosphere with halo effects at each vertex that looks like this:

## Making a Smoke Plume

Smoke is easiest to model, and learning it first will give you some insight into the particle system. Begin by making a simple particle emission that you can see in the view window as follows:
Simple Particle Emission
* RMB on the icosphere to select it
* Press F7 to display Object buttons
* Click the "Physics" Tab and in the second pane labeled "particles" hit "NEW"
* The Particles and Particle Motion tabs are displayed (** It is possible to split the panels so that you can see both at once. LMB on either the Particle or Particle Motion label and drag to the side. The panels will separate. ** This is an optional step and not necessary to complete the tutorial)
Before going further, Press the F12 key to make a quick render of the current state of the object. What you should see at this point is nothing, or a small white sphere. Your icosphere appears to have vanished, or gotten smaller. This is because you have now declared all its vertices to be nothing more than particle emitters. Also, the particles have no visible attributes at this point, so there is nothing for the renderer to see. (NOTE: Using Version 2.42, following these instructions produces a small halo object at the center of the sphere)
With the icosphere selected, make the following two changes to the particle system:
* LMB on the Particles tab
* Click on the Static button.
* Click on the "Particle motion" tab.
* Change the value of Norm from 0.000 to 0.100 (Hint: click ten times on the right arrow symbol in the box).
Notice that the view window now shows a stream of particles (You MUST be in OBJECT MODE to see particles) jetting out from every vertex in the icosphere, making it look like a star. Use MMB to rotate the view so that you can appreciate the symmetry of the particle stream. Press KP 1 to return to front view, or KP 7 to return to top view.
Press F12 to make a quick render of the changed object (see image).
You should see something that looks like a white explosion. You may have to reposition the camera to see the entire thing. Each particle is rendered as a glowing ball, but the particles are fairly large at this point, and you cannot see them as individual particles.
Use the following procedure to make the particles smaller. At this time, you will also give them a color and some transparency to make them look a little more like puffs of smoke.
Smoke Particle Material
* In the buttons window, press F5 to display the shading window.
* Click on the material buttons icon (red globe) to display the material.
* Change the name of the material to MA:smoke
The default colour is light grey, which looks a litte bright for smoke. We'll adjust some of the particle attributes next:
Smoke Particle Attributes
* Click on the Shaders tab to display the shaders panel.
* Set the value of Hard to 15
* Set the Halo size to 0.300
* In the Material tab, set the value of A (Alpha) to 0.80.
* In the Material tab, set the RGB color to 0.56, 0.55, and 0.50 respectively.
The preview sample might now look as if it has vanished. However, press F12 for a quick render and you will see that the former white explosion has now become a star of smoke puffs. This pattern is still too organized and regular to look much like smoke, but you are getting there (see image to right).
To model the smoke, press F7 to display the Object buttons in the buttons window again. When you first set up the smoke model, you set the particle emission as "Static". However, you want your smoke to build and to move in the final model, so the next step is to randomize the particles and make them move like drifting smoke.
First, let's look at the default animation of the smoke particles:
* Click on the Static button. Notice that the star of particles vanishes, and the mesh is now drawn only as vertices - no polygons.
* Ensure that the icosphere object is still selected (highlighted pink).
* Pres KP0 to go to camera view.
* Put the cursor In the 3D View window and press Alt-A. Notice that each vertex now emits particles in the same star pattern.
Before you proceed, take a quick look at a rendering of the animation as follows:
* In the buttons window, Press F10 to display the Scene buttons.
* In the Format panel, click on the PC button.
* In the Format panel, choose AVI JPEG as the file format.
* In the Render panel, set the image size to 25% (small, for a fast render).
* In the Anim panel, set the value of End to 100, to create a 100-frame animation lasting about four seconds.
* In the Output panel, set the filename to /tmp/smoketest, or any other save location that you prefer.
* Press the Anim button to begin rendering.
* When all 100 frames are rendered, press the Play button to review the animation.
What you should see is a cloud of smoke puffs starting from the location of the icosphere (which is invisible) and radiating outwards. it looks a little like an explosion of smoke, but is still too organized and regular to appear as smoke.
Now that you have invested some time in creating the animation, it might be worth saving the .blend file. After you have saved the file as smoke1, you can experiment with making the particles look more like smoke. Go back to the section titled:
Smoke Particle Attributes and experiment with the values of Halo Size, Hardness, Alpha and the color of the smoke. You do not need to create a new material, you only need to change the existing RGB and A values.
For example, a Halo Size of 0.900, an Alpha value of 0.100, and a hardness value of 1.0 will produce a denser, more realistic smoke. After you finish experimenting with the values, use these values and save the file again.
Randomizing the Smoke Particles
If you are modelling smoke from a fire, you want the particle system to move randomly, but to drift in a predictable direction as if moved by a breeze or simply billowing up from a source of fire.
Blender's particle interaction options provide some sophisticated ways to control particles and make them interact with the environment. However, for this tutorial you will simply specify some variables that randomize the particles and move them in the desired direction. You can learn about particle interaction later.
To set up the model, first revert to a static view of the particles, as follows:
* In the buttons window, press F7 to display the object buttons.
* In the Particles panel, press the Static button. Notice that the 3D view changes to the particle star.
* Press KP1 to display the front view.
* In the Particle Motion panel, find the group of variables labeled "Force" and change them as follows:
** Change the value of X to 0.500. Notice how the particles are now skewed to the right.
** Change the value of Z to 0.500. Notice how the particles are now skewed upward.
* In the Particle Motion panel, change the value of RLife to 0.200. Notice that the pattern of the particles becomes more disorganized.
* In the Particle Motion panel, change Random to 0.02 to give the starting speed a slight variation. The pattern becomes even more disorganized.
* Press KP0 to return to camera view.
What was formerly an organized star of particles has now become a random mass. You can now preview the animation as follows:
* In the Particles panel, click on the Static button to revert to animated particles.
* In the 3D view window, press Alt-A.
The cloud of particles now drifts randomly to the right. Preview the animation as follows:
* In the buttons window, press F10 to display the Scene buttons.
* Press the Anim button to start the animation
You should now see a much more realistic drifting cloud of smoke. However, one of the problems with it is that you can still see a pattern of particle emission from the vertices of the object. One way to make this less visible is to reduce the scale of the object, squeezing the vertices together, although that will make the source of the smoke appear very dense. Using the mesh edit decimator option to reduce the number of vertices will make it less dense, as will ramping up the Alpha value of the smoke halo.
The *BEST* way to truly randomize particle emission is to select the emitter and go into edit mode (TAB key), select ALL vertices of the emitter ("A" key), go to the Editing menu (F9), and then to the Mesh Tool Subpanel. There, press the HASH button, then leave edit mode (TAB key). You will now see particles emit in a TRULY random fashion, something that has been overlooked by nearly every other tutorial available.
There are many other ways to make the smoke look more natural, such as by animating the value of Alpha or color to make the smoke seem as if it is getting thicker. You can use several emittors to send out particles of smoke of different color and density, with different rates of emission. By animating emittors, you can create a very realistic effect - or even a moving cloud system.
However, for this tutorial, we will keep it simple, and move on to the next step of animating simple flames and sparks to mix in with the smoke.
At this point, you can save the file, and then experiment with changing the values of the particle system to see how it affects the smoke. The following image is using Halo size 2.0, 2000 particles, Alpha 0.5 and the "Hash" randomizing technique described above.

## Making Fire

Fire makes smoke, so save the smoke .blend file for later. Now, press F7. Under the particle motion tab, set X and Z to 0.00. Then, press F5 into the materials tab. What colours the fire are, you choose. Right now I'm going to go with orange and yellow. Change the material to R=1 G=0.273 B=0. Press F6 to go to the texture panel. Click Add New and set Texture Type to Noise. Then, go back to the material buttons and you will see an orange puff with purple in it. Purple? In a fire. That won't do, so go to the Map To panel, and change R to 1, G to 1, and B to 0. Now, the big puff is orange with yellow. That's better.
Go back to the physics tab (F7) and turn static back on. If you take a quick render, you will see the equivalent of a burning gas giant called our sun. Set Z to o.50, and Norm to 0.010. Now take a render. This looks like fire. Now go to the render settings (F10) and set the output folder to whatever you want by clicking the little folder beside it. Save the fire .blend file. Press Anim to save the animation.
Bingo presto, you've got a fire.