Particles: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
(Adding Category:Particles)
(+ soft particles)
Line 54: Line 54:


[[Category:Editing]][[Category:Tutorial]][[Category:Particles]]
[[Category:Editing]][[Category:Tutorial]][[Category:Particles]]
== 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 into 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 there are a couple of relevant particle decl keywords, including one new keyword for tricky spots:
=== DepthHack ===
This is a more 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.

Revision as of 10:07, 8 February 2015

written by Fidcal


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.


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 into 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 there are a couple of relevant particle decl keywords, including one new keyword for tricky spots:

DepthHack

This is a more 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.