Graphics Reference
In-Depth Information
need to use inverse-transpose of the model-view matrix to transform TBN (tan-
gents and bi-tangents use the same transform as normals). It is very expensive
to invert a matrix in a shader, and in the case of a model-view inverse-transpose
matrix pre-computation, we would need to pass this matrix through vertex at-
tributes per instance in case of instancing. One possible hack is to re-use the
original model-view matrix to transform TBN, but in this case we need to or-
thonormalize TBN afterwards to avoid lighting artifacts.
Moreover, TBN becomes unnormalized and loses orthogonality during inter-
polation. Hence, orthogonalization and normalization also need to be performed
in a pixel shader. In our experience, this takes a significant amount of ALUs in
vertex and pixel shaders.
We tried several methods enabling normal mapping without TBN in our en-
gine. [Mikkelsen 10] needs so-called derivative maps as an input, which can be
obtained from normal maps. However, on our assets this method was capable of
conveying much less detail than regular normal mapping, which was unacceptable
for artistic reasons.
We also tried the method in [Schuler 06]. It implies additional ALU cost for
differential chain rule application. However, the greatest limitation appeared to
be pipeline issues: the TBN basis generated by Autodesk Maya did not coincide
with one derived from the texture-coordinate gradient. This resulted in different
parameterizations, making it impossible to reuse already existing normal maps.
Encoding TBN with quaternions allows us to overcome these problems. How-
ever, there are several problems with this approach. One is TBN matrix handed-
ness , which we will not discuss here as it is covered in detail in [Malyshau 12].
The other problem is quaternion interpolation. Quaternion spherical linear
interpolation (SLERP) produces correct results without a prior alignment. How-
ever, since vertex attribute interpolation is not programmable, we interpolate
quaternions linearly, which causes issues. [Malyshau 12] proposes a solution that
increases the original vertex count by 7.5% and polygon count by 0.14%. Below,
we propose a solution, which works for any correctly UV-mapped model, that
does not change vertex and polygon count at all. Let us first explain the ground
for this problem.
Let us consider quaternions q 1 =( x 1 ,y 1 ,z 1 ,w 1 )and q 2 =( x 2 ,y 2 ,z 2 ,w 2 ). If
their dot product ( q 1 , q 2 ) is positive, the quaternions will interpolate along the
shortest arc; otherwise they interpolate along the longest. That being said, if we
take a
q 1 quaternion (instead of an equivalent q 1 ), the interpolation arc will be
reversed. For vertex normals inside the triangles, we will expect to interpolate
along the shortest arc. Yet, for a closed model, that might not always be the
case. A natural solution to this will be to align all quaternions at the model's
neighboring vertices by multiplying one of them by
1 so that their dot product
becomes positive. However, this will not solve the problem in most cases.
Let us consider a cylinder model as in Figure 1.1. We will take a quaternion
q =(0 , 0 , 0 , 1) at the point A as a reference and start aligning all the quaternions
Search WWH ::




Custom Search