Experienced Points

Experienced Points
Graphics Are Sometimes Hard

Shamus Young | 10 Feb 2015 15:00
Experienced Points - RSS 2.0
ExperiencedPoints 3x3

Time to answer some more reader questions. This time it's a bunch of questions about graphics:

Dear Shamus,

As I understand it, the bounding boxes or physical meshes or whatever is used are a lot more basic than what the graphics for those same objects look like. Why is this? Is it inherently harder to have high fidelity bounding boxes? Are they just blowing the hardware resource budget on visuals and leaving nothing for physics?

Ever a fan,

Wide and Nerdy

(Edited for length.)

There are a couple of similar-sounding concepts that we need to pull apart, here. For the uninitiated: We're talking about the sort of abstract notions that programmers use under the hood to drive the logic of the game. You'll never see a bounding box in a game, but they're used everywhere in 3D programming. (And in 2D, we use bounding rectangles. Same idea.)

A bounding box is the smallest cube that can contain the given geometry. So if there's a bounding box on a character's head, then the tip of their nose ought to touch the front of the box and the highest point on their head ought to touch the top. A hitbox is also an invisible cubic region, but in this case it represents the area that's checked for collision. In a shooter, you're not really shooting the bad guy in the head, you're shooting an invisible cube that envelops his head.

This means that your eyes won't always agree with the computer on whether or not a bullet should have hit. Maybe from the side the bullet should have passed just under their nose, but instead it scored a hit because it entered the hitbox. Or - if the hitbox is smaller so the nose isn't included - it might look like the bullet passed right through the nose without scoring a hit. Wide and Nerdy is asking why games don't take the time to check for a real hit instead of mucking about with these inaccurate cubes. This is a really interesting question, since this is something that we used to do, and have now abandoned. Back in the 90's, some of the shooters bragged about having "per pixel hit detection", which is not longer true of games today.

The reason we shoot cubes instead of properly checking to see if shots actually hit is threefold: First, it's just far easier to code. Basic collision detection isn't terribly hard to write (in a relative sense) but it still takes time and processing power. Unlike rendering, collision detection is a job for your CPU, not your graphics card. Graphics power is growing way faster than the general-processing power of the average gaming device. Which means the number of polygons in any given character is going up faster than processor speeds. Therefore high-definition hit detection gets more expensive and harder to do with each new graphics generation.

Secondly, there are concerns over game balance. If we do super-accurate hit detection, then anything that changes the shape of a character becomes a game balance issue. If the artists decide to give this guy a beard, we now have to run the design by a bunch of other people to see if the beard will make it too easy to hit the head, thus giving this particular character model a disadvantage.

And finally, it's just not that big a deal to most players. For the die-hard multiplayer shooter fans, they care about things being fair, and would rather everyone have the exact same hitbox than worry about whether or not having a big nose or sunglasses makes their head a bigger target. And for the rest of us, we generally don't notice. The consoles make up a majority of the market these days, and on consoles we have little bits of auto-aim going on. There's no reason to knock yourself out coding some super-sophisticated hitscan checking system that can tell the difference between shooting someone on the nose or under the nose, because on a console the auto-aim would turn that into a headshot anyway.

Per-pixel hit detection was a cool idea, but it's really only useful and practical on high-framerate, low-latency multiplayer shooters on the PC. And that's a pretty niche market.

Comments on