DOOM 3 : The guts of a rendering engine
Introduction Background Game Design Techniques Tradeoffs Problems and Solutions
Background Doom One of the most successful PC games of all time Kicked off First Person Shooter and Deathmatch games Visually stunning (at the time) Doom III Remake of DOOM using modern rendering technology Why do we care? Lots to learn One of the first games to really push modern rendering hardware Several interesting design choices and tradeoffs Id Software very open about technology It's one of the few non-radical games that we can talk knowledgeably about
Game design decisions You always need to look at your game design to pick the best mix or rendering features For Doom Mood : dark, scary Environment : Military base on Mars, Hell Game-play : FPS, with shades of survival horror, single-player focus Slower paced and fewer enemies than original What does that mean? Environment is constrained, few big vistas Also, few organic environments Some performance can be sacrificed for look Lighting is crucial for generating atmosphere
Game design decisions (cont'd) Example : Survival horror Want to be able to surprise player Why is that wall a different colour? problem Solution : Uniform surface rendering All models in game are rendered the same way Problems In most games, statics and dynamics are dealt with quite differently Need to select general purpose techniques Lightmaps great for statics, but awful for dynamics
Techniques Uses several important techniques that fit together well Stencil volume shadows Bump mapping Projected texture lights Pass per light Ignores other important techniques that are not a good fit Static lighting (light maps) Shadow buffers Projected texture shadows Height fields LOD Hardware vertex processing
Stencil volume shadows Draw extruded shadow volumes Use z-test, write to stencil buffer Advantages Consistent can apply to dynamics and statics Light maps don't work for dynamics Projected shadows don't work for statics Handles self shadowing Fully dynamic lighting at reasonable cost Disadvantages Requires relatively low polygon count models Lots of CPU vertex processing High fill rate requirement No soft shadows Can only shadow from one light
Bump mapping Store normal information for a surface in texture Advantages Adds lots of detail without adding polygons Fits well with stencil shadows, stencil shadows need low polygon counts, bump mapping fills in details Scalable Can be turned off with reasonable quality loss Disadvantages Burns texture memory, read bandwidth Needs sophisticated pixel processing Or lots of passes on older hardware Content generation is a real pain Can only handle one light
Projected texture lights Don't use standard directional/point/spot lights at all For each light define a projector frustum and texture Use projective UV co-ordinate generation to map onto surfaces
Projected texture lights (cont'd) Advantages Allows artists to shape light Flashlight beam Stained glass Can be used to fake certain effects that stencil shadows preclude Build soft/complex shadow into light Disadvantages Lights will appear on back of objects Not a problem with universal stencil shadowing Uses lots of texture read bandwidth Can only handle one light
Pass per light Bump mapping, stencil shadows and projected lights all have a big problem The can only deal with one light at a time Solution : Do a rendering pass for every light First Draw world into z-buffer Simplifies stencil processing to have opaque world in z-buffer first For each light Calculate shadow extrusions for all meshes for current light Render shadow volumes to stencil buffer Render each surface with stencil using current lights projected texture and sum to frame buffer Problem Lights become very expensive This is okay for a dark, moody world Problem
Other stuff In rendering pass for each light, other stuff can be layered on for glitz Specular Environment map Glow Etc.
Tradeoffs What these techniques get Extremely flexible lighting Consistent surface response High detail appearance inside polygons What they cost Need low polygon environments and objects Lots of CPU work on vertices No soft shadowing So it's good for dark, dramatically lit interior environment Surprise, surprise
Problems & solutions Problem : Lights get expensive Need to extrude shadow volumes for each light Need to render large shadow polygons for each light Solutions Need to determine occluding set for each light, as well as visible set for scene Minimise rendering cost associated with each light Discard meshes that are fully in shadow Minimise fill rate by using the Fill the z-buffer first trick Educate artists In FPS engines of the last five years, lights have been quite low cost, thanks to lightmaps Artists need to understand the costs associated with adding a light in a system like this
Problems & solutions (cont'd) Problem : Creating bump maps is a problem Building them by hand in very unintuitive Solution : Calculate them Build geometry at high resolution Use a tool to generate the bump map and a low resolution mesh from the geometry For characters, that's it For environments, generated bump map is then applied to world by level designer
Problems & solutions (cont'd) Many more How to manage decals Caching extruded shadow edges Accelerating some vertex operations with hardware Decomposing into multiple passes for older rendering hardware Etc.
Conclusions Consider game design issues when selecting rendering techniques Some techniques may compliment each other Don't be afraid to lose a feature that you don't really need to gain something else Zombies are scary