Particle effects

From HEWIKI
(Redirected from Particle effect)
Jump to: navigation, search

Contents

See also: Creating particle effects for a beginner-level tutorial.

The particle system can be used to create animated effects to give interesting detail to areas, and lend special effects to game systems. Types of applications may be spell effects, realistic fire, rain, and leaves falling from a tree.

A particle system is made up of two main components:

The Properties panel allows you to modify the properties for each separately, depending whether you are dealing with particles or emitters.

Emitters

An emitter is an entity in HeroEngine that has one purpose: to emit things. Emitters always emit particles, which could be as tiny as a grain of sand, as large as a building, or portray many other effects, from lightning bolts to waterfalls.

Particles

Particles are a generic term for things emitted by emitters. They behave in just about any manner, dictated by the properties (explained below) that give them size, color, movement, velocity and many other attributes.

This page explains many properties and methods for using particle effects. However, the best way to learn particles is simply to use them. Some behaviors are hard to describe, illustrate and, most of all, understand from a documentation standpoint without having an advanced math degree and one heck of an imagination.

Editing particle effects

See also: Copying particle effects

Properties of a particle effect can be changed via the Properties panel. When properly selected, three tabs will appear at the top of the properties panel, for:

If the tabs are not appearing, ensure that the "Selector" HeroBladeTransformSelect.png is active, and/or click on the instance number of the emitter in the Assets panel.

Also note that any changes to the spec properties (second and third tabs) will affect all instances that use that spec. To make spec changes just for one instance, see CustomizeParticleSpec() in Related Functions.

Particle Chain Spec Tabs

Particle Tabbed Properties.png

Select a particle emitter node and you will see a set of tabs across the top of the Properties Panel that show all of the specs in the particle chain. You can now easily switch between the emitter instance and its various particle specs from the panel.

Note that for the tabs to appear, you must have exactly one emitter node selected.


Terms to know

Axis – One of three mutually perpendicular lines that define the orientation in the 3D engine.

3D Coordinates – If space is given in three dimensions, (X,Y,Z), then a 3D coordinate can be given to define any point in that space.

3D Vector Coordinates – If a 3D coordinate can be given to define any point in space, 3D vector coordinates can be used to define a velocity in that space. For instance, a velocity of X=1 causes movement in the amount of 1 meter per second in the positive X direction (left to right when camera is aligned with the axes). The further from zero the number, the greater the velocity. Combinations of X, Y and Z settings can be made to cover any velocity along any vector in 3D space. It is also in the format (X,Y,Z). See Vector Notation.

3D Rotation – Set using (X,Y,Z), each number for the given axis will tell it to rotate in that direction. The higher the number, the greater the rotational velocity. A negative number will cause rotation in the opposite direction.

Gaussians – A very smart man named Carl Friedrich Gauss did a lot of work in various fields (quite various…math, astronomy, electricity), one of them was probability. Gaussian numbers in the particle system will give you a random value (each frame) defined by parameters of minimum, maximum, median and variation.

ParticleGaussianTimeline.gif

Perlin – In the particle system, used to generate Perlin noise for “natural randomness” or controlled chaos. Consider a field of grass. Not all grass is precisely the same color of green. If viewed from above, it doesn’t appear to be completely random per grass blade however. Soil content, amount of light, susceptibility to the elements, and a billion other factors give real grass in certain areas similar hues (with Perlin, hue, saturation and brightness, or HSB, are our concern). The result is patches of grass that are the same (more or less) coloring and gives a nice field of colors that isn’t completely random.

ParticlePerlinTimeline.png

Sine Wave – A waveform of a single constant frequency and amplitude that continues for all time. The base is the value at which the wave is centered on. Amplitude is the distance from the base to the peak of the wave. Wavelength is the measure of crest to crest of the wave. Frequency is the inverse of wavelength, or 1/wavelength.

ParticleSineTimeline2.jpg

Timeline – Any set of pre-defined values over time.

ParticleDefinedTimeline.png

Children – Anything emitted by an emitter.

Billboard – Particles are rendered using billboards, which are rectangles formed by 2 triangular polygons that always rotate to face the camera by default.

Attractors – Points relative to the emitter that draw or repel particles to it based on a strength setting.

Property Formats

Properties are set in several different formats. Here is a table of format codes and how they are entered. Most complex formats have dialogues to help visually illustrate the setting, such as Gaussian and Timeline.

Name Description Format
Value Floating Point number +/-n.n
Gaussian A minimum, maximum, median and variation given in floating points. <..0,.5,-1.0>
<min,max,variation,median>
Median is given as a value from 0 to 1, where 0 is the entered min value and 1 is the entered max value. It’s much easier to use the interface, in qhich median is the actual number, not a function of the other two values.
RGB Values for the amount of red, green, blue and alpha, or opacity. Values are from 0 to 1. #.95,.791,.55,1.0
#red,green,blue,alpha
It is much easier to use the interface, which can be entered in RGBA or HSBA format.
Gaussian RGB The same as RGB, but with Gaussians for one or more values #<.0,1.0,.5,-1.0>,<.0,1.0,.5,-1.0>,<.0,1.0,.5,-1.0>,<.0,1.0,.5,-1.0>
3D Coordinates Three values representing X,Y and Z. -6.10519,0.349719,-0.953089
n,n,n
These can be used to decribe a position, a rotation and a vector. n,n,n
Sine Waves A waveform of a single constant frequency and amplitude that continues for all time. SINE(min=0,max=2,off=0,amp=2,frq=3,cyc=1,pha=0)
Timelines Any set of pre-defined values over time. [.0:.0:L][.527:.304:L][1.0:.0:L]O
Within each bracket is a point in the lifespan, from 0 to 1, a value and a character that represents the graph of the numbers to the next point. L is a line, H is a 90 degree turn, I is an inverse curve, O is an obverse curve, S is an S-curve and T is a sharp S-curve. The last character outside the brackets is either O (Once), L (Loop) or P (Ping Pong). Once again, it is much easier to use the GUI provided for setting these values.
HSB Perlin Basically it creates a pattern of hue, saturation and brightness. Two things for HSB Perlins. They are very complicated and very resource intensive. So, it is better to use them only in cases where they are only calculated once, like planting grass. Documenting Perlin HSB parameters would require a page around this size, so for the moment it's left to the experts.

Properties of emitters

OrientationAxis – Special usage for emitters. This will be covered where applicable.

EmitSpec – Points to the file name of a particle. This is what gets emitted. (Tip: If you hold down SHIFT while clicking on the "..." button of this field, it will take you straight to the Properties for the particles)

InitialRotation2D – the starting 2D rotation of a billboard particle. The only possible gotchas are that it's in degrees (so if it's fed small numbers the rotation won't be apparent) and that it applies specifically to billboard particles emitted by the emitter, not to other types. And of course if your billboard texture is a radially symmetrical round spot, rotating it won't look like anything.

EmitFrequency – This is how often the emitter emits particles and is measured in seconds between particle emissions. Lower is more frequent. The fastest speed possible is .001. A setting of 0 is equivalent to .001. Realistically, this is frame rate dependent, so the fastest that particles will be emitted is 1 per frame.

EmitterRadius – Changing the radius can result in a line, a rectangle or a cube (if you want to get technical, a hexahedron). Setting one dimension to a value and the remaining 2 dimensions to 0 will give you a line. Setting 2 dimensions will give you a rectangle and setting 3 dimensions will give you a cube. If set, particles will be randomly emitted somewhere within the geometry specified.

WithinRadius – Tells the emitter to only emit its spec at a certain radius from emitter. If 0, emission occurs randomly within the emitter radius. If set to a non-zero value, the particles will be emitted at a certain distance from the center of the emitter radius and also be influenced by the shape created by the emitter radius. Setting a WithinRadius of 1 with a perfectly square EmitterRadius will create a circular pattern, while a rectangular Emitter radius with the same WithinRadius setting will produce a more elliptical pattern.

RunUp – When set to False, the emitter will begin emitting particles when the emitter is instanced. When set to true, the emitter will simulate having been running before being instanced. Particles are placed where their logical position would be as if the emitter had been active all along.

AttractorPosition – Sets up an attractor with a 3D location that is relative to the emitter.

AttractorStrength – Specifes how strong emitted particles are drawn to or repelled from the attractor.

AlignToTrajectory - Sets the 2D rotation of billboard particles on their Z axis (maintaining camera facing!) in the direction the particle is moving relative to the camera facing. A fun way to test it is to use \Engine\CleanGame\GlobalParticles\Textures\Sample\arrow_test.dds for the texture, set CollisionResponse to COLLIDE_BOUNCE, and give the emitter with a radius and a bit of negative AttractorStrength.

CollideWithAttractor – If set to true, once the particle reaches the attractor, it will be deleted. It will not “die” in the sense that the EmitAtDeathSpec property will not be honored.

ChildrenInheritMomentum – If the emitter has any velocity (vector, not rotational), emitted particles will begin their lifespan with that velocity added to their own.

LinkChildren – Particles will live their lifespan relative to the position and rotation of their emitter. If the emitter moves along a vector, the particles would move with it, remaining in a position relative to the emitter.

LinkToCamera quasi-parents the emitter node to the camera. The expected use for it is to set the emitter node Position to 0,0,0, and the EmitterRadius to something nonzero. It can be used to make dust particles/snow/etc float through the air in front of the camera.

DeltaRotation3D – A rotation applied to the emitter given in 3D coordinates. A higher number will produce a faster rotation in each particular axis.

MaxDistanceFromCamera – Emitter will stop emitting if the camera moves far enough away from it. If it is set to 1, if the camera moves to a distance greater than 1, the emitter will pause.

MinDistanceFromCamera – Emitter will stop emitting if the camera moves close enough to it. If it is set to 1, if the camera moves to a distance closer than 1, the emitter will pause.

ScaleOverride - If True, the scale of all emitted particles is affected by the scale of the emitter.

AlphaOverride - Multiplies the alpha of all emitted particles. Can be used to fade effects in or out independently of its constituent particles' timelines.

Properties of BILLBOARD_POINT Particles

SourceBlend & DestBlend – Together these are the alpha blending factors. The combinations will be described later.

DiffuseColor -- The color of the particle in R,G,B,A (red, green, blue, alpha) format. This will be in a 0 to 1 format. If it is desire to convert this from integer RGB values, a utility such as Color Cop may be useful.

OrientationAxis – Specifies along which axis a particle will face. If it is set to “XYZ”, the emitted particle will rotate to always face the camera. Choosing another axis will cause the particle to always rotate to lie along that axis. For instance, setting this to “Y” will always make the particle “upright” Choosing “NONE” applies no rotation at particle emission.

XScale2D – Scale a billboard particle along the X-axis.

Yscale2D – Scale a billboard particle along the Y-axis.

DistanceScaleAdjustment – A scale that persists regardless of distance from camera.

Size 2D – Scale uniformly in X- and Y-axis.

TextureName – Path to the texture of the particle.

TextureNumber – By using TextureNumber, you can randomly emit up to four textures from a single texture files. The default value of 0 will use the entire texture. The texture is divided into 4 quadrants, each quadrant having an integer value that is a power of two, 1, 2, 4 and 8. Adding two or more of these values together will result in one integer that represents multiple values; in other words, a bitwise operation.
PartricleQuadrants.jpg
In this example, a value of 1 for TextureNumber would only emit A, while a value of 9 (1+8) would randomly emit A or D. A value of 15 (1+2+4+8) would randomly emit A, B, C or D.


DeltaRotation2D – Since billboard particles are only 2D, you can specify a rotation using one value. A positive value will cause clockwise rotation, and a negative will cause counter-cockwise rotation.

LieFlat – If an orientation axis is set, setting this to True will cause the particle to lie flat on the plane created by the other two axes.

Reflect – Determines whether a particle will be reflected by a mirror. Use sparingly.

BlurFactor – Will attempt to give the particle a trail, giving it a motion blur. The higher the number, the greater the blur. Use sparingly, as numbers over 10 really hurt frame rate.

BackFace – Set to True, this will render both sides of a billboard. If no orientation is set, this won’t be evident, as the billboard always faces the camera. With OrientationAxis set to a value other of NONE, however, this can make the particle visible from one side and not the other. It is actually faster to leave this True, as there is no checking for the rendering engine to do.

Glow – Will create a glow around a particle. Can be NONE, GLOW and GLOW_ONLY. GLOW_ONLY does not render the particle, only the glow effect.

RespectFog – Will cause the particle to be obscured by distance fog in the area’s environment scheme.

DepthBias – Will force the particle to render in front of objects physically in front of it. The distance to objects this will happen is reflected in the value.

MaxDistanceFromCamera – Particle will not render if the camera moves far enough away from it.

MinDistanceFromCamera – Particle will not render if the camera moves close enough to it.

AlphaFalloff – If AlphaFalloff is positive, the particle will fade as the camera approaches it. Fadeout begins when the camera's distance falls below the AlphaFalloff value, and continues smoothly until the distance is zero. This allows for special effects such as crepuscular rays (aka "God Rays"), glowing eyes in the bushes that dim as you approach, and so on.

Sort – If set to True, the rendering engine will attempt to render particles as they are in the world physically. This means if one particle is physically in front of another, it will be rendered that way. A value of False results in a depth sorting that is more or less random. Use this sparingly. Because sorting has a performance overhead, even if it’s logical to sort them, first try them unsorted and if the effect looks good without it, don’t use it.

Properties Shared by Basic Emitters and Billboard Particles

Since emitters can be emitted, they share many of the same properties of particles. If the emitter is not being emitted, these properties are ignored.

Name – Path of file name of particle or emitter.

Folder – Path of folder containing particle file.

ParticleType

LifeSpan – In seconds, the amount of time elapsed before the emitter is killed. It is possible for other factors to infringe upon this property, such as CollisionResponse and CollideWithAttractor.

EmitAtDeathSpec – File name of the particle or emitter to be emitted at the time of emitter death.

Drag - The drag is an adjustment to velocity (can decrease and increase velocity). A positive value negates velocity, while a negative value adds to it.

Trajectory – A velocity given in 3D vector coordinates.

Buoyancy – The tendency to “float” or “sink” along the Y-axis. Default value is 0. A value greater than 1 will cause the emitter to “float” upwards or move positively along the Y-axis, a value of 1 will give it no motion along the Y-axis, and a value less than one will cause it to “drop”, or move negatively along the Y-axis.

Motion – Motion is movement through 3D space that overrides factors such as drag, buoyancy and trajectory.

CollisionResponse – Reaction of a particle to an object created with collision properties.

Mesh particles

Mesh particles are a step up from billboard point particles. They are actual 3D objects that are emitted. The process for creating them is the same. A basic emitter is set up to emit the particle. The ParticleType of the particle is set to MESH. The particle must then point to a 3D mesh file.

Mesh files have a few unique properties.

MeshFileName – Path to the mesh object to be emitted.

Scale3D – A scale given in 3D coordinates (X,Y,Z), with floating point numbers corresponding to the scale in each axis.

UniformScale3D – A single floating point number that will scale the 3D object by that value in all axes.

DiffuseColor – Instead of the actual color of the object, this affects the diffuse light hitting the object. The result will be a factor of the area’s diffuse lighting and this setting.

AmbientColor – The ambient light hitting the object. The result will be a factor of the area’s ambient lighting and this setting.

DeltaRotation3D – Much like delta rotation on an emitter, this can be applied to the mesh particle, since it is a 3D object. UseEmitterRotation - If true, locks the rotation of the particle to the rotation of its emitter.



Emitter Map

An emitter map uses the alpha channel of a texture to decide where it will emit particles.

Properties Unique to EMITTER_MAP:

ColorInfluence – Determines the color of the particle emitted.

TextureName – The path to the texture to be used at the emitter map.

Performance issues and tips

Related functions

function CustomizeParticleSpec(instance as NodeRef, name as String, value as String) as Boolean

Allows setting the properties of a particle spec used for a specific instance of a particle emitter. Internally, this creates a temporary unique copy of the spec -- changes will not be persisted, nor will they affect other instances of the emitter.


function EmitParticle(emitter as NodeRef of Class HBNode, position as Vector3, rotation as Vector3, trajectory as Vector3)

Causes an emitter to emit a particle at the given position, with the given rotation and trajectory. The particle is independent of the emitter's position, rotation, and normal timing for emissions. This is a powerful and flexible technique which can be used, for example, to emit particles at a character's feet when an animation note is triggered, whenever the mouse moves (at the world location pointed to by the mouse), whenever keys are pressed, or at any other time and place. And by calling the function multiple times for a given event, multiple particles can be emitted from different positions using the same emitter, creating, for example, a "wall of fire" effect.

Trails

There are many options which can be used to customize the glowing trails that will appear following a particle. These trails can be large or small, last a long time or disappear right away, and can also use various textures (an interesting effect is to use the texture of grass to make a particle trail).

Trails can be adjusted via the Environment Panel in HeroBlade, and by modifying the Properties of a particle directly.

Trail structure

In its most basic form, a particle trail is generated as a line or trail which follows the particle. A vertex on the particle (Vertex #1) "stays put", and then the same point on the particle moves with the particle away from Vertex 1, stretching a line between the two. A trail can also be stretched out like a rectangle which follows the particle. This can be envisioned as two points on the particle, Vertex 1 and Vertex 2, which then stretch out as the particle moves. The original vertices "stay put", and the vertices at the new location are numbered 3 and 4.

The location of the vertices are in reference to the center of particle, and are set in Properties as TrailVertex1 and TrailVertex2. For the below example image, these were (0, 0.257, 0) and (0, -0.257, 0).

Particle is moving from right to left, leaving a trail (expanded to huge proportions for visualization purposes)

The colors at each vertex of the ends of the trail are set via the Properties panel for the particle, and interpolated across the length and width of the trail:


Note that when trails overlap, that their colors will combine:

Particles moving from right to left, with overlapping trails

For a tutorial on creating a trail, see Creating particle effects.

Related functions

TrailCreate(color1 as String, color2 as String, color3 as String, color4 as String) as ID

Creates a new trail object, which will exist on the client until it is destroyed with TrailDestroy or TrailDestroyAll, or the client shuts down. The return value is an ID number used when calling other functions relating to the new trail.

Colors are set as: "#0,0,1,1"

TrailSetDecay(trail as ID, decaytime as Float)

Sets the decay time of trail points, in seconds. If 0, vertices will never decay and must be removed via RemovePoints() or destroying the entire trail.

TrailAddPoints(trail as ID, vertex1 as Vector3, vertex2 as Vector3)

Adds a pair of points to the trail, at the given worldspace coordinates. The distance between these two points is the width of the trail; therefore trails must have two pairs of points before they can render.

TrailRemovePoints(trail as ID) as Boolean

Removes the oldest pair of points from the trail.

TrailDestroy(trail as ID) as Boolean

Destroys the trail object. This immediately removes all its points. Any further reference to the trail's ID results in a script error.

TrailDestroyAll() as Boolean

The equivalent of calling TrailDestroy() on all existing trails.

TrailSetTexture(trail as ID, texturename as String)

Sets the texture to be used by the trail. If not set, the trail is a solid color.

TrailSetAddRate(trail as ID, rate as Float)

Sets the minimum amount of time (in seconds) that must pass between the addition of new pairs of points. When TrailAddPoints() is called without enough time having passed, it is ignored. This can help prevent points from being added excessively, without having to track the timing in a script.

TrailSetSmoothing(trail as ID, smoothing as Boolean)

Enables or disables smoothing for the given trail (default true).

TrailSetUVProperties(trail as ID, multiplier as Float, worldspace as Boolean, animation as Float)

Sets the UV properties for the trail, combining TrailUVMultiplier, TrailUVWorldSpace and TrailUVAnimation properties into a single function.

Particle Specification Ownership

A particle specification is "owned" by the area in which it was created, and consequently may only be changed in that area no matter how many areas might have instances of the particle specification. This behavior helps ensure that designers cannot make unintentional changes to a particle specification which was crafted for use in a particular area or set of areas. If, as a designer, you need to modify a particle specification "owned" by another area, it is generally recommended that you travel to that area and make the modifications in the context in which the particle was designed.

A particle specification's "owning" area can be found in the property areaGUID.

However, we recognize that sometimes traveling to the owning area may be cumbersome and consequently there exists an override to disable the particle specification ownership check. This can be executed by typing the following command in HeroBlade's Console Panel.

ToggleMasterParticleEdit

Tutorial

See also

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox