Improving Func_Precipitation

Recently, I played the map Hover Craftsman.  As with a few other maps, it used func_precipitation to add a rain effect.  Unlike later games such as Left 4 Dead, which had particle-based rain, the rain in Half-Life 2 is much more primitive and doesn’t look that great.  It falls in long, straight lines and it wasn’t something that occurred in any of the retail levels (although it is used in de_aztec).  As a result, it kind of looks like something out of the Nintendo 64 days.

I’ve found a few ways to improve the appearance of func_precipitation without having to change the texture or do any programming.  Func_precipitation has several cvars (console variables) you can adjust using a point_clientcommand entity.  Point_clientcommand is a way for you, the level designer, to issue commands to the console without the player noticing.  It’s most frequently used for ending levels and kicking the user back to the title screen, but it can also be used to adjust certain cvars on-the-fly.

My setup was like this:
  • A large func_precipitation brush with a Density setting of 100 and everything else left as default.
  • A point_clientcommand entity.
  • An env_wind.
  • A logic_auto.
The logic_auto will set up the rain at the start of the level using the output OnMapSpawn.  I changed 5 different cvars with the rain by sending the Command input to the point_clientcommand and the parameter overrides that follow.  Some of these I gleaned from the Valve Developer Wiki, while others were revealed in the Github code.
  • cl_winddir 1
    This causes the rain to react to an env_wind.  Env_wind is an entity a lot of people either don’t know about or forget to place.  It’s main ability is to add sideways motion to things like dustmotes, cables and, in this case, rain.  This gives the rain a natural diagonal motion instead of falling straight down.  You can adjust the wind and gust settings to change the intensity of this.
  • cl_windspeed 50
    This is a scalar (multiplier) for the wind, useful if you want the wind to affect the rain strongly, but not anything else.
  • r_rainalpha 0.2
    This adjusts how translucent the rain is.  By default, the rain is very opaque.  This softens the rain’s appearance considerably, making it almost invisible at time, much like real rain.
  • r_rainlength 0.05
    This changes how long each drop of rain is.  I personally thing that the default setting is much too long, so I shortened it by half (it defaults to 0.1).
  • r_RainSplashPercentage 0 (defaults to 20).
    Here’s an interesting undocumented thing – when rain hits a water surface, it can actually create its own splash effect.  Granted, this is pretty circumstantial, but it can be done.  In my case, I didn’t want this, so I set it to 0.  It defaults to 20, however, meaning that 20% of raindrops will create splashes.
Unlike some cvars, you don’t need to enter sv_cheats 1 to do these, so you can feel free to use them at any time.  Additionally, they are reset back to defaults the next time the player loads a level, so you don’t need to worry about this.

I hope these tips can help improve the appearance of your Half-Life 2 rain!