The water cycle is one of the first scientific concepts you learn about. Water evaporates from the surface of the Earth, rising, accumulating and condensing before returning to lakes and oceans in forms, such as rain, before beginning the process all over again. I don’t have to explain what rain is to you. You know rain. It’s a part of many of our daily lives, and among the most common stylistic elements in fiction. Considering its familiar nature, it’s surprising how little we know about how rain is created in videogames—and how widely these approaches can vary.
VFX artist Aaron Miller speaks to me about how Fireblade Software created the furious rainfall of naval roguelike Abandon Ship. “In Abandon Ship we wanted the weather to have a gameplay effect, which for rain was to extinguish fires. It also had to fall either straight down, or be at an angle depending on the strength of the wind.” The solution the team decided upon was to create ‘billboards’, or images of sheets of rain, in the distance of the player’s perspective, and reinforce the idea that rain is lashing your ship by spawning rain particles in cylinders attached to the game’s camera. This solution didn’t have the elusive measure of ‘thickness’ necessary to be a convincing extinguisher of in-game fires. So, Miller and company improvised. “We spawned an insanely high amount of rain particles, took screenshots of it into Photoshop, added this to the original texture and reimported it into the game. This resulted in it looking like thousands of rain particles were being spawned, when in fact it was only hundreds. This allowed us to achieve the desired result without it impacting the framerate,” Miller says. “Creating visual effects is often about taking a bunch of disparate systems and making them work in quirky ways to achieve the desired result.”
For 2D games, one of the most simple and common implementations of rain is to spawn particles above the screen, and once they reach the bottom of the screen, move them back to the top again. “For Airships: Conquer the Skies, I made a really basic 2D rain system,” says developer David Stark. “Each raindrop is a randomly placed vertical gray line. When it vanishes off the bottom of the screen, it gets moved back up to the top. There’s more intricate effects for other things, but for rain, this works fine.” The key, as always, is the end result, and how it contributes to the overall presentation of a game.
Coding in the rain
Attaching rain to musical cues or player actions brings an unexpected set of complications to even simple weather implementations, as James Earl Cox III found with his reflective 2D music art game Temporality. “The game only has two inputs: ‘D’ which moves the character forward through time, and ‘A’ which moves the character backwards. Without any input, time stands still … The rain system occurs during a childhood memory, and although a bit primitive, the rain needs to pause and play backward depending on the player’s input. The droplets spawn above screen, with random adjustments to their size, speed, and transparency, and fall below screen, where they’re deleted. When the player moves in reverse, the spawner creates them below the screen instead so they can fall up.”
Kas Ghobadi has made two separate systems for rain to date for their experimental musical adventure Stereophyta. The first used Unity’s default particle system to generate raindrops and elongate them as they fell. But only the second truly began to reach Ghobadi’s goals of having a wholly musical experience. “I wanted this version to be rhythmic,” Ghobadi says. “So in this version, a cloud moves in one of four directions when spawned and it receives messages from an audio clock. When it’s generated, it randomly picks a tempo to spawn raindrops at and does that its whole lifespan. Based on the speed of the tempo, it spawns either more or less rain. When they hit the ground, other particle systems appear to create a big splash effect. When players see the raindrops strike trees or plants, they cause music to play from them.”
Even in situations where rain is less impressive, a large amount of effort can still go into its creation. Daniel Fedor, lead developer of hardcore survival roguelike NEO Scavenger, sourced everything from precipitation, to cloud cover, to temperature rates over the winter and summer, from weather data compiled by the NOAA. He’s another developer in a long line, putting obsessive amounts of detail into something we’ll almost never recognise beyond white lines streaking across a screen.
Freelance engine programmer Amandine Coget on the ingredients of convincing rain.
Rain creates damp, reflective surfaces, like puddles or a trenchcoat’s ‘sheen’. The glossy edges and blurring needed to replicate this effect are expensive to calculate due to the need to ‘accumulate’ light from several angles.
When it rains and the sky darkens, the world has less light. Physically-based rendering now makes it easier to reuse assets under different lighting, but some previous approaches required textures to be radically changed!
So much code
Whether it’s raindrops, rain sheets, or splashes, VFX and particle systems require coding assistance. Code to calculate where the ground is so splashes are properly generated, layer raindrop effects in order, and so on.
Turning rain effects on and off can be easy, but having the world itself (from clothing to city streets) transition smoothly between degrees of wetness is far more difficult. The field’s still undergoing research.