Contents

Acknowledgments

Introduction

Part I — Mathematical Prerequisites

Chapter 1    Vector Algebra

1.1 Vectors

1.1.1 Vectors and Coordinate Systems

1.1.2 Left-Handed Versus Right-Handed Coordinate Systems

1.1.3 Basic Vector Operations

1.2 Length and Unit Vectors

1.3 The Dot Product

1.4 The Cross Product

1.5 Points

1.6 D3DX Vectors

1.7 Summary

1.8 Exercises

Chapter 2    Matrix Algebra

2.1 Definition

2.2 Matrix Multiplication

2.2.1 Definition

2.2.2 Vector-Matrix Multiplication

2.2.3 Associativity

2.3 The Transpose of a Matrix

2.4 The Identity Matrix

2.5 The Inverse of a Matrix

2.6 D3DX Matrices

2.7 Summary

2.8 Exercises

Chapter 3    Transformations

3.1 Basic Transformations

3.1.1 Scaling

3.1.2 Rotation

3.1.3 Translation

3.2 D3DX Transformation Functions

3.3 Composition of Transformations

3.4 Change of Coordinate Transformations

3.4.1 Vectors

3.4.2 Points

3.4.3 Matrix Representation

3.4.4 Associativity and Change of Coordinate Matrices

3.4.5 Inverses and Change of Coordinate Matrices

3.5 Summary

3.6 Exercises

Part II — Direct3D Foundations

Chapter 4    Direct3D Initialization

4.1 Preliminaries

4.1.1 Direct3D Overview

4.1.2 COM

4.1.3 Textures and Data Resource Formats

4.1.4 The Swap Chain and Page Flipping

4.1.5 Depth Buffering

4.1.6 Texture Resource Views

4.1.7 Multisampling

4.2 Initializing Direct3D

4.2.1 Describe the Swap Chain

4.2.2 Create the Device and Swap Chain

4.2.3 Create the Render Target View

4.2.4 Create the Depth/Stencil Buffer and View

4.2.5 Bind the Views to the Output Merger Stage

4.2.6 Set the Viewport

4.3 Timing and Animation

4.3.1 The Performance Timer

4.3.2 Game Timer Class

4.3.3 Time Elapsed between Frames

4.3.4 Game Time

4.4 Text Output

4.5 The Demo Application Framework

4.5.1 D3DApp

4.5.2 Non-Framework Methods

4.5.3 Framework Methods

4.5.4 Frame Statistics

4.5.5 The Message Handler

4.5.6 Going Full Screen

4.5.7 The Init Direct3D Demo

4.6 Debugging Direct3D Applications

4.7 Summary

4.8 Exercises

Chapter 5    The Rendering Pipeline

5.1 The 3D Illusion

5.2 Model Representation

5.3 Basic Computer Color

5.3.1 Color Operations

5.3.2 128-Bit Color

5.3.3 32-Bit Color

5.4 Overview of the Rendering Pipeline

5.5 The Input Assembler Stage

5.5.1 Vertex Layouts

5.5.2 Vertex Buffers

5.5.3 Primitive Topology

5.5.3.1 Point List

5.5.3.2 Line Strip

5.5.3.3 Line List

5.5.3.4 Triangle Strip

5.5.3.5 Triangle List

5.5.3.6 Primitives with Adjacency

5.5.4 Indices and Index Buffers

5.6 The Vertex Shader Stage

5.6.1 Local Space and World Space

5.6.2 View Space

5.6.3 Projection and Homogeneous Clip Space

5.6.3.1 Defining a Frustum

5.6.3.2 Projecting Vertices

5.6.3.3 Normalized Device Coordinates (NDC)

5.6.3.4 Writing the Projection Equations with a Matrix

5.6.3.5 Normalized Depth Value

5.6.3.6 D3DXMatrixPerspectiveFovLH

5.6.4 Example Vertex Shader

5.6.5 Constant Buffers

5.7 The Geometry Shader Stage

5.8 The Clipping Stage

5.9 The Rasterization Stage

5.9.1 Viewport Transform

5.9.2 Backface Culling

5.9.3 Vertex Attribute Interpolation

5.10 The Pixel Shader Stage

5.11 The Output Merger Stage

5.12 Render States

5.13 Effects

5.13.1 Effect Files

5.13.2 Creating an Effect

5.13.3 Interfacing with Effects from the C++ Application

5.13.4 Using Effects to Draw

5.14 Colored Cube Demo

5.15 Peaks and Valleys Demo

5.16 Dynamic Vertex Buffers

5.17 Summary

5.18 Exercises

Chapter 6    Lighting

6.1 Light and Material Interaction

6.2 Normal Vectors

6.2.1 Computing Normal Vectors

6.2.2 Transforming Normal Vectors

6.3 Lambert’s Cosine Law

6.4 Diffuse Lighting

6.5 Ambient Lighting

6.6 Specular Lighting

6.7 Brief Recap

6.8 Parallel Lights

6.9 Point Lights

6.9.1 Attenuation

6.9.2 Range

6.10 Spotlights

6.11 Implementation

6.11.1 Lighting Structures

6.11.2 Implementing Parallel Lights

6.11.3 Implementing Point Lights

6.11.4 Implementing Spotlights

6.12 Lighting Demo

6.12.1 Effect File

6.12.2 Structure Packing

6.12.3 C++ Application Code

6.12.4 Normal Computation

6.13 Summary

6.14 Exercises

Chapter 7    Texturing

7.1 Texture and Resource Recap

7.2 Texture Coordinates

7.3 Creating and Enabling a Texture

7.4 Filters

7.4.1 Magnification

7.4.2 Minification

7.4.2.1 Creating Mipmaps

7.4.3 Anisotropic Filtering

7.5 Sampling Textures

7.6 Textures as Materials

7.7 Crate Demo

7.7.1 Specifying Texture Coordinates

7.7.2 Creating the Texture

7.7.3 Setting the Texture

7.7.4 Texture Effect

7.8 Address Modes

7.9 Transforming Textures

7.10 Land Tex Demo

7.10.1 Grid Texture Coordinate Generation

7.10.2 Texture Tiling

7.10.3 Texture Animation

7.11 Compressed Texture Formats

7.12 Summary

7.13 Exercises

Chapter 8    Blending

8.1 The Blending Equation

8.2 Blend Operations

8.3 Blend Factors

8.4 Blend State

8.5 Examples

8.5.1 No Color Write

8.5.2 Adding/Subtracting

8.5.3 Multiplying

8.5.4 Transparency

8.5.5 Blending and the Depth Buffer

8.6 Alpha Channels

8.7 Transparent Water Demo

8.8 Clipping Pixels

8.9 Fog

8.10 Summary

8.11 Exercises

Chapter 9    Stenciling

9.1 Depth/Stencil Formats and Clearing

9.2 The Stencil Test

9.3 The Depth/Stencil State Block

9.3.1 Depth Settings

9.3.2 Stencil Settings

9.3.3 Creating and Binding a Depth/Stencil State

9.3.4 Depth/Stencil States in Effect Files

9.4 Mirror Demo

9.4.1 Overview

9.4.2 Defining the Depth/Stencil States

9.4.3 Blending the Reflection

9.4.4 Drawing the Scene

9.5 Summary

9.6 Exercises

Chapter 10    The Geometry Shader

10.1 Programming Geometry Shaders

10.2 Tree Billboards Demo

10.2.1 Overview

10.2.2 Vertex Structure

10.2.3 Effect File

10.2.4 SV_PrimitiveID

10.3 Texture Arrays

10.3.1 Overview

10.3.2 Sampling a Texture Array

10.3.3 Loading Texture Arrays

10.3.4 Texture Subresources

10.4 Summary

10.5 Exercises

Part III — Direct3D Topics

Chapter 11    Cube Mapping

11.1 Cube Mapping

11.2 Environment Maps

11.2.1 Loading and Using Cube Maps in Direct3D

11.3 Texturing a Sky

11.4 Modeling Reflections

11.5 New Application Code

11.5.1 Texture Manager

11.5.2 Global Effects and Input Layouts

11.5.3 New 3D Object Classes

11.6 Summary

11.7 Exercises

Chapter 12    Normal Mapping

12.1 Motivation

12.2 Normal Maps

12.3 Texture/Tangent Space

12.4 Vertex Tangent Space

12.5 Transforming between Tangent Space and Object Space

12.6 Shader Code

12.7 Summary

12.8 Exercises

Chapter 13    Shadow Mapping

13.1 Render to Texture

13.1.1 Constructor/Destructor/Accessors

13.1.2 DrawableTex2D::init

13.1.3 DrawableTex2D::buildDepthMap

13.1.4 DrawableTex2D::buildColorMap

13.1.5 DrawableTex2D::begin

13.1.6 DrawableTex2D::end

13.2 Orthographic Projections

13.3 Projective Texture Coordinates

13.3.1 Code Implementation

13.3.2 Points Outside the Frustum

13.3.3 Orthographic Projections

13.4 Shadow Mapping

13.4.1 Algorithm Description

13.4.2 Building the Shadow Map

13.4.3 Restore Rendering to the Back Buffer

13.4.4 The Shadow Factor

13.4.5 The Shadow Map Test

13.4.6 Filtering and the Shadow Map Test

13.4.7 Rendering the Shadow Map

13.5 Summary

13.6 Exercises

Chapter 14    Meshes

14.1 ID3DX10MeshBuffer

14.2 Geometry Info

14.3 Subsets and the Attribute Buffer

14.4 Drawing

14.5 Adjacency Information

14.6 Optimizing

14.7 The Attribute Table

14.8 Cloning

14.9 Commit to Device

14.10 Creating a Mesh

14.11 Mesh Viewer Demo

14.12 Summary

14.13 Exercises

Chapter 15    Picking

15.1 Screen to Projection Window Transform

15.2 World/Local Space Picking Ray

15.3 Ray/Mesh Intersection

15.4 Bounding Volumes

15.4.1 Computing an Axis-Aligned Bounding Box

15.4.2 Rotations and Axis-Aligned Bounding Boxes

15.4.3 Computing a Bounding Sphere

15.4.4 Scaling and Bounding Spheres

15.5 Demo Application

15.6 Summary

15.7 Exercises

Chapter 16    Terrain Rendering

16.1 Heightmaps

16.1.1 Creating a Heightmap

16.1.2 Loading a RAW File

16.1.3 Smoothing

16.2 Texturing

16.3 Lighting

16.4 Terrain FX

16.5 Terrain Height

16.6 Summary

16.7 Exercises

Chapter 17    Particle Systems and Stream Output

17.1 Particle Representation

17.2 Particle Motion

17.3 Randomness

17.4 Blending and Particle Systems

17.5 Stream Output

17.5.1 Creating a Geometry Shader for Stream Output

17.5.2 Stream Output Only

17.5.3 Creating a Vertex Buffer for Stream Output

17.5.4 Binding to the SO Stage

17.5.5 Unbinding from the Stream Output Stage

17.5.6 Auto Draw

17.5.7 Ping-Ponging Vertex Buffers

17.6 GPU-Based Particle System

17.6.1 Particle Effects

17.6.2 The Particle System Class

17.6.3 Emitter Particles

17.6.4 The Initialization Vertex Buffer

17.6.5 The Update/Draw Method

17.7 Fire

17.8 Rain

17.9 Summary

17.10 Exercises

Appendices

Appendix A    Introduction to Windows Programming

A.1 Overview

A.1.1 Resources

A.1.2 Events, the Message Queue, Messages, and the Message Loop

A.1.3 GUI

A.1.4 Unicode

A.2 Basic Windows Application

A.3 Explaining the Basic Windows Application

A.3.1 Includes, Global Variables, and Prototypes

A.3.2 WinMain

A.3.3 WNDCLASS and Registration

A.3.4 Creating and Displaying the Window

A.3.5 The Message Loop

A.3.6 The Window Procedure

A.3.7 The MessageBox Function

A.4 A Better Message Loop

A.5 Summary

A.6 Exercises

Appendix B    High-Level Shading Language Reference

B.1 Variable Types

B.1.1 Scalar Types

B.1.2 Vector Types

B.1.2.1 Swizzles

B.1.3 Matrix Types

B.1.4 Arrays

B.1.5 Structures

B.1.6 The typedef Keyword

B.1.7 Variable Prefixes

B.1.8 Casting

B.2 Keywords and Operators

B.2.1 Keywords

B.2.2 Operators

B.3 Program Flow

B.4 Functions

B.4.1 User-Defined Functions

B.4.2 Built-in Functions

Appendix C    Some Analytic Geometry

C.1 Rays, Lines, and Segments

C.2 Parallelograms

C.3 Triangles

C.4 Planes

C.4.1 D3DXPlane

C.4.2 Point/Plane Spatial Relation

C.4.3 Construction

C.4.4 Normalizing a Plane

C.4.5 Transforming a Plane

C.4.6 Finding the Nearest Point on a Plane to a Given Point

C.4.7 Ray/Plane Intersection

C.4.8 Reflecting Vectors

C.4.9 Reflecting Points

C.4.10 Reflection Matrix

C.5 Exercises

Bibliography and Further Reading

Index

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.194.57