Introduction to 3D Game Programming with Direct3D 11.0

This page contains some general information about the book Introduction to 3D Game Programming with DirectX 11.0, published by Mercury Learning and Information, that will help you decide if this book is for you.

Supplement Files:
Source Code Set I
Source Code Set II
Source Code Set III
Appendix D Selected Solutions
All solutions for Chapter 1.
Direct3D 11 Book Demos with Windows 10 and Visual Studio 2015 Guide.
Direct3D 11 Book Demos with Windows 10 and Visual Studio 2015 Ported Blend Demo.

Quick Navigation


This book presents an introduction to programming interactive computer graphics, with an emphasis on game development, using Direct3D 11. It teaches the fundamentals of Direct3D and shader programming, after which the reader will be prepared to go on and learn more advanced techniques. The book is divided into three main parts. Part I explains the mathematical tools that will be used throughout this book. Part II shows how to implement fundamental tasks in Direct3D, such as initialization, defining 3D geometry, setting up cameras, creating vertex, pixel, geometry, and compute shaders, lighting, texturing, blending, stenciling, and tessellation. Part III is largely about applying Direct3D to implement a variety of interesting techniques and special effects, such as working with meshes, character animation, terrain rendering, picking, particle systems, environment mapping, normal mapping, displacement mapping, real-time shadows, and ambient occlusion.

Intended Audience

This book was designed with the following three audiences in mind:

  • Intermediate level C++ programmers who would like an introduction to 3D programming using the latest iteration of Direct3D.
  • 3D programmers experienced with an API other than DirectX (e.g., OpenGL) who would like an introduction to Direct3D 11.
  • Experienced Direct3D 9 and 10 programmers wishing to learn the latest iteration of Direct3D.


It should be emphasized that this is an introduction to Direct3D 11, shader programming, and game programming; it is not an introduction to general computer programming. The reader should satisfy the following prerequisites:

  • High School mathematics: algebra, trigonometry, and (mathematical) functions, for example.
  • Competent with Visual Studio: should know how to create projects, add files, and specify external libraries to link, for example.
  • Intermediate C++ and data structure skills: comfortable with pointers, arrays, operator overloading, linked lists, inheritance and polymorphism, for example.
  • Familiarity with Windows programming with the Win32 API is helpful, but not required; we provide a Win32 primer in Appendix A.

Required Development Tools and Recommended Hardware

To program Direct3D 11 applications, you will need the DirectX 11 SDK; the latest version can be downloaded here. Once downloaded, follow the instructions given by the installation wizard. The sample programs were written using Visual Studio 2010. Direct3D 11 requires Direct3D 11 capable hardware. The demos in this book were tested on a Geforce GTX 460.

Brief Table of Contents

  • Introduction
  • Part I Mathematical Prerequisites
    • Chapter 1 Vector Algebra
    • Chapter 2 Matrix Algebra
    • Chapter 3 Transformations
  • Part II Direct3D Foundations
    • Chapter 4 Direct3D Initialization
    • Chapter 5 The Rendering Pipeline
    • Chapter 6 Drawing in Direct3D
    • Chapter 7 Lighting
    • Chapter 8 Texturing
    • Chapter 9 Blending
    • Chapter 10 Stenciling
    • Chapter 11 The Geometry Shader
    • Chapter 12 The Compute Shader
    • Chapter 13 The Tessellation Stages
  • Part III Topics
    • Chapter 14 Building a First Person Camera
    • Chapter 15 Instancing and Frustum Culling
    • Chapter 16 Picking
    • Chapter 17 Cube Mapping
    • Chapter 18 Normal Mapping and Displacement Mapping
    • Chapter 19 Terrain Rendering
    • Chapter 20 Particle Systems and Stream-Out
    • Chapter 21 Shadow Mapping
    • Chapter 22 Ambient Occlusion
    • Chapter 23 Meshes
    • Chapter 24 Quaternions
    • Chapter 25 Character Animation
  • Appendix A Introduction to Windows Programming
  • Appendix B High Level Shader Language Reference
  • Appendix C Some Analytic Geometry
  • Appendix D Selected Solutions

Chapter Descriptions

Chapter 1, Vector Algebra: Vectors are, perhaps, the most fundamental mathematical objects used in computer games. We use vectors to represent positions, displacements, directions, velocities, and forces, for example. In this chapter, we study vectors and the operations used to manipulate them.
Chapter 2, Matrix Algebra: Matrices provide an efficient and compact way of representing transformations. In this chapter, we become familiar with matrices and the operations defined on them.
Chapter 3, Transformations: This chapter examines three fundamental geometric transformations: scaling, rotation, and translation. We use these transformations to manipulate 3D objects in space. In addition, we explain change of coordinate transformations, which are used to transform coordinates representing geometry from one coordinate system into another.
Chapter 4, Direct3D Initialization: In this chapter, we learn what Direct3D is about and how to initialize it in preparation for 3D drawing. Basic Direct3D topics are also introduced, such as surfaces, pixel formats, page flipping, depth buffering, and multisampling. We also learn how to measure time with the performance counter, which we use to compute the frames rendered per second. In addition, we give some tips on debugging Direct3D applications. We develop and use our own application framework--not the SDK's framework.
Chapter 5, The Rendering Pipeline: In this long chapter, we provide a thorough introduction to the rendering pipeline, which is the sequence of steps necessary to generate a 2D image of the world based on what the virtual camera sees. We learn how to define 3D worlds, control the virtual camera, and draw 3D scenes.
Chapter 6, Drawing in Direct3D: This chapter focuses on the Direct3D API interfaces and methods needed to configure the rendering pipeline, define vertex and pixel shaders, and submit geometry to the rendering pipeline for drawing. The effects framework is also introduced. By the end of this chapter, you will be able to draw grids, boxes, spheres and cylinders.
Chapter 7, Lighting: This chapter shows how to create light sources and define the interaction between light and surfaces via materials. In particular, we show how to implement directional lights, point lights, and spotlights with vertex and pixel shaders.
Chapter 8, Texturing: This chapter describes texture mapping, which is a technique used to increase the realism of the scene by mapping 2D image data onto a 3D primitive. For example, using texture mapping, we can model a brick wall by applying a 2D brick wall image onto a 3D rectangle. Other key texturing topics covered include texture tiling and animated texture transformations.
Chapter 9, Blending: In this chapter, we look at a technique called blending, which allows us to implement a number of special effects like transparency. In addition, we discuss the intrinsic clip function, which enables us to mask out certain parts of an image from showing up; this can be used to implement fences and gates, for example. We also show how to implement a fog effect.
Chapter 10, Stenciling: This chapter describes the stencil buffer, which, like a stencil, allows us to block pixels from being drawn. To illustrate the ideas of this chapter, we include a thorough discussion on implementing planar reflections using the stencil buffer. An exercise describes an algorithm for using the stencil buffer to render the depth complexity of a scene, and asks you to implement the algorithm.
Chapter 11, The Geometry Shader: This chapter shows how to program geometry shaders, which are special because they can create or destroy entire geometric primitives. Some applications include billboards, subdivisions, and particle systems. In addition, this chapter explains primitive IDs and texture arrays.
Chapter 12, The Compute Shader: The Compute Shader is a programmable shader Direct3D exposes that is not directly part of the rendering pipeline. It enables applications to use the graphics processing unit (GPU) for general purpose computation. For example, an imaging application can take advantage of the GPU to speed up image processing algorithms by implementing them with the compute shader. Because the Compute Shader is part of Direct3D, it reads from and writes to Direct3D resources, which enables us integrate results directly to the rendering pipeline. Therefore, in addition to general purpose computation, the compute shader is still applicable for 3D rendering.
Chapter 13, The Tessellation Stages: This chapter explores the tessellation stages of the rendering pipeline. Tessellation refers to subdividing geometry into smaller triangles and then offsetting the newly generated vertices in some way. The motivation to increase the triangle count is to add detail to the mesh. To illustrate the ideas of this chapter, we show how to tessellate a quad patch based on distance, and we show how to render cubic Bézier quad patch surfaces.
Chapter 14, Building a First Person Camera: In this chapter, we show how to design a camera system that behaves more as you would expect in a first person game. We show how to control the camera via keyboard and mouse input.
Chapter 15, Instancing and Frustum Culling: Instancing is a hardware supported technique that optimizes the drawing of the same geometry multiple times with different properties (say at different positions in the scene and with different colors). Frustum culling is an optimization technique where we discard an entire object from being submitted to the rendering pipeline if it lies completely outside the virtual camera’s field of view. We also show how to compute the bounding box and sphere of a mesh.
Chapter 16, Picking: This chapter shows how to determine the particular 3D object (or 3D primitive) that the user has selected with the mouse. Picking is often a necessity in 3D games and applications where the user interacts with the 3D world with the mouse. We also show how to compute the bounding box and sphere of a mesh.
Chapter 17, Cube Mapping: In this chapter, we show how to reflect environments onto arbitrary meshes with environment mapping; in addition, we use an environment map to texture a sky-sphere.
Chapter 18, Normal Mapping and DisplacementMapping: This chapter shows how to get detailed real-time lighting results using normal maps. In addition, we show how to combine tessellation with displacement maps to increase the geometry detail of our objects.
Chapter 19, Terrain Rendering: This chapter shows how to create, texture, light, and render 3D terrains using heightmaps and a multi-texturing technique. Furthermore, we show how to smoothly "walk" the camera over the terrain.
Chapter 20, Particle Systems: In this chapter, we learn how to model systems that consist of many small particles that all behave in a similar manner. For example, particle systems can be used to model falling snow and rain, fire and smoke, rocket trails, sprinklers, and fountains.
Chapter 21, Shadow Mapping: Shadow mapping is a real-time shadowing technique, which shadows arbitrary geometry (it is not limited to planar shadows). In addition, we learn how to render to a texture, and how projective texturing works.
Chapter 22, Ambient Occlusion: Lighting plays an important role in making our scenes look realistic. In this chapter, we improve the ambient term of our lighting equation by estimating how occluded a point in our scene is from incoming light. We cover both static mesh and real-time screen space methods.
Chapter 23, Meshes: This chapter shows how to load complex models from files and shows how to design a simple set of classes for working with meshes.
Chapter 24, Quaternions: In this chapter, we study mathematical objects called quaternions. We show that unit quaternions represent rotations and can be interpolated in a simple way, thereby giving us a way to interpolate rotations. Once we can interpolate rotations, we can create 3D animations.
Chapter 25, Character Animation: This chapter extends the “Meshes” chapter by loading complicated models from file, but with animation data. We cover the theory of character animation and show how to animate a typical human game character with a complex walking animation.