Advanced 3D game programming with DirectX / by Peter Walsh. p. cm. Includes index. ISBN ISBN 1. Computer. Advanced 3D Game Programming with DirectX (Wordware Game and Graphics Library) · Read more · 3D Game Programming for Teens. Read more. Introduction to 3D Game Programming with DirectX ® 10 Introduction to 3D These samples are fairly advanced for a beginning graphics programmer, but by .

Advanced 3d Game Programming With Directx 10.0 Pdf

Language:English, Arabic, Hindi
Published (Last):03.01.2016
ePub File Size:24.88 MB
PDF File Size:11.58 MB
Distribution:Free* [*Registration needed]
Uploaded by: FRAN

Frank D. Luna. Introduction to 3D GAME PROGRAMMING WITH DIRECTX 11 .. These samples are fairly advanced for a beginning graphics programmer, but by the Note that we mentioned both the Direct3D 10 and Direct3D 11 samples. Get Free Read & Download Files Advanced 3d Game Programming With Directx 10 0 Wordware Game And Graphics Library PDF. ADVANCED 3D GAME. Advanced 3D Game Programming With Directx (Wordware Game and Graphics Library) [Peter Walsh] on *FREE* shipping on qualifying.

Particle Systems and Stream-Out. Shadow Mapping. Ambient Occlusion. Character Animation. Introduction to Windows Programming. High-Level Shading Language Reference. Some Analytic Geometry. Selected solutions. Finally, you may be wondering what kinds of games you can create 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: The reader should satisfy the following prerequisites: Once downloaded, follow the instructions given by the installation wizard. Direct3D 10 requires Direct3D capable hardware. Step-by-step instructions for setting up a Direct3D 10 project in Visual Studio. NET and Visual Studio. This library provides a set of functions, classes, and interfaces that simplify common 3D graphics-related operations, such as math operations, texture and image operations, mesh operations, and shader operations e.

That is to say, D3DX contains many features that would be a chore to implement on your own. We use the D3DX library throughout this book because it allows us to focus on more interesting material.

In other words, D3DX makes us more productive and lets us focus more on actual content rather than spending time reinventing the wheel.

Other reasons to use D3DX: Consequently, whether you choose to use D3DX or not, you should become familiar with it so that you can read code that uses it. Furthermore, it becomes more improved and feature rich with each iteration of DirectX.

Therefore, to obtain extended information it is imperative that you learn how to use the DirectX SDK documentation. In particular, you will want to navigate to the Direct3D 10 section see Figure 1.

However, it does get better and better with every new DirectX version released. As said, the documentation is primarily useful as a reference.

Suppose you come across a DirectX-related type or function, such as the function D3DXMatrixInverse, for which you would like more information. You simply do a search in the documentation index and you get a description of the object type or, in this case, function, as shown in Figure 2. Index of the DirectX documentation. In this book we may direct you to the documentation for further details from time to time.

These tutorials roughly correspond to some of the topics in the first part of this book. We recommend that you study these tutorials at the same time you read through the first part of this book so that you can get alternative explanations and examples.

Each sample illustrates how to implement a particular effect in Direct3D. These samples are fairly advanced for a beginning graphics programmer, but by the end of this book you should be ready to study them. Thus, many of the samples may be implemented inefficiently. Keep this in mind if you are using any of the sample code in your own projects, as you may wish to rework it for better efficiency.

Sample Programs and Online Supplements The website for this book www. On the website you will find the complete source code and project files for every sample in this book. In many cases, DirectX programs are too large to fully embed in a textbook; therefore, we only embed relevant code fragments based on the ideas being shown. It is highly recommended that the reader study the corresponding demo code to see the program in its entirety.

We have aimed to make the demos small and focused for easy study. In fact, a good exercise is trying to implement the samples on your own using the book and sample code as a reference. In addition to sample programs, the website also contains a message board. We encourage readers to communicate with each other and post questions on topics they do not understand or need clarification on.

In many cases, getting alternative perspectives and explanations to a concept shortens the time it takes to comprehend it. And lastly, additional program samples and tutorials may be added to the website on topics that we could not fit into this book for one reason or another. Thus the problem of how to convey a world to a computer arises. The answer is to describe our worlds, and the interactions therein, completely mathematically.

Consequently, mathematics plays a fundamental role in video game development. In this prerequisites part, we introduce the mathematical tools that will be used throughout this book.

The emphasis is on vectors, coordinate systems, matrices, and transformations, as these tools are used in just about every sample program of this book. In addition to the mathematical explanations, a survey and demonstration of the relevant classes and functions from the D3DX math library are provided.

(PDF Download) Delphi Graphics And Game Programming Exposed! With DirectX by Ayres John (2000)

Note that the topics covered here are only those essential to understanding the rest of this book; it is by no means a comprehensive treatment of video game mathematics, as entire books are devoted to this topic. For readers desiring a more complete reference to video game mathematics, we recommend [Verth04] and [Lengyel02].

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.

In this chapter, we become familiar with matrices and the operations defined on them. 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 1 Vector Algebra Vectors play a crucial role in computer graphics, collision detection, and physical simulation, all of which are common components in modern video games. We emphasize the importance of vectors by noting that they are used in just about every demo program in this book. Quantities that possess both magnitude and direction are called vectorvalued quantities. Examples of vector-valued quantities are forces a force is applied in a particular direction with a certain strength — magnitude , displacements the net direction and distance a particle moved , and velocities speed and direction.

Thus, vectors are used to represent forces, displacements, and velocities. We also use vectors to specify pure directions, such as the direction the player is looking in a 3D game, the direction a polygon is facing, the direction in which a ray of light travels, or the direction in which a ray of light reflects off a surface.

A first step in characterizing a vector mathematically is geometrically: We graphically specify a vector by a directed line segment see Figure 1. We note that the location in which we draw a vector is immaterial because changing the location does not change the 3 4 Part I: Mathematical Prerequisites magnitude or direction the two properties a vector possesses. That is, we say two vectors are equal if and only if they have the same length and they point in the same direction.

Thus, the vectors u and v drawn in Figure 1. In fact, because location is unimportant for vectors, we can always translate a vector without changing its meaning since a translation changes neither length nor direction. Observe that we could translate u such that it completely overlaps with v and conversely , thereby making them indistinguishable — hence their equality.

As a physical example, the vectors u and v in Figure 1. The vectors themselves are independent of position; they simply instruct the ants how to move from where they are. In this example, they tell the ants to move north direction ten meters length. Figure 1. However, since the computer cannot work with vectors geometrically, we need to find a way of specifying vectors numerically instead.

So what we do is introduce a 3D coordinate system in space, and translate all the vectors so that their tails coincide with the origin Figure 1. Now we can represent a vector with three floats in a computer program. Chapter 1: Vector Algebra 5 Figure 1. We translate v so that its tail coincides with the origin of the coordinate system. A vector specified by coordinates relative to a coordinate system. Consider Figure 1. Note that we use the terms frame, frame of reference, space, and coordinate system to mean the same thing in this book.

We can translate v so that it is in standard position in either of the two frames.

Observe, however, that the coordinates of the vector v relative to frame A are different from the coordinates of the vector v relative to frame B. In other words, the same vector has a different coordinate representation for distinct frames. The same vector v has different coordinates when described relative to different frames. The idea is analogous to, say, temperature. The physical temperature of boiling water is the same no matter the scale i. Similarly, for a vector, its direction and magnitude, which are embedded in the directed line segment, does not change; only the coordinates of it change based on the frame of reference we use to describe it.

This is important because it means whenever we identify a vector by 6 Part I: Mathematical Prerequisites coordinates, those coordinates are relative to some frame of reference. Often in 3D computer graphics we will utilize more than one frame of reference and, therefore, will need to keep track of which frame the coordinates of a vector are described relative to; additionally, we will need to know how to convert vector coordinates from one frame to another.

We see that both vectors and points can be described by coordinates x, y, z relative to a frame.

However, they are not the same; a point represents a location in 3-space, whereas a vector represents a magnitude and direction. If you take your left hand and aim your fingers down the positive x-axis, and then curl your fingers toward the positive y-axis, your thumb points roughly in the direction of the positive z-axis. On the left we have a left-handed coordinate system. Observe that the positive z-axis goes into the page.

On the right we have a right-handed coordinate system. Observe that the positive z-axis comes out of the page. Observe that for the right-handed coordinate system, if you take your right hand and aim your fingers down the positive x-axis, and then curl your fingers toward the positive y-axis, your thumb points roughly in the direction of the positive z-axis. Vector Algebra n n 7 We can multiply a scalar i. This is called scalar multiplication. We define subtraction in terms of vector addition and scalar multiplication.

Example 1. The difference in the third line illustrates a special vector, called the zero-vector, which has zeros for all of its components and is denoted by 0. The ideas are the same as in 3D; we just work with one less component in 2D. How do v and -1 2v compare geometrically? Graphing both v and -1 2v Figure 1.

We parallel translate u so that its tail coincides with the head of v. Then, the sum is the vector originating at the tail of v and ending at the head of u. We get the same result if we keep u fixed and translate v so that its tail coincides with the head of u. Observe also that our rules of vector addition agree with what we would intuitively expect to happen physically when we add forces together to produce a net force: If we add two forces vectors in the same direction, we get another stronger force longer vector in that direction.

If we add two forces vectors in opposition to each other, then we get a weaker net force shorter vector. Essentially, the difference v—u gives us a vector aimed from the head of u to the head of v.

If we instead interpret u and v as points, then v — u gives us a 8 Part I: Mathematical Prerequisites vector aimed from the point u to the point v; this interpretation is important as we will often want the vector aimed from one point to another. Observe also that the length of v — u is the distance from u to v, when thinking of u and v as points.

Forces applied to a ball. The forces are combined using vector addition to get a net force. We denote the magnitude of a vector by double vertical bars e. The magnitude of a 3D vector can be computed by applying the Pythagorean theorem twice; see Figure 1.

The 3D length of a vector can be computed by applying the Pythagorean theorem twice. Vector Algebra First, we look at the triangle in the xz-plane with sides x, z, and hypotenuse a. Now look at the triangle with sides a, y, and hypotenuse u. From the Pythagorean theorem again, we arrive at the following magnitude formula: For such directiononly vectors, we want the length of the vector to be exactly one.

When we make a vector unit length, we say that we are normalizing the vector. We can normalize a vector by dividing each of its components by its magnitude: Mathematical Prerequisites In words, the dot product is the sum of the products of the corresponding components.

The dot product definition does not present an obvious geometric meaning. So, Equation 1. Equation 1.

On the left, the angle q between u and v is an acute angle. On the right, the angle q between u and v is an obtuse angle. Find the angle between u and v. First we make the following computations: Vector Algebra 11 Now, applying Equation 1.

Given v and the unit vector n, find a formula for p using the dot product. The orthogonal projection of v on n. Note that k may be negative if and only if p and n aim in opposite directions. However, because n is a unit vector, we can say this in another way: Mathematical Prerequisites If n is not of unit length, we can always normalize it first to make it unit length.

Replacing n by the unit vector nn gives us the more general projection formula: Unlike the dot product, which evaluates to a scalar, the cross product evaluates to another vector; moreover, the cross product is only defined for 3D vectors in particular, there is no 2D cross product.

Taking the cross product of two 3D vectors u and v yields another vector, w that is mutually orthogonal to u and v. By that we mean w is orthogonal to u, and w is orthogonal to v see Figure 1. The cross product of two 3D vectors, u and v, yields another vector, w, that is mutually orthogonal to u and v. Applying Equation 1.

Vector Algebra 13 This result makes one thing clear, generally speaking: Therefore, we say that the cross product is anti-commutative. You can determine the vector returned by the cross product by the left-hand-thumb rule.

If you curve the fingers of your left hand from the direction of the first vector toward the second vector always take the path with the smallest angle , your thumb points in the direction of the returned vector, as shown in Figure 1.

However, we will also need to specify positions in our 3D programs; for example, the position of 3D geometry and the position of the 3D virtual camera.

Relative to a coordinate system, we can use a vector in standard position see Figure 1. In this case, the location of the tip of the vector is the characteristic of interest, not the direction or magnitude.

Follow the Author

The position vector, which extends from the origin to the point, fully describes the location of the point relative to the coordinate system. One side effect of using vectors to represent points, especially in code, is that we can do vector operations that do not make sense for points; for instance, geometrically, what should the sum of two points mean? On the other hand, some operations can be extended to points. For example, we define the difference of two points q — p to be the vector from p to q.

Also, we define a point p plus a vector v to be the point q obtained by displacing p 14 Part I: Mathematical Prerequisites by the vector v. Conveniently, because we are using vectors to represent points relative to a coordinate system, no extra work needs to be done for the point operations just discussed as the vector algebra framework already takes care of them see Figure 1.

The Following 13 Users Say Thank You to aanthonyz For This Useful Post:

Actually there is a geometrically meaningful way to define a special sum of points, called an affine combination, which is like a weighted average of points. However, we do not use this concept in this book. Its class definition is: In addition to the above class, the D3DX library includes the following useful vector-related functions: Mathematical Prerequisites Note: Remember to link the d3dx Output for the above program.

When comparing floating-point numbers, care must be taken due to floating-point imprecision. Two floating-point numbers that we expect to be equal may differ slightly. The following short program illustrates these ideas: Is it numerically? Mathematical Prerequisites cout Figure 1. To compensate for floating-point imprecision, we test if two floating-point numbers are approximately equal. Geometrically, we represent a vector with a directed line segment.

A vector is in standard position when it is translated parallel to itself so that its tail coincides with the origin of the coordinate system. A vector in standard position can be described numerically by specifying the coordinates of its head relative to a coordinate system.

Vector Algebra Length: This class contains three float data members for representing the x-, y-, and z-coordinates of a vector relative to some coordinate system. Moreover, the D3DX library provides the following useful functions for computing the length of a vector, the squared length of a vector, the dot product of two vectors, the cross product of two vectors, and normalizing a vector: Perform the following computations and draw the vectors relative to a 2D coordinate system: Perform the following computations: This exercise shows that vector algebra shares many of the nice properties of real numbers this is not an exhaustive list.

Also assume that c and k are scalars. Prove the following vector properties: Mathematical Prerequisites c. Just use the definition of the vector operations and the properties of real numbers. Normalize u and v. Is the angle between u and v orthogonal, acute, or obtuse?

Find the angle q between u and v. Also let c and k be scalars. Prove the following dot properties: Vector Algebra Also, draw the vectors relative to a 2D coordinate system. Let the following points define a triangle relative to some coordinate system: Find a vector orthogonal to this triangle. Parallelogram spanned by two 3D vectors u and v; the parallelogram has base v and height h.

This shows the cross product is generally not associative. Just use the cross product definition. Mathematical Prerequisites We will later use 2D vectors to describe 2D points on texture maps. The purpose of 4D vectors will make more sense after reading the next chapter when we discuss homogeneous coordinates.

Note that there is no 2D cross product function, so you can skip that. Chapter 2 Matrix Algebra In 3D computer graphics, we use matrices to compactly describe geometric transformations such as scaling, rotation, and translation, and also to change the coordinates of a point or vector from one frame to another. This chapter explores the mathematics of matrices. The product of the number of rows and columns gives the dimensions of the matrix.

The numbers in a matrix are called elements or entries. We identify a matrix element by specifying the row and column of the element using a double subscript notation Mij, where the first subscript identifies the row and the second subscript identifies the column.

Mathematical Prerequisites Example 2. We identify the element in the second row and first column of matrix B by B Matrices u and v are special matrices in the sense that they contain a single row or column, respectively. We sometimes call these kinds of matrices row vectors or column vectors because they are used to represent a vector in matrix form e.

Observe that for row and column vectors, it is unnecessary to use a double subscript to denote the elements of the matrix — we only need one subscript. Occasionally we like to think of the rows of a matrix as vectors. For example, we might write: Likewise, we can do the same thing for the columns: We now define equality, addition, scalar multiplication, and subtraction on matrices: Example 2. We will see in Chapter 3 that matrix multiplication is used to transform points and vectors and to concatenate transformations.

If these dimensions did not match, then the dot product in Equation 2. In particular, we cannot take the dot product of the first row vector in A with the first column vector in B because we cannot take the dot product of a 2D vector with a 3D vector.

Applying Equation 2. Chapter 2: Matrix Algebra 27 2. Now, applying Equation 2. For example, matrix multiplication distributes over addition: In particular, however, we will use the associative law of matrix multiplication from time to time, which allows us to choose the order in which we multiply matrices: Mathematical Prerequisites 2.

We denote the transpose of a matrix M as MT. The identity matrix is a square matrix that has zeros for all elements except along the main diagonal; the elements along the main diagonal are all ones. The identity matrix can be thought of as the number 1 for matrices. In particular, if M is a square matrix, then multiplication with the identity matrix is commutative: Matrix Algebra 29 Example 2. The following list summarizes the important information about inverses: A matrix that does have an inverse is said to be invertible, and a matrix that does not have an inverse is said to be singular.

Note that multiplying a matrix with its own inverse is a case when matrix multiplication is commutative. Mathematical Prerequisites Matrix inverses are useful for solving for other matrices in a matrix equation. Assuming that M is invertible i.

Game Developers Conference 2008

Techniques for finding inverses are beyond the scope of this book, but they are described in any linear algebra textbook it is not difficult; it is just not worth digressing into the procedure here.

To conclude this section on inverses, we present the following useful algebraic property for the inverse of a product: This is done as follows: The reason for this will be explained in the next chapter.

In addition, the overloaded parenthesis operator provides a convenient syntax for accessing 32 Part I: Mathematical Prerequisites Figure 2. Output of the above program. Two matrices of the same dimensions are equal if and only if their corresponding components are equal. We add two matrices of the same dimension by adding their corresponding elements. We multiply a scalar and a matrix by multiplying the scalar with every element in the matrix. Matrix multiplication is not commutative i.

Matrix multiplication is associative: The transpose of a matrix is found by interchanging the rows and columns of the matrix. We denote the transpose of a matrix M as M T. Matrix Algebra n n The identity matrix is a square matrix that has zeros for all elements except along the main diagonal, and the elements along the main diagonal are all ones.

Multiplying a matrix with its inverse results in the identity matrix: The inverse of a matrix, if it exists, is unique. Only square matrices have inverses and even then, a square matrix may not be invertible.

Solve the following matrix equation for: Compute the following matrix products: Mathematical Prerequisites 4. Write the following linear combinations as vector-matrix products: In fact, matrix multiplication is associative for general sized matrices, whenever the multiplication is defined.

Chapter 3 Transformations We describe objects in our 3D worlds geometrically; that is, as a collection of triangles that approximate the exterior surfaces of the objects. It would be an uninteresting world if our objects remained motionless.

Thus we are interested in methods for transforming geometry; examples of geometric transformations are translation, rotation, and scaling. In this chapter, we develop matrix equations, which can be used to transform points and vectors in 3D space. Mathematical Prerequisites 3. The idea is this: Remember that we are working with a vector-matrix product, and so we are limited to the rules of matrix multiplication to perform transformations.

Смотри также

But our points and vectors have three coordinates, not four. So what do we place for the fourth coordinate? The 4-tuples used to write the coordinates of a 3D vector or point are called homogeneous coordinates, and what we place in the fourth w-coordinate depends on whether we are describing a point or a vector.

Specifically, we write: We do not want to translate the coordinates of a vector, as that would change its direction and magnitude — translations should not alter the properties of vectors.

We now have enough background to look at some particular kinds of transformations we will be working with. The notation of homogeneous coordinates is consistent with the ideas shown in Figure 1. Chapter 3: Transformations 39 3. Figure 3. The left pawn is the original object. The middle pawn is the original pawn scaled 2 units on the y-axis.

The right pawn is the original pawn scaled 2 units on the x-axis. The scaling matrix: The inverse of the scaling matrix is given by: Suppose now that we wish to scale the square 0. The corresponding scaling matrix is: Mathematical Prerequisites Now to actually scale transform the square, we multiply both the minimum point and maximum point by this matrix: Scaling by one-half units on the x-axis and two units on the y-axis.

Clockwise rotation about an arbitrary axis n. In a left-handed coordinate system, positive angles go clockwise when looking down the positive axis of rotation. Rotation matrices have an interesting property. The readers can verify that each row vector is unit length and the row vectors are mutually orthogonal.

Thus the row vectors are orthonormal i. A matrix whose rows are orthonormal is said to be an orthogonal matrix. An orthogonal matrix has the attractive property that its inverse is actually equal to its transpose. Thus, the inverse of Rn is: In particular, if we choose the x-, y-, and z-axes for rotation i.

Mathematical Prerequisites Example 3. Then the y-axis rotation matrix is: Transformations 43 3. Note that to translate an entire object, we translate every point on the object by the same vector b. Displacing the position of the ant by some displacement vector b.

The translation matrix is given as follows: Suppose now that we wish to translate the square 12 units on the x-axis, —10 units on the y-axis, and leave the z-axis unchanged. The corresponding translation matrix is: Translating 12 units on the x-axis and —10 units on the y-axis. For the rotation matrices, the angles are given in radians. The obvious way to do this is step-by-step: In other words, matrix-matrix multiplication allows us to concatenate transforms.

This has performance implications. To see this, assume that a 3D object is composed of 20, points and that we want to apply these three successive geometric transformations to the object. On the other hand, using the combined matrix approach requires 20, vectormatrix multiplications and two matrix-matrix multiplications.

Clearly, two 46 Part I: Mathematical Prerequisites extra matrix-matrix multiplications is a cheap price to pay for the large savings in vector-matrix multiplications.

Again, we point out that matrix multiplication is not commutative. This is even seen geometrically. For example, a rotation followed by a translation, which we can describe by the matrix product RT, does not result in the same transformation as the same translation followed by the same rotation, that is, TR. How do we describe the same temperature of boiling water relative to the Fahrenheit scale?

In other words, what is the scalar, relative to the Fahrenheit scale, that represents the temperature of boiling water?

To make this conversion or change of frame , we need to know how the Celsius and Fahrenheit scales relate. They are related as follows: In the following subsections, we look at a similar problem, but instead of scalars, we are interested in converting the Chapter 3: We call the transformation that converts coordinates from one frame into coordinates of another frame a change of coordinate transformation.

It is worth emphasizing that in a change of coordinate transformation, we do not think of the geometry as changing; rather, we are changing the frame of reference, which thus changes the coordinate representation of the geometry. This is in contrast to how we usually think about rotations, translations, and scaling, where we think of actually physically moving or deforming the geometry.

In 3D computer graphics, since we employ multiple coordinate systems, we need to know how to convert from one to another. Because location is a property of points, but not of vectors, the change of coordinate transformation is different for points and vectors. In other words, given the coordinates identifying a vector relative to one frame, how do we find the coordinates that identify the same vector relative to a different frame?

Mathematical Prerequisites Figure 3. The geometry of finding the coordinates of p relative to frame B. From Figure 3. Expressing each vector in the above equation in frame B coordinates we get: Transformations where u and v are unit vectors that aim, respectively, along the x- and y-axes of frame A, and Q is the origin of frame A.

The advantage of Equation 3. 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.Chapter 4, Direct3D Initialization: In this chapter, we learn what Direct3D is about and how to initialize it in preparation for 3D drawing.

However, for completeness, we reshow the situation again in Figure 5. We learn how to define 3D worlds, control the virtual camera, and draw 3D scenes.

The semantic name and index provide a way to map vertex elements to the corresponding parameters of the vertex shader. Note that to translate an entire object, we translate every point on the object by the same vector b.