Particle Effects Tutorial 1
Welcome to the wonderful world of particles! If you've played the game AT ALL then I'm sure you know something about what can be done with them. The jets from the spaceship you arrive in are particles. The steam from that hose right at the beginning is a particle effect. Blood, clouds of dust, fireballs, ricochets, rain, explosions, waterfalls, tornadoes--these can all be done with particle effects. And thanks to the particle editor (which I'll get to in a moment) it's amazingly easy since there's no code that needs to be written.
1. What is a Particle Effect, exactly?
A particle is a small, one-sided square made out of two polygons. If you turn on r_showtris and look at a particle effect, you'll see a whole bunch of little squares like this one:
Because they are on-sided, if you look behind them you can't see them at all. This is important to remember with certain settings. Particles have a "look-at" command, so that they always face the view (or a certain axis if you change it later). This makes it easier on the engine because it only has to render two polygons per particle, wheras if they were viewable from behind, it would require at least four. Six polygons per particle if you wanted to see them from any direction. I know it doesn't seem like much, but when you're dealing with particles numbering in the thousands, it starts to add up. Think about this: most character models in the game aren't much higher than 5,000 polygons. The largest number of particles you can have through their editor for one stage
of an effect is 4,096. That's 8,192 polygons. If each particle were two-sided, it would be 16,384 polygons. Look-at controllers are our friends
On a side note related to look-at controllers: Half-Life 2 uses a similar look-at technique for all its vegetation, which helps since their engine never has to render an actual blade of grass; their bushes are on flat planes that rotate to match the view.
Through the particle Editor you can change the orientation of the look-at controller so that it doesn't point directly at the camera. You can align it to the X, Y, and Z axis, the player's View, or to the direction the particle is moving (called "Aimed" in the editor).
If you set it to Z, you won't be able to see the particles from below. If you set it to X, you won't be able to see them from behind, etc.
Another thing to note, is that when particles get near eachother their color values add together. If you have 30 yellow particles right on top of eachother, you'll get a white blob. This is great for explosions and light effects, but really doesn't seem to fit with dust clouds.
2. Alright Already! How I do this?
First thing's first. Launch Doom in windowed mode. If it comes up fullscreen push Alt + Enter
to get it windowed. I suggest a smaller resolution like 640x480, but as long as you can see everything it's fine.
Pull down the console (Ctrl + Alt + ~
) and type 'editParticles
Now, this takes a while for anything to happen, so please be patient. Go get something to drink, or read ahead, or engage in an exciting thumb-twiddling competition with your cat. Anything other that staring at it waiting for it to load
After 40-60 seconds or so, you should get a screen like this:
This looks a little daunting, perhaps a bit complex. Most of it is actually pretty simple, and I'll take you through some pieces of thing step by step in an attempt to make you more comfortable with it. The things I skip will be covered in later tutorials.
3. The Editor
Starting at the top:
The green highlighted area shows the particle you're currently working on. The dropdown box shows the name of the particle (which can be anything not already named as a particle) and will let you select any other particle to work on. The text below that shows where the file itself is located. You can see in this example we're working on "Admin_hall_smk_cone" which is located in "particles/alphalabs1.prt"
The yellow highlighted area is pretty self-explanatory, but just in case: Click on New...
to create a new particle. It will first ask you for the name of the particle, which will be displayed in the dropdown. It will also ask if you want to copy the current particle into the new one (a good way to work on Id's particles), then it'll ask you where to save it and for a filename for the .prt file.
On the left you have the Stages
section. The box where it says "stage 0" is where you can select different stages of your effect. Whichever stage you have selected will be highlighted blue, and any change you make to any setting will affect that stage only
The gold buttons above the stage selection box will (from left to right) Create a new Stage, Delete the selected Stage, Hide the selected stage (any effects on that stage will not show up when you test the effect), and Show the selected stage if it's Hidden.
The yellow box indicates the material currently applied to the effect on the current stage. In order to craft your own 100% original particle effect, you will have to make your own images for the effect and write a material file for them. This will be included in the next installment.
To the right of that box is a button that merely says "...
Click this box and a material selection dialogue box will appear, allowing you to change the material without typing it in the little box.
The portion that is highlighted Light Blue controls fading effects for your particle. Fade in controls how much each particle will have to fade in order to become fully apparent when it spawns. Setting this at 0 means all the particles will spawn without any extra transparency and won't fade at all. Likewise, setting it to 1 will make them completely invisible the instant they spawn and all the particles will fade in from that.
Bunching is important. It controls how many particles are spawned at a time. Setting this to 0 will make all of the particles (from 0 to 4096, remember?) spawn at once, fly away and disappear. The closer to 1 you get, the fewer come out at one time. At 1, you will have a continuous effect (if you keep looping it).
Count controls the number of particles. It can range from 0 to 4,096 and will drastically affect any particle effect you ever make. One reason for this, is the additive property particles have. If you put them close together they add together. Dark things get darker, light things get lighter. Dark greys, indigoes, and blacks will become absolutely black. Yellows, oranges and light greens will become absolutely white. dark oranges will become red. And so on. If you want to make smoke, you will need to keep this down
On the top we have Gravity. A negative setting will pull your partices upward, a positive setting pulls them downward. The greater the number, the stronger the pull.
Below and to the left we have Distribution
This will influence the behavior of your particles to a great extent. By defining a shape, you define that shape around the particle emitter (what you put in your map). The particle emitter will be at the center of this shape, unless you set Offset to something other than 0 0 0.
will define a Cube with the dimensions you set. The particles will spawn on the cube
, not in the cube.
defines a cylinder with the dimensions you set. The particles spawn on the surface the perimeter of the cylinder
defines a sphere with the dimensions you set. The particles will spawn on the surface of the sphere
I cannot stress enough that the particles do not
spawn within the shape at all. They spawn on the surface of the shape.
will define the radius of a circle around your shape for the particles. This only works if you're using Outward
for your direction instead of Cone. Here's an example of the Ring in action.
Ring is set to 0
Ring is set to 5
The ring is a way of expanding your sphere without defining a larger radius. Quite often you can make it look like particles are spawning within your shape by using the ring properly.
After you've defined your shape, you can set the Direction and Orientation of your effect.
If you select Cone
(in light green) then you will have to define an Angle for it. This can be anything from 0 to 360. The smaller the angle, the smaller and tighter the cone will be. The larger the angle, the larger the cone.
If you select Outward
(in light green) instead, then Angle becomes Upward Bias
. The larger the number the more the particles will try to push themselves upward.
To the right of that, in light blue, with have the orientation. This is what I was talking about with the look-at controller. By default it's set to View. If you set it to Aimed you'll still be able to see the particles all the time, though they'll look stretched (which is cool for some stuff). Setting X Y or Z will make the particles only viewable from one side.
Initial Angle (at the bottom in green) defines the angle the particles come out of the emitter at.
Here, in red is the Speed. There are two values, as you can see. The speed of your particles will start at the first number, and end at the second. By using a positive for the first and a negative for the second, your particles will turn around. If you want them all moving at the same speed, set both to the same number. Speeds can be negative.
In green you have the Size. Again, two values, and your particles will spawn as large as the first value, and die at the second value.
In yellow you have Rotation. Same as above with the two numbers. Rotations can be negative as well. I've achieved better results leaving this setting alone and adding some rotation into my material file instead, though.
In blue is the Aspect. By increasing one value over the other, you can stretch your particles. Take it too far and you get a bunch of lines.
In the lower-left hand corner of the editor are some buttons under the heading DOOM Stuff. The only two that you need to worry about right are the T
and Switch to DOOM
Pressing the T
will spawn the current particle you're working on at the player's feet as a testmodel. For playing around with particles I reccomend the map 'testmaps/test_box'
clicking Switch to DOOM will do just that. If you ran it in a window like I told you to, though, you can just click on the DOOM window. Plus, you'll see all the changes you make updated as you make them without having to switch.
That should give you enough to get started making your own particles! I plan to have another update soon (I'm hoping before Thursday) which will go in-depth on more specific uses for different settings, and may even include the use of vertex fragment programs. Stay tuned and happy tweaking!