INTRODUCTION
Direct3D 11 is a rendering library for writing high performance 3D graphics applications using modern graphics hardware on the
Windows platform. (A modified version of DirectX 9 is used on the XBOX 360.) Direct3D is a low-level library in the sense that its
application programming interface (API) closely models the underlying graphics hardware it controls. The predominant consumer of
Direct3D is the games industry, where higher level rendering engines are built on top of Direct3D. However, other industries need high
performance interactive 3D graphics as well, such as medical and scientific visualization and architectural walkthrough. In addition,
with every new PC being equipped with a modern graphics card, non-3 D applications are beginning to take advantage of the GPU
(graphics processing unit) to offload work to the graphics card for intensive calculations; this is known as general purpose GPU
computing, and Direct3D 11 provides the compute shader API for writing general purpose GPU programs. Although Direct3D is
usually programmed from native C++, stable .NET wrappers exist for Direct3D (e.g., http://slimdx.org/) so that you can access this
powerful 3D graphics API from managed applications. Finally, at their 2011 BUILD conference ( http://www.buildwindows.com/),
Microsoft recently showed that Direct3D 11 will play the key role in writing high performance 3D "Metro" applications in Windows 8.
All-in-all, the future looks bright for Direct3D developers.
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, terrain rendering, picking, particle systems, environment mapping, normal mapping, displacement mapping, real-time shadows,
and ambient occlusion.
For the beginner, this book is best read front to back. The chapters have been organized so that the difficulty increases
progressively with each chapter. In this way, there are no sudden jumps in complexity leaving the reader lost. In general, for a
particular chapter, we will use the techniques and concepts previously developed. Therefore, it is important that you have mastered the
material of a chapter before continuing. Experienced readers can pick the chapters of interest.
Finally, you may be wondering what kinds of games you can develop after reading this book. The answer to that question is best
obtained by skimming through this book and seeing the types of applications that are developed. From that you should be able to
visualize the types of games that can be developed based on the techniques taught in this book and some of your own ingenuity.
INTENDED AUDIENCE
This book was designed with the following three audiences in mind:
1. Intermediate level C++ programmers who would like an introduction to 3D programming using the latest iteration of Direct3D.
2. 3D programmers experienced with an API other than DirectX (e.g., OpenGL) who would like an introduction to Direct3D 11.
3. Experienced Direct3D 9 and Direct3D 11 programmers wishing to learn the latest iteration of Direct3D.
PREREQUISITES
It should be emphasized that this is an introduction to Direct3D 11, shader programming, and 3D game programming; it is not an
introduction to general computer programming. The reader should satisfy the following prerequisites:
1. High School mathematics: algebra, trigonometry, and (mathematical) functions, for example.
2. Competent with Visual Studio: should know how to create projects, add files, and specify external libraries to link, for example.
3. Intermediate C++ and data structure skills: comfortable with pointers, arrays, operator overloading, linked lists, inheritance, and
polymorphism, for example.
4. 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 HARDWARE
To program Direct3D 11 applications, you will need the DirectX 11 SDK; the latest version can be downloaded from
http://msdn.microsoft.com/en-us/directx/ default.aspx. Once downloaded, follow the instructions given by the installation wizard. At the
time of this writing, the latest SDK version is the June 2010 DirectX SDK. All of our sample programs were written using Visual
Studio 2010.