Weather effects

From Oldunreal-Wiki
Revision as of 22:53, 5 November 2014 by Hellkeeper (talk | contribs) (typos)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
A WeatherEmitter used to spawn rain in a realistic fashion (map DmRiot).

Weather effects such as rain, snow, falls of dust, hail and so on, can be added to a map in a map, using the newly introduced WeatherEmitter added by Unreal 227. This actor, a subclass of XParticleEmitter, is specifically designed to spawn falling sprites. It holds significant advantages over Particle Emitters regarding weather conditions, such as not spawning a huge amount of sprites over the entire affected zone, but only in a limited radius around the player to mimic weather without being too much of a strain on the engine.

Theory and uses

The Weather Emitter is the placeable subclass of XWeatherEmitter, itself a subclass of XParticleEmitter. This is a directional actor: when added to the map, its rotation is shown by a red arrow and is very important to determine many things. For a Weather Emitter, the direction of the arrow is the direction into which weather effects "fall". Though usually, it will be directed to the ground, more or less inclined (to imitate, for example, falling rain), it is possible to have rain "falling" from the ground to the sky if you need such an effect.

A regular Particle Emitter is assigned a radius or a box - by the mapper - in which particles are spawned. The Lifetime of the particles spawned are used to determine how far they travel before being destroyed. This is an intuitive way of doing things, but its drawback when using effects on large areas is that a great number of particles will have to be spawned to cover the entire zone. Even modern computers may be brought to their knees given a sufficiently lush emitter covering huge... tracts of land. For rain, snow or such effects, which may cover entire maps and always be visible somewhere, this is simply not an option, as the number of particles would be so high playing the game would be like watching grandma's slideshow - if the engine does not simply give up on trying before crashing.

The WeatherEmitter, on the other hand, tackles this issue in an efficient way: instead of spawning particles all over the map, a weather emitter is assigned a volume or an entire zone. When a player enters the zone, particles are spawned only around him to give him the illusion that rain is actually falling. Picture players running around, each one surrounded by his own cube of falling particles visible only to him: because all players see rain falling around, they believe the whole map is covered rainy. In fact, only a few hundred particles are spawned around him. When sufficiently far away from the zone or volume in which rain is spawned, the player will see nothing; when running towards the rainy zone, he will see rain slowly appearing in the distance and gain density and opacity, exactly as one would while getting closer and closer to a window.

The WeatherEmitter

The WeatherEmitter actor. Notice the directional red arrow when selected.

When added to the map, the WeatherEmitter is displayed as a small cloud with rain drops falling out from it. The first step in creating realistic weather conditions is to rotate it so that it is oriented in the direction the rain, snow or whatever you want to spawn, is falling. If you activate RealTime Preview, you may notice that it already spawns the traditional pawn actor texture. Now let's see what we can make of this bad boy.

Properties

All the properties of the WeatherEmitter are in the XWeatherEmitter tab of its properties. All proprety names are quite self-explanatory, and a quick look at the XWeatherEmitter code can give you hints if needed. The WeatherEmitter is very easy to use and can pretty much be used with its default properties when provided with a rain texture.

Sprites are spawned by the WeatherEmitter in a cube around the player.
  • AppearArea: Default: all 0; This property lets you define a volume with Min and Max coordinates on all axis. The defined box will be the volume in which it is raining. A player standing outside of the volume will be able to see rain falling inside the volume. As explained above, there will not be a constant stream of particles spawned all over the box; particles will be created in the parts of a cube around the player which are inside the volume or zone in which the rain is spawned. See the illustration. For this parameter to be active, AppearAreaType must be set to EWA_Box.
  • ApearAreaType: Default EWA_Zone; Decides the spawning of particles either in the entire zone where the WeatherEmitter is located (determined by portals and zoneinfos) with EWA_Zone, or in a determined volume specified in AppearArea.
  • FadeOutDistance: Default 0- 650; Rain is spawned in a cubic volume around the player. The particles spawned very close to the player are almost totally opaque; the particles at the limit of the volume are almost totally translucent. Between these two extremes, particles are more or less opaque depending on the distance between them and the player. These Min and Max settings decide the distance at which the particles start to become translucent (min) and are totally invisible (max).
  • LifeTime: Default, 0.4 - 0.7 : the lifetime of a single particle in seconds.
  • ParticleCount: Default, 250; how many particles are spawned.
  • ParticleColor: Default: all 0; Colours of the particles: X is Red, Y is Green and Z is Blue. You set mins and maxs to all in order to have several colours or several variations of one colour.
  • PartStyle: Default STY_Translucent: Style of particles. Like most sprites, it should mostly remain on Translucent, but Masked may be useful.
  • PartTextures: The texture used on sprites. You can add up to 8 different textures to spawn multiple different sprites.
  • Position: Default: X: -50;200, Y -200;200, Z -50;400: this is the series of parameters that determines the size of the cube around a player (see illustration).
  • Size: Default 0.15-0.2; The size of particles, 1 being the full size of the texture.
  • Speed: Default 300-500; The speed of particles. The default values are good for rain. You might want to slow it down dramatically for snow or dust.
  • WallHitEmitter: spawns the particles of another emitter on impact. See below.
  • WallHitEvent and WaterHitEvent: Default, HIT_DoNothing; behaviour of the particles when hitting solid surfaces or water. HIT_DoNothing does nothing : the particle goes through the object. HIT_Destroy kills the particle on impact. HIT_Bounce will make particle bounce... Which can be very fun when the WeatherEmitter is strongly inclined. Otherwise, the fact that particle keep the same speed while bouncing makes it useless to simulate raindrops bouncing in the floor or such effects. HIT_Script calls a scripted event you may have created.
  • WeatherType Default EWF_Rain: how are the particles moving, what type of behaviour is it trying to mimic: EWF_Rain will rain the particles down, and the particles will be perpendicular to the direction of the WeatherEmitter. EWF_Snow, once its speed is properly scaled down (say 30-50), sends particles slowly tumbling down with a slight swinging movement. EWF_Dust spawns particles with regular initial speed, but particles slow down until they reach total stilness. EWF_Neighter rains particles down much like EWF_Rain, but particles will always be facing the camera, not oriented accordingly to their velocity.

Note that no good texture for this effect does exist in stock Unreal packages. However, Rain textures can be as simples as a small white dash on a black background, which will give good result when made translucent and spawned to a nice speed (see DmRiot at the beginning of the page). Snow and Dust textures might be harder to create from scratch.

You can create interesting effects with WallHitEmitter. Its main use is for splashing effects for raindrops. By entering an emitter's tag in the WallHitEmitter field, each particle will spawn a particle of the target emitter on contact with walls or floors. If you use this effect on a large zone, make sure the source emitter has a high MaxParticles to limit the number of raindrops devoid of splash: think of this as stripping the target emitter of one of its particles to spawn it on the contact point: once too many particle shave been "stolen" from the target emitter, there is no longer anything to steal, and so remaining drops hitting the ground will not spawn anything. The source emitter itself will keep emitting its own particles: it will not be deactivated while its particles are spawned by the WeatherEmitter. It might be a good idea to put the source emitter in a distant and hidden part of the map.

This effect can kill a map's performances by more or less doubling the number of particles on the screen. Be careful.

Volumes Without Rain

Regardless of the AppearAreaType you are using, you might have problems with rain going through walls, ledges, ceilings, and so on. You can fix this by adding an XRainRestrictionVolume. This actor defines a volume inside which rain particles will not pass. It will block weather effects from all WeatherEmitters, but can be set to only affect one WeatherEmitter by matching its tag to the WeatherEmitter's tag. Its only interesting properties are BoundsMax and BoundsMin which define the minimum and maximum boundaries of the volume.

By setting the XRainRestrictionVolume actor's bDirectional property to true, the actor can be made directional, and rotated in any way you want, unlike the WeatherEmitter iself, whose emission volume is always pefectly perpendicular to the grid. This allows the use of volumes which are not aligned on the grid, while attempting to something like this by zoning out the wanted parts would result in a large number of zones with odd angles.