Creating A Fire Particle

From Valve Developer Community
Jump to: navigation, search
Underlinked - Logo.png
This article needs more Wikipedia icon links to other articles to help Wikipedia icon integrate it into the encyclopedia. Please help improve this article by adding links Wikipedia icon that are relevant to the context within the existing text.
January 2024
English (en)Русский (ru)中文 (zh)Translate (Translate)

Overview

The aim of this tutorial is to give you a insight of fire creation in particles. This article will not explain the complete ins and outs of particle creation, as there is already documentation on it here. You will learn to create a fire particle like this:

Fire particle.jpg

Properties

Make a new particle system, and name it. First we need to determine the main properies of the particle. In the main tab of the particle, select the system properties tab.

Change the max_particles to 40. Now select the material line, and click the ... button to load the material browser and search for a appropriate fire material. For example particle\fire_particle_4\fire_particle_4.vmt.

Set the bounding_box_min to -512 -512 -512 and the bounding_box_max to 512 512 512. Change the color field to an orange color. We're done on the system properties tab now. Now in the main tab select the render tab. Right-click on the tab and select the add option.

Renderer

All particles need some kind of renderer to actually do anything. So we're going to add a render_animated_sprites renderer. Inside it change the animation_rate number to 0.9 and set the animation_fit_lifetime to 1. We're done with the renderer now. next click on the operator tab.

Operators

With the operators we will determine things like movement type, alpha fade in/out, lifespan etc. Operators do the work after the particle is initialized, rather then the initializers job of setting the starting state.

In the operator tab, add a movement_basic. This will determine the basic movement that the particle will do. In the movement_basic, we only need to do one thing here. In the gravity field, set it to 0 0 50. Gravity gives the fire a direction to emit, 0 0 50 will make the fire go up like it would in real life, where as setting it to 0 0 -50, it will make it emit downwards.

Next add a Oscillate_Vector'. This operator will help us create a wavy fire effect, to keep the fire being wavy and bumpy like a real fire, rather then a static looking fire. Here's a example of its function:

Sin wave.jpg

In the Oscillate_Vector under the oscillation rate min change the numbers to -0.400000006 -0.400000006 0 and under oscillation rate max change the numbers to 0.400000006 0.400000006 0. Change the oscillation frequency min numbers to 0.5 0.5 1 and the oscillation frequency max numbers to 1 1 0.

We're done with this operator now.

Next add a Lifespan Decay. This will delete the particle when it's given lifespan expires, we need to do this to make our alpha fade work, which we'll add. We don't need to add anything to this operator, it just needs to be there for it to function correctly.

Now we'll add the Alpha Fade. Add a Alpha_Fade_In_Random. Inside it change the fade in time min to 0.3000000119 and the fade in time max to 0.400000006. Now add a Alpha_Fade_Out_Random and change the fade out time min to 0.349999994 and fade out time max to 0.5.

We're done with the operators now.

Initializers

We need to add some initializers. These will determine the particles starting state.

Add a Radius Random, set the radius_min to 3, and the radius_max to 10. This emits the particle within this radius, if you wanted a much larger fire, then for instance you would set the max to 50.

Next add a Alpha Random. Set the alpha_min to 120 and the alpha_max to 200.

Now add a Rotation Random. Nothing is needed to add inside here.

Next add a Position Within Sphere Random. Set the distance_bias to 1 1 0 and the speed_max to 10. Set the speed_in_local_coordinate_system_min and speed_in_local_coordinate_system_max both to 0 0 5. This tells the particle to emit inside this sphere with a certain speed.

Add a Lifetime Random and set it's lifetime_max to 1.25 and lifetime_min to 1. This sets each particle in the fires life to random in these numbers.

Add a Sequence Random and set the sequence_max/min to 2.

Now add a Position Modify Offset Random and set the offset in local space 0/1 to 1.

The Initializing is now complete.

Emitters

Now lastly we need to add the main function that brings the particle to life. Emitters are what do this.

Add a emit_continuously and the fire particle should come to life in the preview box. Set the emission_rate to 50.

Conclusion

The particle is now finished, you should have a small fire particle built. You can

learn from the way you built this to edit from it to make other particles like a

waterfall.