[Guide/Snippets] setRain/rainParams: How to make snow, and other cool effects

Party-approved future science plus handbooks for the revolution
Post Reply
User avatar
Ciaran
Posts: 69
Joined: Thu Jul 21, 2016 9:36 pm
Location: Yorkshire, England

[Guide/Snippets] setRain/rainParams: How to make snow, and other cool effects

Post by Ciaran »

With Arma 2.08, it's now possible to edit the config of rain with setRain.

Using the syntax setRain rainParams, we can feed setRain an array, rainParams, containing parameters for how the rain looks and behaves.

Important note: In order for rain to work, overcast must be at least 0.5. This can be set using setOvercast.
You will also need to ensure it is raining using the primary setRain syntax. The below code is an example of what you need before you can start playing with rainParams:

Code: Select all

0 setOvercast 1; 
0 setRain 1; 
forceWeatherChange; //force applies the settings above instantly, to make sure
rainParams
As given on the biki, an example config for snow is:

Code: Select all

setRain [
	"a3\data_f\rainnormal_ca.paa",	// rainDropTexture
	1,	// texDropCount
	0.01,	// minRainDensity
	15,	// effectRadius
	0.1,	// windCoef
	2,	// dropSpeed
	0.5,	// rndSpeed
	0.5,	// rndDir
	0.02,	// dropWidth
	0.02,	// dropHeight
	[0.1,0.1,0.1,1],	// dropColor
	0.1,	// lumSunFront
	0.1,	// lumSunBack
	5.5,	// refractCoef
	0.3,	// refractSaturation
	true,	// snow
	false	// dropColorStrong
];
This isn't a very good config, but let's break down some of the key areas/nuances.
  • rainDropTexture is the texture used for the rain. This is a path that, in this example, is accessing Arma 3\Addons\data_f.pbo\rainnormal_ca.paa
    We can use a texture from the mission folder by using getMissionPath.
    It should be noted that the image is not read as a normal RGBA image - each channel is interpreted as a different channel in the game. Red becomes the alpha value, Green and Blue become the normals (how light is reflected at different angles) and Alpha becomes the colour value (though I'm yet to test exactly how this functions - see third example config below for a reasonable example).
  • texDropCount tells the engine how many particles are within your texture. This splits the image horizontally into chunks, then stretches each chunk to match the dropWidth/Height set later on. For example, if you set this to 2 with a square texture, it will cut the texture in half, and display each half on separate drops.
  • effectRadius is the radius within which the effect is displayed - however, it's not quite that simple. The number of particles on screen appears to be fixed, so increasing this radius will make the rain look less dense overall, and decreasing it will make it appear denser. 20m seems to be the sweet spot for snow - it's rendered just about far enough away that it doesn't look odd, but not so far that it lacks density.
  • rndSpeed and rndDir add some randomness to the speed and direction of the drops. For rain this would obviously be quite low. 0.5 seems good for snow.
  • dropWidth and dropHeight will likely need to be changed for each texture. For snow this should be square, for rain this should be much taller than it is wide to create the effect of it blurring through your vision.
  • dropColor sets the RGB colour and alpha of the particle. Again, this would need to be changed per texture. RGB values need to be set fairly high to take effect (double digits at least). For the most part you'll only need to play around with the 4th value, alpha. They're also heavily influenced by the lum and refract values, see the blood rain example below.
  • snow is used to tell the engine not to play the rain audio.
A basic explanation of each parameter can be found on the config reference for RainParticles.

Important note:
The config defined by rainParams will persist until set otherwise, even if rain is turned off and back on. setRain configNull will reset rain to default values.


Now the useful bit:
Example configs

I would recommend you set up a test in the editor and paste these snippets into the pause menu console to try them. Values even live update in the pause menu so you can A/B different settings.

Better snow:

Code: Select all

0 setFog 0.3;
0 setOvercast 1;
0 setRain 1;
forceWeatherChange;
setRain [
	"a3\data_f\Destruct\damage_Metal_MC.paa", // rainDropTexture
	1,	// texDropCount
	0.01,	// minRainDensity
	20,	// effectRadius
	0.25,	// windCoef
	2,	// dropSpeed
	0.5,	// rndSpeed
	0.5,	// rndDir
	0.06,	// dropWidth
	0.06,	// dropHeight
	[0.1,0.1,0.1,15],	// dropColor
	0.25,	// lumSunFront
	0.25,	// lumSunBack
	3.0,	// refractCoef
	0.3,	// refractSaturation
	true,	// snow
	false	// dropColorStrong
];
Start by adding some fog to make it feel more natural, then use a much better (notably not square) texture for the snowflakes. Some alternative textures that I tried were data_f\carflare_ca.paa and data_f\cl_fire.paa, but this one turned out the best IMO.
Note alpha in dropColor has to be set quite high to make the snowflakes fairly solid.
Preview.

Raining blood:

Code: Select all

0 setFog 0.2;
0 setOvercast 1;
0 setRain 1;
forceWeatherChange;
setRain [ 
	"a3\data_f\Destruct\damage_Metal_MC.paa", // rainDropTexture
	1, // texDropCount 
	0.01, // minRainDensity 
	30, // effectRadius 
	0.05, // windCoef 
	18, // dropSpeed 
	0.05, // rndSpeed 
	0.05, // rndDir 
	0.03, // dropWidth 
	1.5, // dropHeight 
	[50,0,0,10], // dropColor 
	0.0, // lumSunFront 
	0.0, // lumSunBack 
	0.1, // refractCoef 
	1.5, // refractSaturation 
	false, // snow 
	false // dropColorStrong 
];
Want those spooky Halloween vibes? Maybe you just want to haunt your players for those civilian deaths? Order blood rain today!
Preview.

Engine Unlimiter:

Code: Select all

setRain [ 
	getMissionPath "engineUnlimited.jpg", // rainDropTexture 
	1, // texDropCount 
	0.01, // minRainDensity 
	20, // effectRadius 
	0.1, // windCoef 
	2, // dropSpeed 
	0.25, // rndSpeed 
	0.25, // rndDir 
	0.05, // dropWidth
	0.05, // dropHeight 
	[70,70,70,1], // dropColor 
	0.05, // lumSunFront 
	0.05, // lumSunBack 
	0.0, // refractCoef 
	0.0, // refractSaturation 
	true, // snow 
	false // dropColorStrong 
];
Engine limitations getting you down? Unlimit your engine with this one simple trick! Uses a file placed in the mission folder named engineUnlimited.jpg.
While this works reasonably enough, if done properly, the image should be modified so the RGBA channels work as described earlier on. It will then need to be converted to a PAA (example file here) using the Arma 3 Tools so that the alpha layer is preserved (the game cannot load PNGs).
Preview with the original jpeg.
Preview with the modified paa image.

I think this just about covers it, but feel free to post more examples below if you find anything good.

Post Reply