Graphics Reference
In-Depth Information
The quaternion q is equivalent to the quaternion k q where k
R
.
The normalized quaternions ( x, y, z, w )and( −x, −y,−z,−w )areequiva-
lent.
The inverse rotation for the quaternion ( x, y, z, w ) is denoted by the quater-
nion ( x, y, z,
w ).
The angle between two normalized quaternions q 1 , q 2 can be found as θ =
2 arccos( q 1 ,q 2 ), where ( q 1 ,q 2 ) is a per-component dot product of q 1 and q 2 .In
this chapter all quaternions are implied to be normalized if not noted otherwise.
1.3 Quaternion Use Cases
In our engine we used quaternions for multiple purposes. Our goal was to replace
bulky 3 × 3 rotation and tangent-space matrices throughout the entire engine.
This affected the following engine components:
normal mapping,
generic transforms,
instancing,
skinning,
morph targets.
For each of these cases we discuss the implications in the following individual
sections.
1.4 Normal Mapping
Normal mapping was an initial reason to use quaternions engine-wide. Normal
mapping requires one to define a so-called tangent space at each surface location:
a coordinate system, which is defined by tangent, bi-tangent (often erroneously
called bi-normal), and normal (TBN).
Usually, these basis vectors are defined per model vertex and then interpolated
inside triangles, and this is where the problems arise. First, TBN occupies at least
six interpolator channels (provided we reconstruct the third vector using a cross
instruction and pack a handedness bit without wasting an extra interpolator
channel). This may be alleviated by packing TBN, but it comes at a pixel shader
additional cost.
Second, TBN might need orthonormalization multiple times throughout the
pipeline. In the case of a model-view matrix containing a nonuniform scale, we
Search WWH ::




Custom Search