Friday, 13 July 2007

Beneath the Surface

It's E3 week which means that game devs get to release a few more scraps in order to appease fans and keep their games in the public consciousness. (Anticipation no less!)
Here's the first look at my single-player level and I'd be glad to share a few insider tidbits that I'm sure won't compromise my NDA :o)
We build the environments using polygons - meshes that are broken down into triangles.
These polygons are pretty dull, so we assign shaders to them. Shaders are like buckets of pictures and effects. The planks on the bridge, for example, comprise of a colour map (texture maps are projected or 'mapped' onto polygons) and a specular map (shininess) and a normal map which gives a faked 3D effect, lighting pixels such that they appear raised or indented according, in part, to the angle at which they're being viewed. Also in the shader, we assign material properties. In this way, the engine will respond with the correct effect when the polygons are shot at (so that wood chips fly off when wood is shot, and little clouds of dust puff up when dirt is shot at). Also, this property is used to discern the appropriate sound effects: so, for example, a player walking on a metal gangway will hear metallic footsteps.
The environment itself is static. However, we add props, and many of these are destructible and/or movable. Having built the bridge into the background, I then removed the railings into a discrete file. In addition to the undamaged railings, I broke up the geometry and created a replica of the railings from broken lengths of wood. When the railings are hit, the whole version is instantly replaced by the broken version, and pieces of wood explode apart. Each broken piece of wood is surrounded by an invisible physics object which is a cheap way of detecting collison, and from which the physics properties are determined: in this instance, I set the physics bodies to 'wood' so that the engine knows how these pieces should behave. Props are lit dynamically (so that the light behaves appropriately and the shadows move as they move), whereas the background has baked on light and shadows (called a lightmap).
You can see the hotel lobby in the background. I had to build this three times. These three instances are of different polygon counts and texture sizes and are called LODS (level of detail). In this way, when the player is a long way from the lobby, they will see just a handful of polygons on the horizon. In the pic above, the mid LOD is being drawn. LODS are triggered on and off as the player moves around the map, passing through invisible trigger boxes. As the player moves past the tiki bar, the lobby will be obscured from view; at that moment, they will trigger the change to the highest level of detail mesh so that, when they emerge at the top of the steps, the most detailed lobby is in place, ready for exploration.
All this is necessary in order to keep the visible poly counts below budget and keep the game running at a consistent 30 fps (min).
To this end, we also stream portions of the level in and out as the player moves around the map. Behind the lobby is a hotel courtyard and this is constructed from lots of hotel rooms. Whilst the player is in the pool area above, the courtyard has not been streamed in. However, I created 'dogleg' passageways between the lobby and the courtyard in which the lobby is dumped and the courtyard loaded in. These passageways obsure the view, and create points of no return so that everything behind can safely be discarded. Streaming in this way allows us to move away from loading times! (But it does create a lot of extra work for us artists. Boo.)
Hey, there's loads more in there, but much of it is utterly invisible to the player and only the effects are visible: collison walls create invisible boundaries; HDR settings create dynamic light-dark ranges that are location dependent; nav meshes and movement and defensive tokens are placed to aid the AI and make the NPCs (Non-Player Character) behave in an artificially intelligent and believable manner; portals and occluders control the visibility of various portions of the map; lightblockers hide seams and node naming conventions assign shattering glass properties ...
I guess, just like novels and icebergs, what we perceive is reliant on so much that we don't.

1 comment:

R1X said...

You are a wizard. Back 15 years ago when I was experimenting on my Amiga with the prog language Amos, my neighbour and I were having enough trouble just getting two sprites to interact - to register the boundary points of each other - let alone the trickery you now have to employ as games move closer and closer to realism... oh those halcyon days of 2D gaming :)