Difference between revisions of "Particle Effects"

From FreeSpace Wiki
Jump to: navigation, search
Line 44: Line 44:
 
*This is optional
 
*This is optional
 
*Syntax: See [[#Uniform random range]], or the string ''<none>''
 
*Syntax: See [[#Uniform random range]], or the string ''<none>''
 +
{{Table232|
 +
===+Size over lifetime curve:===
 +
*Specifies the curve to use for changing the particle's size over time
 +
*The lifetime of the particle (0-1) is X, the size multiplier is Y.
 +
*Syntax: ''String'', the name of the curve from [[Curves.tbl]]
 +
}}
 +
{{Table232|
 +
===+Velocity scalar over lifetime curve:===
 +
*Specifies the curve to use for changing the particle's velocity over time
 +
*The lifetime of the particle (0-1) is X, the velocity multiplier is Y (negative Y values cause the aprticle to move backwards, etc).
 +
*Syntax: ''String'', the name of the curve from [[Curves.tbl]]
 +
}}
  
 
=Effect Types=
 
=Effect Types=
Line 57: Line 69:
 
*Syntax: See [[#Uniform random range]]
 
*Syntax: See [[#Uniform random range]]
 
*Default: 0
 
*Default: 0
}}
 
{{Table232|
 
===+Size over lifetime curve:===
 
*Specifies the curve to use for changing the particle's size over time
 
*The lifetime of the particle (0-1) is X, the size multiplier is Y.
 
*Syntax: ''String'', the name of the curve from [[Curves.tbl]]
 
}}
 
{{Table232|
 
===+Velocity scalar over lifetime curve:===
 
*Specifies the curve to use for changing the particle's velocity over time
 
*The lifetime of the particle (0-1) is X, the velocity multiplier is Y (negative Y values cause the aprticle to move backwards, etc).
 
*Syntax: ''String'', the name of the curve from [[Curves.tbl]]
 
 
}}
 
}}
  
Line 131: Line 131:
 
*Syntax: See [[#Uniform random range]]
 
*Syntax: See [[#Uniform random range]]
 
*Default: 0
 
*Default: 0
}}
 
{{Table232|
 
===+Size over lifetime curve:===
 
*Specifies the curve to use for changing the particle's size over time
 
*The lifetime of the particle (0-1) is X, the size multiplier is Y.
 
*Syntax: ''String'', the name of the curve from [[Curves.tbl]]
 
}}
 
{{Table232|
 
===+Velocity scalar over lifetime curve:===
 
*Specifies the curve to use for changing the particle's velocity over time
 
*The lifetime of the particle (0-1) is X, the velocity multiplier is Y (negative Y values cause the aprticle to move backwards, etc).
 
*Syntax: ''String'', the name of the curve from [[Curves.tbl]]
 
 
}}
 
}}
  
Line 190: Line 178:
 
*Syntax: See [[#Uniform random range]]
 
*Syntax: See [[#Uniform random range]]
 
*Default: 0
 
*Default: 0
}}
 
{{Table232|
 
===+Size over lifetime curve:===
 
*Specifies the curve to use for changing the particle's size over time
 
*The lifetime of the particle (0-1) is X, the size multiplier is Y.
 
*Syntax: ''String'', the name of the curve from [[Curves.tbl]]
 
}}
 
{{Table232|
 
===+Velocity scalar over lifetime curve:===
 
*Specifies the curve to use for changing the particle's velocity over time
 
*The lifetime of the particle (0-1) is X, the velocity multiplier is Y (negative Y values cause the aprticle to move backwards, etc).
 
*Syntax: ''String'', the name of the curve from [[Curves.tbl]]
 
 
}}
 
}}
  
Line 265: Line 241:
 
*Syntax: See [[#Uniform random range]]
 
*Syntax: See [[#Uniform random range]]
 
*Default: 0
 
*Default: 0
}}
 
{{Table232|
 
===+Size over lifetime curve:===
 
*Specifies the curve to use for changing the particle's size over time
 
*The lifetime of the particle (0-1) is X, the size multiplier is Y.
 
*Syntax: ''String'', the name of the curve from [[Curves.tbl]]
 
}}
 
{{Table232|
 
===+Velocity scalar over lifetime curve:===
 
*Specifies the curve to use for changing the particle's velocity over time
 
*The lifetime of the particle (0-1) is X, the velocity multiplier is Y (negative Y values cause the aprticle to move backwards, etc).
 
*Syntax: ''String'', the name of the curve from [[Curves.tbl]]
 
 
}}
 
}}
  

Revision as of 01:02, 27 June 2023

This feature requires FreeSpace Open

Revision information.....

FSO Git Commit: Date: 2020-10-29 SHA: 4546c8784
Note: Please update the revision information when the page is updated. If your edit had nothing to do with new code entries then please do not edit the revision information


List of Tables and related code files
* Notes Modular Tables
** Notes tables which only use modular tables
Ai.tbl* /ai/aicode.cpp
Ai_profiles.tbl* /ai/ai_profiles.cpp
Animation.tbl** /model/modelanimation.cpp
Armor.tbl* /ship/ship.cpp
Asteroid.tbl* /asteroid/asteroid.cpp
Autopilot.tbl* /autopilot/autopilot.cpp
Cheats.tbl* /cheats_table/cheats_table.cpp
Colors.tbl* /globalincs/alphacolors.cpp
Curves.tbl* /math/curves.cpp
Controlconfigdefaults.tbl /controlconfig/controlsconfigcommon.cpp
Credits.tbl* /menuui/credits.cpp
Cutscenes.tbl* /cutscene/cutscenes.cpp
Decals.tbl** /decals/decals.cpp
Fireball.tbl* /fireball/fireballs.cpp
Fonts.tbl* /graphics/font.cpp
Game_settings.tbl* /mod_table/mod_table.cpp
Glowpoints.tbl* /model/modelread.cpp
Help.tbl* /gamehelp/contexthelp.cpp
Hud_gauges.tbl* /hud/hudparse.cpp
Icons.tbl* /mission/missionbriefcommon.cpp
Iff_defs.tbl* /iff_defs/iff_defs.cpp
Keywords.tbl* Not In Codebase
Lighting_Profiles.tbl* /lighting/lighting_profiles.cpp
Lightning.tbl* /nebula/neblightning.cpp
Mainhall.tbl* /menuui/mainhallmenu.cpp
Medals.tbl* /stats/medals.cpp
Messages.tbl* /mission/missionmessage.cpp
Mflash.tbl* /weapon/muzzleflash.cpp
Music.tbl* /gamesnd/eventmusic.cpp
Nebula.tbl* /nebula/neb.cpp
Objecttypes.tbl* /ship/ship.cpp
Options.tbl* Not In Codebase
Particle effects(-part.tbm)** /particle/effects...
Post_processing.tbl /graphics/gropenglpostprocessing.cpp
Rank.tbl* /stats/scoring.cpp
Scpui.tbl* Not In Codebase
Scripting.tbl* /parse/scripting.cpp
Ships.tbl* /ship/ship.cpp
Sexps.tbl** /parse/sexp/sexp_lookup.cpp
Sounds.tbl* /gamesnd/gamesnd.cpp
Species_defs.tbl* /species_defs/species_defs.cpp
Species.tbl* /menuui/techmenu.cpp
Ssm.tbl* /hud/hudartillery.cpp
Stars.tbl* /starfield/starfield.cpp
Strings.tbl* /localization/localize.cpp
Tips.tbl* /menuui/playermenu.cpp
Traitor.tbl* /stats/scoring.cpp
Tstrings.tbl* /localization/localize.cpp
Virtual_pofs.tbl* /model/modelreplace.cpp
Weapon_expl.tbl* /weapon/weapons.cpp
Weapons.tbl* /weapon/weapons.cpp

Particle Effects is a SCP feature which allows to define custom particle effects that can be assigned to various engine properties.

This table is one of the Modular Tables and can be extended with xxx-part.tbm. This table type does not have a main table like the other types. All particle effects must be specified in modular tables. Currently there is no support for the usual +nocreate ability the other modular tables have but that will be added in the future. Parts of this documentation are written with with +nocreate in mind for when that is implemented.

General Info

  • Begins with #Particle Effects
  • Contains zero or more particle effect definitions
  • Ends with #End

Particle effects are created by specifying a name and a type. The type dictates which values are valid and will be described below.

$Effect:

  • Creates a new effect and specifies its name. The name must be at least one character long.
  • Syntax: String

$Type:

  • Sets the type of this effect. See Effect Types for possible values.
  • Syntax: String

+Filename:

  • Sets the filename of the animation that should be used.
  • Required if +nocreate wasn't used
  • Syntax: String, filename
FS2 Open, 21.0:
  • Allows for setting list of filenames the animation should use. If multiple animations are listed it picks randomly from the list for each spawned animation.
  • Syntax: String or String List, filename(s)

+Size:

+Length:

  • If specified, orients the animation along its velocity, and stretches it by this distance. This is a uniformly distributed random range, see #Uniform random range.
  • This is optional
  • Syntax: See #Uniform random range

+Lifetime:

  • Sets the life time of the particles. This is a uniformly distributed random range, see #Uniform random range, or the string <none> in which case the runtime of the animation is used. Defaults to <none>.
  • This is optional
  • Syntax: See #Uniform random range, or the string <none>
FS2 Open, 23.2:

+Size over lifetime curve:

  • Specifies the curve to use for changing the particle's size over time
  • The lifetime of the particle (0-1) is X, the size multiplier is Y.
  • Syntax: String, the name of the curve from Curves.tbl
FS2 Open, 23.2:

+Velocity scalar over lifetime curve:

  • Specifies the curve to use for changing the particle's velocity over time
  • The lifetime of the particle (0-1) is X, the velocity multiplier is Y (negative Y values cause the aprticle to move backwards, etc).
  • Syntax: String, the name of the curve from Curves.tbl

Effect Types

There are multiple different types of effects. They are specified by passing the given name to $Type.

Single

This effect type creates exactly one particle per processing step.


FS2 Open, 22.0:

+Parent Velocity Factor:

  • Allows the particles to inherit the velocity of an attached object, like a weapon/ship/particle if applicable, or the last velocity of the associated weapon in the case of a weapon's $Impact Effect.
  • 0 is none of the velocity, 1 is 100% of the velocity, but the value can exceed those in either direction if desired.
  • Syntax: See #Uniform random range
  • Default: 0

+Duration:

  • Sets for how long this effect will be active. The duration can be once, always or a random range. If the effect should run only once then you can use the string Onetime. If the effect should always be active you can specify the string Always. Otherwise a non-negative random range is expected.
  • This is optional
  • Syntax: Onetime, Always, or a #Uniform random range.

+Delay:

  • Specifies after how much time after the effect is triggered the effect starts creating particles. This is not a valid option if the duration is Onetime.
  • This is optional
  • Syntax: See #Uniform random range, or the string <none>

+Effects per second:

  • Specifies how many times per second this effect is triggered. If this is not specified then the effect is triggered every frame. "Triggering" an effect means that one instance of the effect with the properties from above is created. If this is specified then the amount of triggers per second is always the same regardless of the FPS the game is running at. Values higher than the FPS (e.g. 120 if the game is running at 60 FPS) are handled correctly and will trigger the effect multiple times per frame if necessary.
  • This is optional
  • Syntax: number. Must be greater than 0.

Composite

A composite effects contains multiple other effects which are all displayed at the same time. This is useful if you want to create complex effects that require more than one individual particle effect. The amount of child effects is not limited. This type currently does not support +nocreate.

+Child effect:

  • This specifies a child effect that should be added to the composite effect. The effect is specified using #Inline effect creation.

Cone

This effects creates multiple particles which are sent in a direction determined by a cone around a specific direction. The particles are created in a normal distribution around the direction vector. That means that more particle are created along the direction vector than far away from it. The velocity of a particle is scaled based on the angle it is away from the direction vector. This may be changed in the future to allow different effects.

+Deviation:

  • Sets the standard deviation from the direction vector. Must not be 0 (though 0.1 is acceptable).
  • Required if +nocreate is not present
  • Syntax: float, in degrees

+Velocity:

+Number:

+Chance:

FS2 Open, 22.2:
  • Sets a chance to spawn for each particle specified by +Number
  • Syntax: float between 1.0 and 0.0. 1.0 is a 100% chance, and 0.0 is a 0% chance.

+Direction:

  • Sets the direction the cone will be centered around. Can be one of:
    • Incoming: The direction vector is the direction of the particle source, e.g. for a weapon this would be the orientation it is currently facing.
    • Normal: The normal vector of the particle source. This data may not exist for all sources. The debug log file will contain the warning message "Effect '<EffectName>' tried to use normal direction for source without a normal!" if an effect tries to use the normal vector without it existing.
    • Reflected: The reflected vector from incoming and normal vector. This is a good way of simulating armor deflecting a shot. This direction requires the normal for work properly so the same warning message as above may appear in your log if the source has no normal vector assigned to it.
    • Reverse: The reverse of the incoming vector
  • Optional
  • Syntax: String, one of the strings specified above


FS2 Open, 22.0:

+Parent Velocity Factor:

  • Allows the particles to inherit the velocity of an attached object, like a weapon/ship/particle if applicable, or the last velocity of the associated weapon in the case of a weapon's $Impact Effect.
  • 0 is none of the velocity, 1 is 100% of the velocity, but the value can exceed those in either direction if desired.
  • Syntax: See #Uniform random range
  • Default: 0

+Duration:

  • Sets for how long this effect will be active. The duration can be once, always or a random range. If the effect should run only once then you can use the string Onetime. If the effect should always be active you can specify the string Always. Otherwise a non-negative random range is expected.
  • This is optional
  • Syntax: Onetime, Always, or a #Uniform random range.

+Delay:

  • Specifies after how much time after the effect is triggered the effect starts creating particles. This is not a valid option if the duration is Onetime.
  • This is optional
  • Syntax: See #Uniform random range, or the string <none>

+Effects per second:

  • Specifies how many times per second this effect is triggered. If this is not specified then the effect is triggered every frame. "Triggering" an effect means that one instance of the effect with the properties from above is created. If this is specified then the amount of triggers per second is always the same regardless of the FPS the game is running at. Values higher than the FPS (e.g. 120 if the game is running at 60 FPS) are handled correctly and will trigger the effect multiple times per frame if necessary.
  • This is optional
  • Syntax: number. Must be greater than 0.

+Trail effect:

Sphere

This effect creates particles which are randomly sent in all directions.

+Velocity:

+Number:

+Chance:

FS2 Open, 22.2:
  • Sets a chance to spawn for each particle specified by +Number
  • Syntax: float between 1.0 and 0.0. 1.0 is a 100% chance, and 0.0 is a 0% chance.


FS2 Open, 22.0:

+Parent Velocity Factor:

  • Allows the particles to inherit the velocity of an attached object, like a weapon/ship/particle if applicable, or the last velocity of the associated weapon in the case of a weapon's $Impact Effect.
  • 0 is none of the velocity, 1 is 100% of the velocity, but the value can exceed those in either direction if desired.
  • Syntax: See #Uniform random range
  • Default: 0

+Duration:

  • Sets for how long this effect will be active. The duration can be once, always or a random range. If the effect should run only once then you can use the string Onetime. If the effect should always be active you can specify the string Always. Otherwise a non-negative random range is expected.
  • This is optional
  • Syntax: Onetime, Always, or a #Uniform random range.

+Delay:

  • Specifies after how much time after the effect is triggered the effect starts creating particles. This is not a valid option if the duration is Onetime.
  • This is optional
  • Syntax: See #Uniform random range, or the string <none>

+Effects per second:

  • Specifies how many times per second this effect is triggered. If this is not specified then the effect is triggered every frame. "Triggering" an effect means that one instance of the effect with the properties from above is created. If this is specified then the amount of triggers per second is always the same regardless of the FPS the game is running at. Values higher than the FPS (e.g. 120 if the game is running at 60 FPS) are handled correctly and will trigger the effect multiple times per frame if necessary.
  • This is optional
  • Syntax: number. Must be greater than 0.

+Trail effect:


FS2 Open, 21.4:

Volume

This effect creates particles within a spherical (or ellipsoidal) volume.

+Velocity:

  • Sets the velocity of the created particles. This is a #Uniform random range. This value will be scaled based the particle's starting distance from the center of the volume.
  • Required if +nocreate is not present
  • Syntax: See #Uniform random range

+Number:

+Chance:

FS2 Open, 22.2:
  • Sets a chance to spawn for each particle specified by +Number
  • Syntax: float between 1.0 and 0.0. 1.0 is a 100% chance, and 0.0 is a 0% chance.

+Volume radius:

  • Sets the radius of the spherical volume.
  • Required if +nocreate is not present
  • Syntax: Float, meters

+Bias:

  • Causes the particles to spawn more frequently near the edges or near the center. Values greater than 1 bias the particles toward the center, less than 1 biases them towards the edge.
  • This is optional.
  • Syntax: Float

+Stretch:

  • 'Stretches' or squashes the spherical volume into an ellipsoid. Values greater than 1 stretch it, less than 1 squashes it.
  • This is optional.
  • Syntax: Float


FS2 Open, 22.0:

+Parent Velocity Factor:

  • Allows the particles to inherit the velocity of an attached object, like a weapon/ship/particle if applicable, or the last velocity of the associated weapon in the case of a weapon's $Impact Effect.
  • 0 is none of the velocity, 1 is 100% of the velocity, but the value can exceed those in either direction if desired.
  • Syntax: See #Uniform random range
  • Default: 0

+Duration:

  • Sets for how long this effect will be active. The duration can be once, always or a random range. If the effect should run only once then you can use the string Onetime. If the effect should always be active you can specify the string Always. Otherwise a non-negative random range is expected.
  • This is optional
  • Syntax: Onetime, Always, or a #Uniform random range.

+Delay:

  • Specifies after how much time after the effect is triggered the effect starts creating particles. This is not a valid option if the duration is Onetime.
  • This is optional
  • Syntax: See #Uniform random range, or the string <none>

+Effects per second:

  • Specifies how many times per second this effect is triggered. If this is not specified then the effect is triggered every frame. "Triggering" an effect means that one instance of the effect with the properties from above is created. If this is specified then the amount of triggers per second is always the same regardless of the FPS the game is running at. Values higher than the FPS (e.g. 120 if the game is running at 60 FPS) are handled correctly and will trigger the effect multiple times per frame if necessary.
  • This is optional
  • Syntax: number. Must be greater than 0.

+Trail effect:

Inline effect creation

At some places in this table a particle effect may be created within another particle effect. This is used for composite effects and particle trails. If inline creation is valid for an option then you may either specify a name of a previously defined effect or use $New Effect which will create a new, unnamed effect. If a name is specified then that effect must be already defined. In order to ensure that the effect is always defined no matter in which order the effect tables are parsed the effect should be defined in the same table. Some options using this construct require a specific type of effect. That will be noted in the documentation of the option.

If $New Effect is used then a new unnamed effect is created. If the surrounding option has not forced an effect type then you can specify it using the standard syntax described above. All options are the same as if the effect would have been parsed in the normal way. +nocreate is not valid within this element.

Random range

The particle effect system uses randomization to provide variation to the created particles. This is implemented by letting the mod author specify the values for the random distribution. There are different types of distributions which are explained below.

Uniform random range

  • This accepts 1 or 2 values. If one value is used then the random range always returns that value. If two values are specified then a uniformly distributed random value will be picked from the range.
  • Syntax: (Random values), a list of floating point values. Either one or two values. If only one value is specified then the parentheses are optional.
    • Example: (4 20)
    • Example: 4

Normal distribution random range

  • This accepts 1 or 2 values. This random range generates values according to a normal distribution. The first value specified the mean value of the distribution. The second value specifies the standard deviation of the distribution, this defaults to 1.
  • Syntax: (Random values), a list of floating point values. Either one or two values.
    • Example: (4 20)

Example

#Particle Effects

$Effect: MassDriverImpact
$Type: Cone
	+Filename: exp05
	+Size: (5 7)
	+Lifetime: (0.6)
	+Deviation: 5
	+Velocity: (500 700)
	+Number: (20 30)
	+Direction: Reflected
	+Trail effect: $New Effect
		$Type: Single
			+Filename: exp20
			+Size: (10)
			+Lifetime: (1)
			+Duration: Always


$Effect: ApocalypseIgnition
$Type: Single
	+Filename: exp20
	+Size: (10 20)

$Effect: Small_Explosion
$Type: Single
	+Filename: ("exp20" "exp05")
	+Size: (10 20)
	
$Effect: ApocalypseHomed
$Type: Composite
	+Child effect: $New Effect
		$Type: Single
			+Filename: exp05
			+Size: (5 7)
			+Duration: (2 10)
	+Child effect: $New Effect
		$Type: Single
			+Filename: exp06b
			+Size: (5 7)
			+Duration: (2 10)
			+Delay: (8 15)
			+Effects per second: 20

#End