Holiday 2012. I was seating on my couch with my laptop warming my legs, playing around with a very early version of Megaton Rainfall (although it wasn’t named at that time).
On screen I had a simulation of buildings collapsing depending on where you shoot them. It was looking fantastic. I remember thinking “Oh my god, this is cool”, and I decided I would finish this game (which involved quitting my job).
Like everyone else, I like Hollywood blockbusters with a lot of explosions. And there’s one thing explosions in films do well and games don’t.
Most explosions you see in games are not procedural, and do the following:
Let’s say a house receives a hit from an RPG and explodes. At the time of the explosion, they replace the “house” mesh by a “wrecked house”, and at the same time they add a particle effect (fire, smoke and debris). The problem is discontinuity.
You notice the cut, an abrupt change in the first frame of the explosion, so you don’t feel the house is what exploded. Besides, the “wrecked house” doesn’t have a hole in the exact location of the RPG (because it was modelled by an artist who didn’t know where it would come from).
A solution could be to have a “chopped house” in memory, partitioned in a myriad pieces, and on exploding, switch to that mesh and start only moving the pieces near the center of the explosion, but… What if the designer is a nonconformist and wants massive explosions of massive skyscrapers in massive cities 200 squared miles in size? That would exhaust memory in one fell swoop.
So here are the two ‘bright’ ideas that make all of this procedural destruction possible in Megaton Rainfall (and at 60 fps and with stereo rendering/VR).
(By the way, I wish I could send this blog to myself back in time, to 2012, it would have saved me a lot of failed experiments).
Idea 1: A snapshot of the building pre-explosion
First idea: at the time of the explosion, the engine takes a snapshot of the house as it’s seen from the camera. Yes, a snapshot, a bitmap.
Next it generates a particle effect that fills the space of the exploded area, and applies the snapshot to the particles as a texture. That means from the camera’s perspective, the first frame of the explosion seems exactly the same. Continuity achieved! You can follow every detail with your eyes during the explosion until it finishes. Besides, the particles are GPU-accelerated 2D billboards. The PS4 can handle bazillions easily. The feeling is phenomenal and no other game handles explosions this way AFAIK.
Idea 2: Have two versions of each building and switch between them quickly
Second idea: Given a building and the position of an explosion, how do we generate the wrecked version of the building, including thick inner walls?
The trick is to keep a “paper” version of the building (with walls with no thickness), that the player doesn’t see, and an “inflated version”, with thick walls, that’s displayed on screen. The engine has the feature to “inflate walls” of a “paper” mesh very fast. When a new explosion takes place, we discard the inflated version, we remove the triangles of the “paper” mesh near the explosion (updating the paper version), and we regenerate the inflated version based on the paper version.
Then we add fire, smoke, sparks, an expanding wave, unfortunate people caught in the explosion and furniture, and voila: a serving of procedural explosion. (However, you only see fire at night. That was an artistic decision. As for people caught in the explosion? You can only see them from a distance: I wanted to avoid a PEGI 18+.)
There are plenty of other types of explosions in the game, but this post has a word limit. But the gifs are not limited so here’s one more to sign off!