Nadradený pojem:

Podradené pojmy:

To transform a normal to eye
coordinates, we use the *normal
matrix**.*
It is also used to transform direction vectors (for example, a spotlight
direction vector).

The normal matrix**N** is the transpose of the inverse of
the upper left 3x3 submatrix of the modelview matrix (denoted this as** M**).
This part of the matrix represents rotation and scaling (translations
don’t affect the orientation of a normal vector)

We’re going to apply the modelview matrix** M** to
the points on the triangle.

We’d like to find a transformation**N**,
applied to the normal, so that the transformed normal is still orthogonal to
the triangle after transformation.

The normal matrix

Derivation:

- Consider the triangle below. The normal n is orthogonal to any vector in the plane of the
triangle, including its edges, for example edge
**e = p2 – p1** - That
is,
**n · e**= 0. We did something just like this in the vector mathematics worksheet. - Note
that the dot product can be written as a matrix multiplication, that is:
**n · e = nT e = 0**

We’re going to apply the modelview matrix

We’d like to find a transformation

High

It
is best to compute the normal matrix on the client side and pass it into the
shaders.

While it is possible to write GLSL code to compute the normal matrix in a shader, the vertex / fragment shaders often execute many times when rendering an object.

Matrix inversion is computationally expensive [standard algorithms run in O(N3) for a NxN matrix].

The normal matrix does not change when rendering a single object. It is usually more efficient to compute it on the client side and pass it in through a uniform variable.

While it is possible to write GLSL code to compute the normal matrix in a shader, the vertex / fragment shaders often execute many times when rendering an object.

Matrix inversion is computationally expensive [standard algorithms run in O(N3) for a NxN matrix].

The normal matrix does not change when rendering a single object. It is usually more efficient to compute it on the client side and pass it in through a uniform variable.

Nadradený pojem:

Podradené pojmy: