Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin
English

Overview

This tutorial covers the basic functions of the particle system, and more specifically, demonstrates how to create a fire effect.

In preparation for the tutorial, start the Sandbox Editor and open an already created level.

Table of Contents
maxLevel3
minLevel2
minlevel2

Prepare a New Particle Library

Particle Library

Most of the data in CryENGINE is handled and stored in libraries. The Particle Effect libraries are stored in the game folder, under: Game\Libs\Particles.

To create a particle effect, start by preparing a new particle library.

Opening the Database View

On the View menu, click Open View Pane, and then click DataBase View to open the DataBase View.

Adding a New Library

In the Database View, among the tabs at the top of the window, is the Particles tab. This is where all the Particle libraries are found.

Before creating a new particle, choose a library in which to place it. The best way to do this is to first create a new library.

The default library is called Level and should be active. You can create as many Particle libraries as you need. They will each be saved as a separate file in the game folder.

Select the Particles tab and click the Add Library button to create a new library.

In the New Library Name window, enter MyTutorials as the name of the library.

Adding a New Particle Effect to the Library

Click the Add New Item button to add a new particle effect. All effects will be organized in groups. As you don't have any groups yet, you have to create a new group too.

In the New Particle Name window, enter ExampleFire as the name of the Group and Fire1 as the name of the particle.

The new particle will be displayed in the particle list. Now, you're ready to work on it.

On the File menu, click Save to save the progress.

Preparing the Particle Effect

Typically, you will need to prepare the textures before making any new effects. However, this tutorial uses already finished textures and focuses on using the different texture types.

The default location to save the textures for particle use is the Game\Textures\Sprites folder.

Setting Up a Sprite Texture

Make sure that the Fire1 particle is currently selected.

In the Appearance tab (located next to the particle browser list), click the open folder icon next to the Texture text box.

Now, in Game\Textures\Sprites, select the texture called fire_ball6.dds. The path of the texture will be displayed in the Texture text box. You can check the texture when you hover the mouse pointer over the text box.

To align the particle direction to the sprite's movement, select the Orient To Velocity check box.

The next step is for the life time of the particle. To create a continuous fire, select the Continuous check box, in the Emitter section of the particle properties.

To have more than one particle displayed at any time, set the Count (of visible particles at the same time) to 10, and to have each particle rise higher, set the Particle Life Time to 3.

Keep the other values at their default (Emitter Life Time, 0; Spawn Delay, 0; Pulse Period, 0).

In the Movement section, set the Speed parameter to 3 to speed up the particle.

Placing the Particle Effect in a Level

To place the effect in the level, you need to drag the effect from the particle browser list to the level.

Note

Note that you should not drag a child particle into the level, this will not work. You need to use the parent (container) particle.

However, before you do this, activate the Select and Move tool on the Editor toolbar and turn on Follow Terrain and Snap to Objects to make the placement easier.

Now drag the Fire1 particle effect to the level.

You'll be able to see the particle continuously spawning from the emitter. However, right now, it still looks very unrealistic. The next step is to tweak more parameters in the Particle Editor and improve the fire's appearance.

Tip

You can use the Goto Selected Object button to align the camera position to be just in front of the emitter.

Save the scene again before proceeding to the next step.

Creating a More Realistic Look

To get a more fire-like look, you will need to tweak a few more parameters within the particle.

Pay special attention to the following options:

  • Spawning condition
  • Appearance
  • Movement

Tweaking How the Sprites Spawn

Go to the Emitter section on the top-left part of the parameter lists. If the Emitter Life Time is set to 0, particles will spawn infinitely, until the emitter is disabled or deleted.

Set Particle Life Time to 1 and the appearance of the particle will change.

The parameter Count controls how many particles are alive in the scene at any time. If it's set to 10, at the time that the particle number 11 is spawned, particle number 1 will disappear.

The Particle Life Time option controls the life time of each particle. If it's set to 3, particles die 3 seconds after they were spawned.

Adding Randomness

Until now, all particles have been spawned in exactly the same way, and this doesn't look natural. To add some randomness, click the + button in front of the Particle Life Time parameter to open its additional parameters.

Set the Particle Life Time Var Random to 0.4.

The particle will start to look a little more irregular now. The Var Random parameter exists for almost all the parameters. The randomness is measured from 0 to 1 (0% to 100%).

If the Particle Life Time is set as 10 (sec), and the Var Random value is set to 1, the particle life time is randomized to be between 0 to 20 sec (/- 100%). If Var Random is set to 0.3, the Particle Life Time is randomized to between 7 and 13 seconds (/- 30%).

For now, though, keep the settings as shown.

Don't forget to save the level from time to time.

The Lighting Tab

Go to the Lighting pane and add the following settings:

  • Set Diffuse Lighting to 0.
  • Set Diffuse Backlighting to 0.
  • Set Emissive Lighting to 3.
  • Set Emissive HDR Dynamic to 3.

The particle will start to glow as shown:

Diffuse Lighting is the most basic lighting parameter for sprites. It controls how much the sprite is influenced by any dynamic or ambient light in the level.

Usually, you have to set an appropriate value for this (like 0.7). However, in the case of a fire that can't actually be lit, you should set this value to 0.

Diffuse Backlighting is a simple parameter to add some brightness to the particle (often called Ambient or Incandescence in common 3D software).

By increasing this value, you can make a more translucent appearance. Conversely, by decreasing this value, you can create a more solid looking particle.

Emissive Lighting and Emissive HDR Dynamic are different from the other lighting parameters. They control emissive lights on the effect; for example, the light that is created by the particle.

Usually, these parameters are used if the particle is self illuminating (like fire, sparks, explosions). Emissive HDR Dynamic works only when HDR is turned on; that is, Config Spec is set as high or highest.

Tweaking the Sprite Alpha Curve

Now, change the lifespan curve to add a natural transparent look to the fire. Open the additional parameters of the Alpha parameter in the Appearance section.

A particle's Alpha value controls how transparent it is. Click and drag the yellow square in Var Particle Life to create a key point (red point).

Double-click the top-left edge of the green line to create a second point and drag this to the bottom of the graph.

Double-click the top-right edge of the curve to create a third point and drag this also to the bottom of the graph.

The Var Particle Life curve controls the Alpha value of the sprite, independent of the texture's Alpha. Longitudinal represents the Alpha value, transversal, the Particle Life Time.

In this case, the particle will be displayed with 0 Alpha value (invisible), then increase to 100% Alpha value at 25% of its life time, and then finally fade out and disappear at the end of its life time.

Tip

You can add or delete more key points by double-clicking them, and also move key points by dragging them in both dimensions.

Tweaking the Sprite Scaling and Stretch Parameters

Go to the Size pane and set the Size parameter to 1.3, and then open the additional parameters and set the Size Var Random to 0.4.

Adjust the Size Var Particle Life curve to match the graph below:

Next, add a little stretch effect to the sprite. Set Stretch to 0.2, and set the Stretch Var Particle Life curve as shown below:

The Stretch option will stretch the sprite. A default value of 0 means that the sprite has not been stretched at all; for example, a perfect square shape. In this case, the particle is stretched up to 0.2 at the start of its life and back to a perfect square shape at the end of its life.

Now, the particle will look more like real fire, but with some more tweaking, you can further better it.

Tweaking the Movement and Air Resistance of the Particle

Movement of particles is also very important to add realism to the effect. In this section, you will tweak the particle movement parameters.

Access the Movement tab and set the Speed to 3 and Var Random to 0.4. You'll find the Var Random hidden behind the little + button. The Speed value controls the speed of the particle. It controls the speed along the direction of the Emit Angle, which you will tweak later.

Tip

Remember that adding a random value to parameters is an effective way to get a more realistic effect, in most cases.

Air Resistance simulates the denseness of air or any medium where the particle is situated. In a dense medium like water, the energy of motion is consumed faster because water has a higher resistance than air. The opposite is true in space, as particles never loose their velocity.

Set the Air Resistance to 0.2 and the Air Resistance Var Random to 0.4.

Info
titleNote

Particles with air resistance are also affected by the environmental forces in the level such as wind, turbulence, or global wind. Thus, if you set high values for air resistance, the particles will be strongly affected by the wind forces in the level, maybe so much that you won't see any particles. To avoid this, first try assigning low values (like 0) to the air resistance, and then check the effect.

Tweaking the Angles Tab

Go to the Angles section and tweak some more options.

Set Emit Angle to 20 and Emit Angle Var Random to 1.

The particle's default direction is exactly along the z-axis of the emitter. The changes above mean that the particle emits at a 20 degree angle around the z-axis, and also gets a random direction within -20 to 20 degrees.

If you don't set a Random value other than 0, the particles will always get an exact -20 or 20 degrees direction from the z-axis; consequently, the whole shape of the effect will look like an umbrella turned upside down.

Tweaking the Rotation Tab

Set the Random Angles and Random Rotation Rate as shown below:

These parameters control the rotation of each sprite. The left column refers to the x-axis, the center column to the y-axis, and the right column to the z-axis.

In this case, the particle has a possible 180 degree rotation value on the z-axis when they spawn, and a maximum of 30 degrees random rotation on the z-axis while they live.

For sprite particles like this fire, the x and y axes are not affected at all, because sprites are 2D objects – they have no x- or y-axis. The particle system also supports imported 3D objects, which can be used as particles where all 3 axes are supported.

Soft Particles

When you get closer to the effect and check the area where the particle is intersecting with the terrain surface, you'll be able to see a significant edge at the bottom of the sprite.

To avoid this edge, access the Appearance pane and select the Soft Particle check box.

The edge will be removed and the fire will look even more realistic than before.

You now know how to create a simple 2D particle and how to tweak its basic parameters.

 

 

Excerpt
hiddentrue
Learn how to create a simple particle effect by using the Particle tab of the DataBase View.
Chinese

创建简单粒子特效

本教程包含粒子系统的基本功能,更确切地说,是说明如何创建火焰特效。

为开始本教程,请启动“Sandbox 编辑器”并打开已创建的关卡。

准备新粒子库

粒子库

CryENGINE 中的多数数据都在粒子库中处理和保存。“粒子特效”库保存在 Game\Libs\Particles 之下的游戏文件夹中。

若要创建粒子特效,请先准备新粒子库。

打开数据库视图

在*视图*菜单中,单击*打开视图窗格*,再单击*数据库视图*以打开数据库视图。

 

添加新库

进入数据库视图,在窗口顶部的选项卡中,有“粒子”选项卡。在此位置可以找到所有“粒子”库。

 

创建新粒子之前,请选择可以放置该粒子的库。最佳方法是先创建一个新库。

默认库名为“关卡”且应激活该关卡。您可以创建所需的任意数量的粒子库。该粒子库将作为单独的文件保存于游戏文件夹中。

选择*粒子*选项卡并单击*添加库*按钮以创建新库。

 

在*新库名称*窗口中,输入 MyTutorials 作为该库的名称。

 

添加新粒子特效至库

单击*添加新道具*按钮以添加新粒子特效。所有特效都将组织在组中。由于尚未创建任何组,您应先创建一个新组。

 

在*新粒子名称*窗口,输入 ExampleFire 作为组的名称,输入 Fire1 作为粒子的名称。

 

新粒子将显示在粒子列表中。现在已准备就绪,可以运行新粒子。

在*文件*菜单中,单击*保存*以保存该进度。

 

准备粒子特效

通常,制作任意特效之前您将需要准备纹理。但是,本教程使用已完成后的纹理并集中探讨使用不同的纹理类型。

Game\Textures\Sprites 文件夹是保存粒子所使用纹理的默认位置。

设置片画面纹理

确保当前已选定火焰 1 粒子。

在*外观*选项卡(位于粒子浏览器列表旁边)中,单击“纹理”文本框旁边的*打开文件夹*图标。

 

现在,在 Game\Textures\Sprites 中,选中名为 fire_ball6.dds 的纹理。该纹理的路径将显示在“纹理”文本框中,鼠标悬停在文本框上时,可以对纹理进行检查。

若要将粒子方向与片画面的移动方向保持一致,请选中*适应速率*复选框。

 

下一步是设置粒子的生命周期。若要创建连续的火焰,请选中粒子属性*发射器*区段的*连续*复选框。

 

若要在任意时间内显示多个粒子,请将*计数*(同时显示的可见粒子的数量)设为 10,若要每个粒子升得更高,请将*粒子生命周期*设为 3。其他数值则保持默认值(粒子发射器生命周期*为 *0再生延迟*为 *0脉冲周期*为 *0)。

 

在移动区段,设置*速度*参数为 3 以加速粒子。

 

在关卡中放置粒子特效

若要在关卡中放置粒子特效,需要从粒子浏览器列表中将该特效拖动至关卡。但是,在执行此操作之前,请在编辑器工具栏中激活*选择和移动*工具并打开*跟踪地形*和*对齐对象*以便更容易放置。

 

现在拖动*火焰 1* 粒子特效至关卡。

 

您将能够看到连续的粒子从粒子发射器中再生。但是在此刻,该过程看起来仍非常不真实。下一步要做的是在“粒子编辑器”中对更多的参数进行微调并改善火焰的外观。

 

 Note 使用“转到所选对象”按钮以将摄像机位置调整至粒子发射器的前面。

 

 

进行下个步骤前请再次保存场景。

创建更真实的外观

若要使火焰看起来更真实,将需要对粒子之内的更多的参数进行微调。

特别要注意以下选项:

对片画面如何再生进行微调

进入参数列表左上角的*粒子发射器*区段。若*粒子发射器生命周期*设为 0,在禁用或删除该粒子发射器之前,粒子将无限再生。

将*粒子发射器生命周期*设置为 1 时,粒子的外观将会改变。

参数“计数”控制任意时间内场景中活着的粒子个数。若将该计数设置为 10,第 11 个粒子再生时,第 1 个粒子将会消失。

粒子生命周期选项控制每个粒子的生命周期。若将该选项设置为 3,粒子再生后 3 秒将死亡。

添加随机性

到目前为止,所有粒子都以完全相同的方式再生,但该过程看起来并不自然。若要添加随机性,请单击*粒子生命周期*参数前面的 + 按钮以打开其中的其他参数。

将*粒子生命周期 Var Random* 设置为 0.4

 

现在的粒子看起来开始稍微不规律。几乎所有参数都存在 Var Random 参数。用 0 至 1(0% 至 100%)的数值来衡量随机性。

若粒子生命周期设置为 10(秒),Var Random 数值设置为 1,粒子生命周期将在 0 至 20 秒 (/- 100%) 内随机形成。若 Var Random 数值设置为 0.3,粒子生命周期将在 7 至 13 秒 (/- 30%) 内随机形成。

但是现在,暂时保持如下所示的设置。

不要忘记时不时地保存关卡。

光照标签

转到光照窗格并添加以下设置:

粒子将开始如下所示的发光:

 

漫反射光照是片画面最基本的参数。它控制着关卡中任意动态或环境光照对片画面的影响程度。通常,您需为其设置适当的数值(如 0.7)。但是在火焰实际上未能够被点燃的情况下,应该将该数值设置为 0。漫反射背光是一个可以添加光度至粒子(在普通的 3D 软件中通常被称为 环境白炽光 )的简单参数。通过增加该数值,可以使其变成更透明的粒子。相反地,通过减小该数值,可以创建看起来更立体的粒子。

漫反射光照和放射性 HDR 动态不同于其他光照参数。它们控制效果的放射性光照;例如,通过粒子创建的光照。通常,若粒子能够自行发光(如火焰、火花、爆炸),可以使用这些参数。放射性 HDR 动态仅在 HDR 打开时运行;也就是说,将配置规格设置为高规格或最高规格。

对片画面 Alpha 曲线进行微调

现在,更改寿命曲线以添加自然透明的外观至火焰。打开*外观*区段的 Alpha 参数的其他参数。粒子的 Alpha 数值控制其透明度。单击并拖曳 *Var 粒子寿命*中的黄色方块以创建关键点(红点)。

双击绿线的左上角边缘以创建第二个点并将其拖动至图表底部。

双击曲线的右上角边缘以创建第三个点并也将其拖动至图表底部。

 

Var 粒子寿命曲线控制片画面的 Alpha 数值,不依赖于纹理的 Alpha 数值。纵向表示 Alpha 数值,横向表示粒子生命周期。

这种情况下,粒子将以 0 Alpha 数值(不可见)显示,再在其生命周期的 25% 时将 Alpha 数值增加至 100%。接着最终淡出并在其生命周期结束时消失。

 

 Note 通过双击关键点可以添加或删除更多的关键点,通过拖动关键点的大小可以移动关键点。

 

对片画面缩放和拉伸参数进行微调

进入*大小*窗格并将*尺寸*参数设置为 1.3,再打开其他参数并将*尺寸 Var Random* 设置为 0.4

调整*尺寸 Var 粒子生命周期*曲线以与以下图表相匹配:

 

接下来,添加小伸展特效至片画面。将*伸展*设置为 0.2 并按照如下所示的步骤对*伸展 Var 粒子生命周期*进行设置:

 

伸展选项将对片画面进行拉伸。0 默认数值表示片画面未拉伸;例如,完全的正方形,这种情况下,在粒子生命周期开始时其拉伸数值增加至 0.2,并在其生命周期结束时还原为完全的正方形。

现在,粒子看起来会更像真正的火焰,然而进行一些更多的微调后,效果将更加逼真。

对粒子的移动和空气阻力进行微调

若要让特效更加逼真,粒子的移动至关重要。在本节中,将对粒子移动参数进行微调。

进入*移动*标签并将*速度*设置为 3,将 Var Random 设置为 0.4。您将发现 Var Random 隐藏于 "little +" 按钮的后面。速度数值控制粒子的速度。也控制沿着稍后将对其进行微调的发射角度方向的速度。

 

 Note 请记住在多数情况下,添加随机值至参数是获得更真实特效的有效途径。

 

空气阻力可以模拟空气的密集程度或粒子所处位置的任意媒介。在诸如水的重介质中,因水比空气有更高的阻力,所以其动能消耗更快。与其相反的是在太空中,粒子从不会降低速率。

将*空气阻力*设置为 0.2 并将*空气阻力 Var Random* 设置为 0.4

 

 

 Note 具有空气阻力的粒子也会受关卡中诸如风、扰动或全局风等环境因素的影响。因此,若设置较高的空气阻力数值,粒子将受到关卡中风力的强烈影响,该影响可能大到看不见任何粒子。若要避免此种情况发生,首先尝试设定较低的空气阻力数值(如 0),再检查该特效。

 

对角度标签进行微调

转到*角度*区段以对更多选项进行微调。

将*发射角度*设置为 20,并将*发射角度 Var Random* 设置为 1

 

粒子的默认方向为精确沿着粒子发射器的 z-轴方向。以上更改表示粒子以与 z-轴成 20 度角的方向发射,或者以 -20 至 20 度\以内的随机方向发射。若不将随机数值设置为除 0 以外的数值,那么粒子将总是以与 z-轴精确成 -20 至 20 度的方向发射;因此,该特效的整体形状如同倒转过来的雨伞。

对旋转标签进行微调

按照如下所示对*随机角度*和*随机旋转速率*进行设置:

 

这些参数控制每个片画面的旋转。左列指的是 x-轴,中间列是指的是 y-轴,右列指的是 z-轴。

这种情况下,粒子再生时,可以在 z-轴上达到 180 度旋转值,粒子存活时,可以在 z-轴上最大可达 30 度的随机旋转。

对于诸如这种火焰的片画面粒子,由于片画面是 2D 对象(它没有 x 轴或 y 轴),所以 x 轴和 y 轴一点都不会受到影响。粒子系统也支持输入 3D 对象,该对象可用作 3 个轴都支持的粒子。

软粒子

靠近该特效并检查粒子与地形表面交叉的区域时,您将能够看到片画面底部明显的边缘。

 

若要避免该边缘的出现,请进入*外观*窗格并选中*软粒子*复选框。

 

将删除该边缘,火焰看起来将会比之前更加逼真。

 

现在您了解如何创建简单 2D 粒子以及如何对其基本参数进行微调。