

CONVENTIONS AND NOTATION
First, let's agree to some notation since in latter parts of the book I'll be getting into some pretty heavy notation. Generally, any singlevalued quantity is written in a normal, unbolded font, whereas any multivalued quantity like a vector or a matrix is written in bold font. It gets a little confusing since one of the things a shader is generally trying to compute is color and, in current graphics hardware, that means a three or fourelement value representing the rgb or rgba values that the graphics hardware uses to represent a color. Traditionally, this color value is treated as a vector value, but it's manipulated as individual elements (Table 2.1).
TYPE 
EXAMPLE 
DESCRIPTION 

Scalars 
a b 
A single floating point number. Represented by a lowercase italicized letter. 
Vectors 
a c_{s} v 
A three or fourelement array of floating point numbers representing a direction. Represented by a lowercase bold letter. A subscript indicates an individual element. 
Unit vector 

A vector with a little hat character (a "circumflex") represents a normalized or unit vector. A unit vector is just a vector that has a length of one. 
Points 
p x 
A three or fourelement array of floating point numbers representing a position. Represented by a lowercase bold letter. A subscript indicates an individual element. 
Matrices 
M T 
A three or fourelement array of floating point numbers representing a position. Represented by an uppercase bold letter. 
In addition to notation for the various data types we will be manipulating, we'll also need notation for the various types of mathematical operations we'll be performing on the data (Table 2.2).
TYPE 
EXAMPLE 
DESCRIPTION 

Addition 
a + b 
Addition or subtraction between similar operand types. 
Subtraction 
c − d  
Multiplication 
MA 
There is no explicit operator typically used in this text for multiplication between operands that can be multiplied together. The absence of an operator indicates implied multiplication. 
Division 
1/2 
Division is represented by either a stroke or a dividing line. 
Dot product 
a • b 
Also called the inner product. Represented by the • symbol. 
Cross product 
b × a 
Represented by the × symbol. 
Absolute value or magnitude 
 a  
The absolute value is the positive value of a scalar quantity. For a vector, it's the length of the vector. In either case, a value divided by its absolute value is ±1. 
Piecewise multiplication 
i_{d} ⊗ c_{s} 
Elementbyelement multiplication. Used in color operations, where the vector just represents a convenient notation for an array of scalars that are operated on simultaneously but independently. 
Piecewise addition 
i_{d} ⊕ c_{s} 
Elementbyelement addition. Used in color operations, where the vector just represents a convenient notation for an array of scalars that are operated on simultaneously but independently. 
You'll also see text in a paragraph in a monospaced font. This is used to indicate particular aspects of shader programming. For example, you might need to check the capabilities of the device you're currently rendering by checking the D3DCAPS structure, or we might want to render a triangle list with a call to DrawIndexedPrimitive().
Finally, you'll see colored blocks of code, either C or C++ or shader code:
// shader file vs.1.0 //transform vertices by view/projection matrix m4x4 oPos, v0, c0 mov r0, c5 // load color5 mov rl, c6 // load color6 dp3 r2, r0, r1 // combine using a dot product mov oD0, r2 // output color

