CONVENTIONS AND NOTATION

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 single-valued 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 four-element 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).

Table 2.1: OPERAND NOTATION

TYPE

EXAMPLE

DESCRIPTION

Scalars

a b

A single floating point number. Represented by a lowercase italicized letter.

Vectors

a cs v

A three- or four-element 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 four-element 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 four-element 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).

Table 2.2: OPERATOR NOTATION

TYPE

EXAMPLE

DESCRIPTION

a + b

Addition or subtraction between similar operand types.

Subtraction

c d

Multiplication

MA
pv

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
a/b

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

id cs

Element-by-element 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.

id cs

Element-by-element 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:

```