Game Programming Gems 2
70 Articles, Edited by Mark DeLoura.
Survey of Lowest Known Online Prices
$51.06 (27% off) Amazon.com (free shipping)
$69.95 (0% off) BarnesAndNoble.com
Section 1: General Programming
Optimization for C++ Games
Inline Functions Versus Macros
Programming with Abstract Interfaces
Exporting C++ Classes from DLLs
Protect Yourself from DLL Hell and Missing OS Functions
A Property Class for Generic C++ Member Access
Adding Deprecation Facilities to C++
A Drop-in Debug Memory Manager
A Built-in Game Profiling Module
Linear Programming Model for Windows-based Games
File Management Using Resource Files
Game Input Recording and Playback
A Flexible Text Parsing System
Genuine Random Number Generation
Using Bloom Filters to Improve Computational Performance
3ds max Skin Exporter and Animation Toolkit
Using Web Cameras in Video Games
Section 2: Mathematics
Floating-Point Tricks: Improving Performance with IEEE Floating-Point
Fast, Robust Intersection of 3D Line Segments
Inverse Trajectory Determination
The Parallel Transport Frame
Smooth C2 Quaternion-based Flythrough Paths
Recursive Dimensional Clustering: A Fast Algorithm for Collison Detection
Section 3: Artificial Intelligence
Managing AI with Micro-Threads
Abstract: Presents code and concepts to create hundreds of low-overhead threads by manipulating the stack. This technique has notable benefits in terms of AI load balancing and the author has implemented the architecture on systems ranging from the PC to the GameBoy.
Micro-Threads for Game Object AI
Abstract: Fuzzy Logic provides an attractive alternative to more crisp forms of finite state decision making. This article builds on the presentation of the Finite-State Machine class from the first Game Programming Gems book, by introducing a generic Fuzzy-State Machine class in C++. The concepts of fuzzy logic are presented and an example of applicability for computer game AI is offered. The FSMclass and FSMstate classes from the first GEMS book are converted into fuzzy logic versions, and source code is provided for review.
A Generic Fuzzy State Machine in C++
Abstract: Neural networks are a powerful artificial intelligence technique that are based on an abstraction of the neurocomputational functions of the human brain. One of their most important characteristics is that they can learn by example, and do not need to be programmed in the conventional sense. For example, Codemasters (the developers of Colin McRae Rally 2.0) discovered that a neural network could learn how to drive a rally car by imitating the developers' play, thus avoiding the need to construct a complex set of rules. This article guides the reader through all the steps that are necessary to incorporate neural networks into their own game. Assuming no prior understanding, the article presents a case study of applying one of the most popular, easy to use, and effective neural networks, the multilayer perceptron, to a real game. All the steps required for successful neural network development are described, as are the most common problems, and their solutions. The CD that accompanies the book includes all the source code for the game, and the neural network class that lies at the heart of its AI. The class is designed to be used as a drop-in module in other games and hence contains no application specific code.
Using a Neural Network in a Game: A Concrete Example
A High-Performance Tile-based Line-of-Sight and Search System
Abstract: Explains the concept of Command Queuing in an RTS along with several ways to implement it. Command Queuing is the idea that the player should be able to queue up any sequence of command orders (Move, Attack, Patrol, Repair, etc) for a particular unit. Some commands that cycle, such as Patrol, present specific challanges in order to acheive the right behavior. Solutions to these difficulties are discussed along with detailed diagrams.
An Architecture for RTS Command Queuing
Abstract: Presents 11 strategies for optimizing AI, along with tips and examples for each.
Stratagies for Optimizing AI
1. Use event-driven behavior rather than polling.
2. Reduce redundant calculations.
3. Centralize cooperation with managers.
4. Run the AI less often.
5. Distribute the processing over several frames.
6. Employ level-of-detail AI.
7. Solve only part of the problem.
8. Do the hard work offline.
9. Use emergent behavior to avoid scripting.
10. Amortize query costs with continuous bookkeeping.
11. Rethink the problem.
Abstract: Influence mapping is a powerful and proven AI technique for reasoning about the world on a spatial level. Although influence maps are most often used in strategy games, they have many uses in other genres as well. Among other things, an influence map allows your AI to assess the major areas of control by different factions, precisely identify the boundary of control between opposing forces, identify "choke points" in the terrain, determine which areas require further exploration, and inform the base-construction AI systems to allow you to place buildings in the most appropriate locations.
Abstract: This article discusses two useful techniques for strategic decision-making. These are easiest to understand in the context of strategy game AI, but they have applications to other game genres as well. The resource allocation tree describes a data structure that allows an AI system to continuously compare its desired resource allocation to its actual current resources in order to determine what to build or purchase next. The dependency graph is a data structure that represents a game's "tech tree," and we discuss a number of ways that an AI can perform inference on the dependency graph in order to construct long-term strategic plans and perform human-like reasoning about what its opponents are attempting to accomplish.
Strategic Assessment Techniques
Terrain Reasoning for 3D Action Games
Flocking with Teeth: Predators and Prey
Expanded Geometry for Points-of-Visibility Pathfinding
Optimizing Points-of-Visibility Pathfinding
Imploding Combinatorial Explosion in a Fuzzy System
Section 4: Geometry Management
Abstract: View-Independent Progressive Meshing (VIPM) has moved from the status of an interesting research project, to promising new technology, to sensible addition to all the best engines, and now into the Direct3D graphics API itself. However, in an effort to push the performance of VIPM, and in particular to drive the hardware as efficiently as possible, several new forms have been developed, each with their own tradeoffs and characteristics. This article is intended as a guide to some of the more promising versions, and should help people decide which of the many variants to sue in particular situations.
Comparison of VIPM Methods
Abstract: This article proposes a simple method for interlocking tiles that requires a minimal amount of coding. The technique offers the benefits of dynamically adapting detail levels and animation flexibility. It does this while maintaining a data system that is perfectly suited for hardware transform and lighting.
Simplified Terrain Using Interlocking Tiles
Abstract: The article presents an algorithm and demonstration application that manages thousands of objects in motion that are continuously maintained as a collection of hierarchical bounding spheres in a SphereTree. The design goal for this algorithm has been to make the 99-percentile case spend almost no CPU time updating an object in motion within the tree structure. Queries against the SphereTree perform more tests than other data structures, but this is mitigated by the fact that the tree can be maintained using very little CPU time. This data structure is ideally suited for gross culling of massive numbers of moving objects in a large world space. It doesn't matter if the objects are moving at widely disparate speeds, or even if many of them are not in motion at all. It also has a very low cost when objects are inserted and removed from the tree with great frequency.
Sphere Trees for Fast Visibility Culling, Ray Tracing, and Range Searching
Abstract: The axis-aligned bounding box (AABB) tree structure has proven to be very useful for accelerating intersection queries on sets of geometry. The data structure is easy to implement, the built structure is numerically well conditioned, and like all binary trees, they have O(log n) search time. This article explains several techniques that can be used to lower the overall memory footprint of an AABB tree to 11 bytes per triangle.
Compressed Axis-Aligned Bounding Box Trees
Abstract: This article presents a general-purpose optimization for quadtree access that improves performance in three ways over the traditional implementations: 1) by eliminating node traversal and the unnecessary cache-misses it causes, 2) by requiring fewer instructions and CPU cycles overall vs. a best case traditional approach, and 3) by doing so in a compact amount of time and with minimal memory accesses regardless of what depth in the tree the target node resides in.
Direct Access Quadtree Lookup
Abstract: This article briefly explains a method for approximating the refraction effect seen when looking through the side of a fish tank. The majority of this article explains how to construct the transformation matrix that will be applied to the geometry inside the tank to simulate the refraction effect.
Approximating Fish Tank Refractions
Abstract: This article proposes a solution of breaking the task into rendering several smaller subimages. These subimages can then be pasted together to form a screen shot of arbitrary resolution. This article focuses on the projection matrix tricks required to do this seamlessly.
Rendering Print Resolution Screenshots
Abstract: This article presents a general method for applying a decal to an arbitrarily shaped surface and concurrently clipping the decal to the surface's boundary.
Applying Decals to Arbitrary Surfaces
Abstract: Rending distant scenery in 3D can be accomplished with skyboxes. This article explains the principle of skyboxing and describes alternative means for rendering a skyboxed scene.
Rendering Distant Scenery with Skyboxes
Abstract: This article presents a projective texture approach, which enables self-shadowing of convex subsections of characters in real time. After breaking the character into convex subsections, the subsections are rendered into a texture with varying alpha values from teh point of view of the light source. When the character is rendered from the viewer's point-of-view, this texture is projected back onto the convex subsegments of the character, simulating the occlusion of each subsegment with respect to the light source. Being map based rather than stencil-volume based, this technique requires no additional work to be compatible with higher-order surface tessellation techniques.
Abstract: This article will deal with the basic issues of controlling and animating a character from a third-person perspective. While it seems straightforward enough (just copy Super Mario 64), it's not as trivial as it first appears. There are many small nuggets of wisdom that can often take weeks of trial and error to discover.
Classic Super Mario 64 Third-Person Control and Animation
Section 5: Graphics Display
Abstract: Silhouette detection and rendering is a key component for adding a stylized look to 3D cartoon rendering. The basic concept of silhouette edge detection is to find the important edges that depict the outline of a model. Many cartoon animators illustrate these silhouettes by tracing a black outline around the borders of a model. This cartoon rendering article describes several silhouette edge detection techniques: an edge-based detection method, a programmable vertex shader technique, and an advanced texturing technique. The advantages and disadvantages of each technique are highlighted.
Cartoon Rendering: Real-time Silhouette Edge Detection and Rendering
Abstract: The techniques described in this article take advantage of modern real-time graphics capabilities, including texture mapping and programmable vertex shading. The basic idea is to simulate a limited color palette using textures. To do this, we modify the standard diffuse shading equation to create a highlight and shadow color, and use these colors to create a small texture map for each material to be used as a lookup table at runtime. Additionaly, these techniques require no additional markup information from the artist - this article describes the creation of the texture maps and texture coordinates for each material.
Cartoon Rendering Using Texture Mapping and Programmable Vertex Shaders
Abstract: This article presents several techniques that can be used to perform dynamic lighting effects on a per-pixel basis. These methods have the advantage that they don't require highly tessellated geometry, and can often be performed at little performance cost on multitexturing graphics hardware.
Dynamic Per-Pixel Lighting Techniques
Abstract: In this article, we'll set out to procedurally generate cloud textures that possess some of the properties that real clouds exhibit. In additon, because textures typically reside in graphics subsystem memory, we'll aim to generate the procedural clouds almost entirely using the graphics hardware. Finally, we'll address some ways to scale the technique's quality and performance requirements in order to accommodate a range of target machines.
Generating Procedural Clouds Using 3D Hardware
Abstract: This article introduces a novel way in which to generate texture information from pixels already rendered to the frame buffer. The technique can be used in several different ways, but is presented here as a solution to the common problem of occluded lens flare. Many games attempt to read back pixels generated in the frame buffer in order to determine exactly what was visible in the final scene. We will present a technique that works without CPU assistance, and does not require reading data from the graphics card. We will also outline the reasons why reading back information from the graphics card can be a costly operation and should be avoided if possible.
Texture Masking for Faster Lens Flare
Abstract: This article presents a set of techniques to improve the utility of "priority buffers". Along the way, we will explore other shadow techniques, and close by discussing how to create useful hybrid techniques.
Practical Priority Buffer Shadows
Abstract: Impostering is about using sprites in a 3D scene, but instead of an artist drawing or rendering the sprites beforehand, they are updated on the fly. Instead of rendering a high-triangle object every frame, the high-triangle object is occasionally rendered to a texture-usually on the order of once every 5 to 50 frames. This article presents Impostors and describes how to render them, create update heuristics, and use prediction to determine how to orient the impostor each time it is rendered.
Impostors: Adding Clutter
Abstract: This article covers a few fundamental operations for generating procedural animations, and puts these to use in specific examples that simulate fire, smoke, water, or perform image processing. With today's consumer hardware, we can even run complex cellular automata programs entirely within the rendering of a 3D accelerator and put the resulting animations to use in various effects.
Operations for Hardware-Accelerated Procedural Texture Animation
Section 6: Audio
Game Audio Design Patterns
A Technique to Instantaneously Reuse Voices in a Sample-based Synthesizer
Software-based DSP Effects
Interactive Processing Pipeline for Digital Audio
A Basic Music Sequencer for Games
An Interactive Music Sequencer for Games