Particles: Difference between revisions
(8 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
== Introduction == | == Introduction == | ||
Line 26: | Line 23: | ||
* Note that 'Choose Model' does not assign a model or models to be emitted such as a leaf or snowflake (see [[Particle Editor]]) No, if you choose model then it just assigns a visible model shape to the entity in the normal way. I guess one could use a chimney pot in our example but the particle effect would have to be customised to line up so we shall create a separate particle effect and just place it over a chimney. Depends on what you are doing whether you need a model at the position of the particle effect. It does save on entities, but it is less flexible. | * Note that 'Choose Model' does not assign a model or models to be emitted such as a leaf or snowflake (see [[Particle Editor]]) No, if you choose model then it just assigns a visible model shape to the entity in the normal way. I guess one could use a chimney pot in our example but the particle effect would have to be customised to line up so we shall create a separate particle effect and just place it over a chimney. Depends on what you are doing whether you need a model at the position of the particle effect. It does save on entities, but it is less flexible. | ||
Line 35: | Line 31: | ||
Particle effects can also be created using the [[Stim/Response]] system. | Particle effects can also be created using the [[Stim/Response]] system. | ||
Particles can be turned off and on by the game itself too. You can place a "hide_distance" spawnarg on the emitter with the value in units (e.g. "512") after which the particle emitter will be switched off (and on again if the player re-enters the radius). If you encounter problems with particles going through your walls, you can also use the "areaLock" spawnarg with a value called "origin". This ties the entity's visibility to the visleaf in which the origin lies, meaning, if the player leaves the room or closes the vis portal (by shutting the door), the emitter will stop emitting the particles. | |||
==Starting OFF at game start== | ==Starting OFF at game start== | ||
Line 45: | Line 42: | ||
Note that the particle effect may be very briefly visible at game start then turn off within a second. This is normal and I don't think can be avoided. In most cases this doesn't matter if the effect is not in the player's view right at game start. | Note that the particle effect may be very briefly visible at game start then turn off within a second. This is normal and I don't think can be avoided. In most cases this doesn't matter if the effect is not in the player's view right at game start. | ||
Line 53: | Line 49: | ||
[[Category:Editing]][[Category:Tutorial]] | == Soft Particles == | ||
Beginning in TDM 2.03, particle effects are softened where they intersect solid objects. There's no longer any need to move lamp glares away from walls, and dust/fog/smoke will appear to be shapeless 3d volumes instead of 2d images cut off at the floor and walls. | |||
Soft particles start to fade out where they get close to solid objects. And when they intersect solid objects, they continue to draw over the top for a short distance. This "rubs out" any hard edges belonging to the 2d images that make up the particle effect, which stops the eye getting a fix on exactly where those images are and restores the illusion of a 3d volume. | |||
The range over which the particle fades out -- and is allow to draw over solid stuff -- is proportional to the "radius" of the particle volume being represented. By default, it's 0.4 times the diameter of the particle stages' quads. | |||
Soft particles can be toggled on and off using the cvar r_useSoftParticles. | |||
Mappers don't have to do anything to take advantage of this -- it's enabled by default and will "just work" in 99% of cases -- but mappers can control the effect more precisely if they wish using the "SofteningRadius" keyword documented below. | |||
== Particle decl keywords == | |||
Most particle settings are applied using the particle editor, but there are a few more keywords that can be added manually to the decl generated by the editor. | |||
You can read about most of keywords on the [https://iddevnet.dhewm3.org/doom3/editor_particle.html Doom 3 SDK page]. Additional explanation is provided in the [[Particle Editor]] article | |||
=== WorldAxis === | |||
Added in 2.03 to enable better candle smoke. If a particle stage has an offset to its origin, or if it moves in any way independent of gravity, WorldAxis will make that offset and movement use the world axis instead of the emitter's axis. Particles also have a WorldGravity keyword that's set using the particle editor. WorldGravity affects only movement under gravity. WorldAxis affects other kinds of movement plus offsets. Added so that candle smoke can rise upright at a constant rate no matter how the player turns the candle. | |||
Example: the new candle smoke in 2.03 starts with a narrow plume of smoke emitted from the candle's wick (which is where the emitter is placed), followed by a wider volume of wispy smoke that spreads out from the top of the narrow plume. Both stages use WorldAxis: the first stage so that it can rise upright from a knocked-over candle at a constant rate; the second stage so that it always starts from a point ''above'' the candle even if the candle is on its side. | |||
=== DepthHack === | |||
This is a primitive way of avoiding some particle intersections, the only one that was available in the original idTech4 engine. It's a keyword placed at the top of the particle decl and applies to all stages of the particle: it can't be applied separately to individual stages. It causes the particle to draw in front of solid objects by up to the specified number of units, e.g. "depthHack 20" was used in lamp glares to make them draw over things by up to 20 units. | |||
DepthHack is overridden by the new soft particle technique in TDM 2.03. The keyword and its value are ignored, unless the particle decl turns off the new soft particles effect. | |||
=== SofteningRadius === | |||
New particle stage keyword for TDM 2.03. Add this to individual particle ''stages'' to change the behaviour of soft particles. Accepted values are: | |||
* -1: Turn off soft particles and draw this particle stage the old way, including using DepthHack if it's specified in the decl. | |||
* 0: Turn off soft particles AND Depthhack. | |||
* Any positive number: sets the particle "radius", which is the amount it's allowed to draw in front of anything solid that intersects it. Defaults to 0.4 times the max particle quad size for the stage. If you have a tricky particle that's showing through a wall, you can reduce the radius a bit. For example: a tdm_dustfog_03 with a max quad size of 100 will have a default radius of 40. If you want to put it in a confined space where it ends up showing through a wall, you could add "softeningRadius 30" to the stage to stop that happening. | |||
=== DiversityPeriod === | |||
This keyword was introduced in TDM 2.09. With default value 0, every cycle of a particle system looks a bit different from the previous ones in terms of randomness/diversity. | |||
With value K > 0, every K-th cycle of particle system looks exactly the same. So it makes the system look "periodic". For instance, K = 1 means that every cycle looks the same. Value K = 10 means that ten cycles look different but after that everything repeats. | |||
The keyword is required for the new [[Particle collisions and cutoff#Linear layout|"mapLayout linear"]] mode of particle collisions. | |||
[[Category:Editing]][[Category:Tutorial]][[Category:Particles]] |
Latest revision as of 12:52, 14 November 2022
Introduction
Particles are VERY flexible - they can function as rain, snow, falling leaves, oscillating leaves and foliage, smoke, mist, flame, trickling sand, trickling water, drips, waterfall, spray, fountain - anything that can be made up of particles, big or small, fast or slow.
There are already many particle effects available to the Dark Mod mapper. This tutorial is just the basics of how to get particle effects, new or old, into your mission...
Getting Particle effects into your game
First, all that is assumed is you know the essentials described in Dark Radiant Must Know Basic Intro
Like so many things - it's easy when you know how. Let me describe by example. Say you want to have some smoke coming out of a chimney in your mission...
- Right click and select Create Entity. Select func_emitter from the list.
- Add the property : model
- If you select the model property then you see two buttons at the bottom - Choose Model and Choose Particle.
- Select the Choose Particles button (see below for information on Choose Model)
- Select a particles effect from the list. For chimney smoke there are a couple of Doom ones - admin_hall_smk_cone.prt and mc2_hall_smk_cone.prt though they are a little bright (but could be modified in the Particles Editor and resaved as a new particles effect.) There are also a couple of Dark Mod ones - chimney_smoke1.prt and chimney_smoke2.prt at this time. Other DM stuff is under tdm_ but it's worth exploring the whole list to see what is available.
- All that remains is to position your func_emitter over a chimney.
- Note that there is a DR bug that does not allow you to rotate the func_emitter on the X or Y planes; however, there's some question whether most particles care about where the emitter is rotated.
That will give you a start. Try out some of the others so you see what is available and what is possible and then you can move on to more advanced stuff...
- Note that 'Choose Model' does not assign a model or models to be emitted such as a leaf or snowflake (see Particle Editor) No, if you choose model then it just assigns a visible model shape to the entity in the normal way. I guess one could use a chimney pot in our example but the particle effect would have to be customised to line up so we shall create a separate particle effect and just place it over a chimney. Depends on what you are doing whether you need a model at the position of the particle effect. It does save on entities, but it is less flexible.
Switching Particles on and off
func_emitter can be turned on and off by using target from any targetting entity eg a button or lever.
Particle effects can also be created using the Stim/Response system.
Particles can be turned off and on by the game itself too. You can place a "hide_distance" spawnarg on the emitter with the value in units (e.g. "512") after which the particle emitter will be switched off (and on again if the player re-enters the radius). If you encounter problems with particles going through your walls, you can also use the "areaLock" spawnarg with a value called "origin". This ties the entity's visibility to the visleaf in which the origin lies, meaning, if the player leaves the room or closes the vis portal (by shutting the door), the emitter will stop emitting the particles.
Starting OFF at game start
To start a particle effect OFF at game start give the func_emitter the property and value...
start_off 1
You can then make it start when you want by using target from any targetting entity eg a button or lever.
Note that the particle effect may be very briefly visible at game start then turn off within a second. This is normal and I don't think can be avoided. In most cases this doesn't matter if the effect is not in the player's view right at game start.
Creating Your Own Particle Effects
You can create your own particle effects - or even easier - modify existing ones. To do this read Particle Editor.
Soft Particles
Beginning in TDM 2.03, particle effects are softened where they intersect solid objects. There's no longer any need to move lamp glares away from walls, and dust/fog/smoke will appear to be shapeless 3d volumes instead of 2d images cut off at the floor and walls.
Soft particles start to fade out where they get close to solid objects. And when they intersect solid objects, they continue to draw over the top for a short distance. This "rubs out" any hard edges belonging to the 2d images that make up the particle effect, which stops the eye getting a fix on exactly where those images are and restores the illusion of a 3d volume.
The range over which the particle fades out -- and is allow to draw over solid stuff -- is proportional to the "radius" of the particle volume being represented. By default, it's 0.4 times the diameter of the particle stages' quads.
Soft particles can be toggled on and off using the cvar r_useSoftParticles.
Mappers don't have to do anything to take advantage of this -- it's enabled by default and will "just work" in 99% of cases -- but mappers can control the effect more precisely if they wish using the "SofteningRadius" keyword documented below.
Particle decl keywords
Most particle settings are applied using the particle editor, but there are a few more keywords that can be added manually to the decl generated by the editor. You can read about most of keywords on the Doom 3 SDK page. Additional explanation is provided in the Particle Editor article
WorldAxis
Added in 2.03 to enable better candle smoke. If a particle stage has an offset to its origin, or if it moves in any way independent of gravity, WorldAxis will make that offset and movement use the world axis instead of the emitter's axis. Particles also have a WorldGravity keyword that's set using the particle editor. WorldGravity affects only movement under gravity. WorldAxis affects other kinds of movement plus offsets. Added so that candle smoke can rise upright at a constant rate no matter how the player turns the candle.
Example: the new candle smoke in 2.03 starts with a narrow plume of smoke emitted from the candle's wick (which is where the emitter is placed), followed by a wider volume of wispy smoke that spreads out from the top of the narrow plume. Both stages use WorldAxis: the first stage so that it can rise upright from a knocked-over candle at a constant rate; the second stage so that it always starts from a point above the candle even if the candle is on its side.
DepthHack
This is a primitive way of avoiding some particle intersections, the only one that was available in the original idTech4 engine. It's a keyword placed at the top of the particle decl and applies to all stages of the particle: it can't be applied separately to individual stages. It causes the particle to draw in front of solid objects by up to the specified number of units, e.g. "depthHack 20" was used in lamp glares to make them draw over things by up to 20 units.
DepthHack is overridden by the new soft particle technique in TDM 2.03. The keyword and its value are ignored, unless the particle decl turns off the new soft particles effect.
SofteningRadius
New particle stage keyword for TDM 2.03. Add this to individual particle stages to change the behaviour of soft particles. Accepted values are:
- -1: Turn off soft particles and draw this particle stage the old way, including using DepthHack if it's specified in the decl.
- 0: Turn off soft particles AND Depthhack.
- Any positive number: sets the particle "radius", which is the amount it's allowed to draw in front of anything solid that intersects it. Defaults to 0.4 times the max particle quad size for the stage. If you have a tricky particle that's showing through a wall, you can reduce the radius a bit. For example: a tdm_dustfog_03 with a max quad size of 100 will have a default radius of 40. If you want to put it in a confined space where it ends up showing through a wall, you could add "softeningRadius 30" to the stage to stop that happening.
DiversityPeriod
This keyword was introduced in TDM 2.09. With default value 0, every cycle of a particle system looks a bit different from the previous ones in terms of randomness/diversity. With value K > 0, every K-th cycle of particle system looks exactly the same. So it makes the system look "periodic". For instance, K = 1 means that every cycle looks the same. Value K = 10 means that ten cycles look different but after that everything repeats. The keyword is required for the new "mapLayout linear" mode of particle collisions.