Weeks before this last-minute scramble for fun, a decision was made that would nearly wreck the whole thing. Nobody knew it at the time, but it would have lasting repercussions. It wasn't even a big thing, really. It was just one small decision in a long line of them, this one about shadows.

Shadows perform multiple roles in a game like Defense Grid 2. The most obvious is that they add realism. In real life, big things like towers and trees cast shadows. So, in a video game, if those things aren't doing that, they look fake. More importantly to DG2, shadows also impart scale.

The towers in DG2 are designed to be huge, but the players are viewing them from a top-down perspective. In real life, when you're standing on a tall building and looking down, everything below will look small — even cars and trucks and other buildings. Flying high in an airplane, even the tall buildings look small. It's a matter of perspective.

DG2 is played from airplane level. So unless you zoom way in, everything on the level looks small. Even the towers. That's where shadows come in. Big trees cast shadows. Bigger towers cast bigger shadows. In DG2, the towers are supposed to be massive, rising high above the treetops. So they need massive shadows.

But shadows in video games are tricky things. They're mostly code, but since they impact the overall look of the game, they often need an artist's touch. That's where Lead Artist Lex Story comes in. Story wants to make sure that people are excited to play DG2 and that they are impressed with the visual awesomeness of the towers they're deploying to deal death to the enemies below.

"[If] people don't buy into it, that would suck for the experience," Story says. "And the experience is what I want to drive home. My job as a communicator is to drive home the fact that this is a world you completely understand; there's no questions about it. Have fun.

"I always tell people, I hate subtle. I don't want subtle. I want obvious. I want in your face. I want, 'Wow, I remember that one scene. That was really cool!' It's like when you watch a scene in a movie and it's super dramatic. Do you remember any of the other parts, or do you remember the super dramatic part when Gandalf comes out of the frickin' mountain going downhill and he shines his frickin' light and it blinds all the orcs?"

"I always tell people: I hate subtle. I don't want subtle. I want obvious. I want in your face. I want, 'Wow, I remember that one scene.'"

For DG2, Story's brand of awesome is for the player to be wowed by the sight of the towers rising from the ground and be awestruck by their sense of scale. That's why he needs (among other things) shadows. But right now the shadows he has aren't working. They float.

"When you're a player and you're zoomed in, it looks weird, because it looks like the trees are kind of floating," says Austin. "Shadows are there to ground trees. If the base of the tree is not touching the shadow, it just looks kind of wrong."

Austin is the executive producer on one of HPE's other games, Windborne, but he's consulting with the DG2 team because he's in charge of all of the technology for the entire company. And he wrote most of the engine the team is using, back several years ago, for a game that never came out.

In the real world, shadows are the absence of light. We say that shadows are "cast" but they're really the space where light isn't cast, because something (a tree) is standing between where the light is coming from (the sky), and what it is shining on (the ground).

In a video game shadows are created as a separate system from light, because the light is itself just another visual effect. It isn't real light; it's an illusion of light. Video game light doesn't cast shadows. It doesn't make things look brighter. It doesn't do anything, because it isn't anything. It's just a trick. Things look brighter in video games because those things are told, by computer code, to look brighter because, according to the math, those things are where "the light" would be shining on them. Game engines calculate where light would be coming from and where objects would be hit by it and then fake the result.

Austin on shadows and floating trees "There's a bunch of different ways to do shadows, and [developers] are constantly coming up with new cool ways. It used to be that the way you would do shadows is you would take the model and just create polygons that extended off of it in the direction of the light and look where they intersected geometry. Those were shadows. "But ... 10 years ago, as we created higher-polygon models, that became very expensive, and all the edges were always super hard, sharp edges. ... So what we do is we render the entire scene from the view of the light, and it's kind of like the light gets its own split screen view of what's going on in the scene. Then, when I'm rendering my scene, I'm looking in to see whether or not the light can see the point that I'm looking at. If it can't, then it's in shadow. If it can see the point I'm looking at, it's in light. "The next step on that is, well, we want fuzzy shadows, because shadows are not crisp, usually. They look a lot nicer if they're softer. You don't see the pixelation that's inherent in using lower resolution textures. So the thing that we were using in this case is called a variant shadow map. ... The way a variant shadow map works is ... a statistical thing. The mean and the mean squared. Through that, I can figure out what the average mean is and what the variance off that mean is and use that to accumulate ... to figure out what the shadows are. "It kind of sucks, but in computers, when you do math — floating point math — it's not exact. The equivalent is: If I do three times four, I'm going to get a number around 12, but it might be 11.995, or it might be 12.005. Normally, it doesn't matter, but in the case of anything that you're rendering into, you'll get kind of stair-stepping. It comes across as a moiré pattern. You'll get what we call shadow acne, where there are all these little dots around the shadow and it looks kind of ugly. The shadow comes in sharp, and then falls off and then comes in sharp and falls off. So we give a tolerance to avoid the shadow acne problem. "The epsilon [with the floating trees] was set way off. It was way too conservative and so the shadows were ... Basically, it was saying, 'When we're too close to the surface, we don't know for sure, so we'll just pretend like it's not shadowed.' "The reason why the epsilon was off is because it used to be we would do this thing called perspective variant shadow maps. We skew the buffer ... to try to match up with our buffer as much as possible, so we're using the full resolution for shadows. For the purposes of getting [DG2 ready for PAX], that part was turned off, and so the epsilons were different."

Shadows are created the same way, except by calculating where light wouldn't hit based on which objects would be in the way. The places in the game world where light wouldn't reach because of another object in the way are where shadows get placed, in the shape of those objects. It's similar to how it works in the real world, but the exact opposite. Shadows in games aren't the absence of light; they're the presence of shadow. It's another trick.

There are many techniques for doing this and making it look realistic. The technique DG2 uses creates shadows that go from solid and dense at the center to lighter and more diffused around the edges to simulate the fuzzy-edged look of real shadows. It looks natural, and it grants the objects in the game a sense of scale. But to make it work in the short time the team members had before PAX, they had to make one fateful decision that will come roaring back to bite them in the ass: They turned off "culling."

Culling is a method the game engine uses to determine what elements on the screen the player can't see, and then it decides not draw those things in order to save resources. If a player can't see a thing because it's blocked by something else, or is off screen, then there's no need to draw it. Why would there be? You can't see it. So those things a player can't see are "culled." Austin compares this to the door to a room down a hall beyond our line of sight. We know that door is there but we can't see it. In a video game, the team would "cull" that door, and simply not draw it until we could see it, saving precious GPU cycles and increasing the frame rate.

For whatever reason though, culling interferes with the way shadows work in DG2. Engineer Peter Freese recommends against turning culling off and instead working on an alternate way to draw shadows, but he's overruled. It's a small thing, in spite of that. There's plenty of GPU power to go around, and the PAX demo is just for PAX. The shadows can be fixed later. The demo will just have to get along without being culled.

Meanwhile, the shadows are creating a problem people can actually see, if they look closely enough. The shadows in DG2 are fuzzy and soft around all of the edges, including the bottoms where the shadows meet the trunks of the trees. This makes it look like the trees are floating, which is not great.

Unfortunately, they may not be able to fix this in time for PAX. The issue is put on the board for fixing before the game's release, and maybe before PAX, if there's time.

"When it's coming down to the line and you have a big list of things to do, a big task list, spending your time fuzzing out the leaf border of these shadows is maybe not where you should be spending your time," Austin says, laughing. "For the final game it's fine. But it's really easy ... We call it rabbit-holing. It's where you get so focused on the tree that you completely lose track of the forest. ... 'How far do we go on everything to get the best gestalt?' rather than 'How do I make this perfect?'"

The trees may just have to float. It's nearing five o'clock on Monday. For the DG2 team, the day will not end for another several hours. And then there will be only two days left before PAX. The shadows will be put aside and forgotten until Thursday, less than a day before the show starts.