Content area
Full Text
YOU KNOW AS WELL AS I THAT GAME players love to wreak havoc on their game worlds. One common effect in video games is showing damage being applied to walls and other surfaces when players (or NPCs) shoot them. Physical destruction, as an ingame effect, makes players feel like they are actually interacting with their environment, making the simple act of shooting a wall somewhat satisfying.
In an ideal situation, the player shoots the wall and chunks of it fly off, leaving actual holes in the wall. Eventually, the wall would be chipped away completely, falling to rubble before the player's very eyes. Unfortunately implementing such a general-purpose solution is highly complex and expensive, since it requires the creation of arbitrary amounts of new geometry and possibly textures.
A more common technique is to apply a decal to the wall. A decal is a twodimensional image of some damage, such as a bullet hole, that's pasted in some way over the surface of the environment geometry. Decals are also used for other in-game, player-created modifications to the world, such as graffiti and blood spatters.
DECALS AND BULLET HOLES DON'T MIX
There are several ways to implement decals. One is to create a new quad that's aligned with the wall surface, with the decal texture face mapped to the quad. In another method, you could make a copy of a section of the wall geometry and position the decal by adjusting its UV coordinates. Or, you could apply the decal as an additional rendering pass on the original geometry.
Each of these methods has its pros and cons, and the one you choose will depend on what you generally use decals for. For bullet holes, we want to allow an arbitrary number of holes per mesh, since you will want to splay bullets all over it. In this case, it's probably best to create a new quad for each new bullet hole.
The problem with decals is that they are 20, and while 2D works fine for graffiti and blood splats, bullet holes have depth, so a flat image is less than convincing. A solution worth investigating is to use a pixel shader technique called parallax mapping to give the illusion of depth to a 2D...