Some neat uses for Texture Matrices
(By Dan Evans, 10th Nov 1999)
Go to my main page
Please note; not all of these ideas have had solid testing via an implementation
so some of it is theory, but not all of it.
The only real restriction on the coordinate space of these techniques is that
if you want to use D3D's transformation pipeline (i.e. TnL) then you have to
use world space coordinates for your vertex normals. This requires that the
other vectors involved are also in the same coordinate space (otherwise the
result would not make sense).
1) Cartoon rendering ('Toon' rendering)

Using this texture...

See actual results
and
(D3DRENDERSTATE_TEXTUREMAPBLEND,D3DTBLEND_MODULATE)
or (D3DTSS_COLOROP, D3DTOP_MODULATE)
depending what your preferred method is. (I think the first pair are legacy now ???).
2) Anisotropic lighting

Using this texture...

See actual results
and
(D3DRENDERSTATE_TEXTUREMAPBLEND,D3DTBLEND_ADD)
or (D3DTSS_COLOROP, D3DTOP_ADD)
3) Spherical reflection mapping
This matrix uses the X and Y axes of the view matrix as vectors for using in a dot product
with the world space normal (the D3D sample "Spheremapping" uses the world space
normal which I found a bit confusing, but I guess that's how it works) The Z axis
of the view matrix is ignored. What we want is a 2d mapping into our reflection map
so Z turns out to be superfluous for our requirements. Using the D3D conventions the
X axis in view space can
be represented as a vector made from elements 11, 21, and 31 of the View matrix and
12, 22, 32 for the view-space Y axis;
Viewspace X Axis (VX)
|
_11
| _12
| _13
| _14
|
_21
| _22
| _23
| _24
|
_31
| _32
| _33
| _34
|
_41
| _42
| _43
| _44
|
Viewspace Y Axis (VY)
|
_11
| _12
| _13
| _14
|
_21
| _22
| _23
| _24
|
_31
| _32
| _33
| _34
|
_41
| _42
| _43
| _44
|

It is interesting to note that if you get a texture of a perfect ball of short fur
on a black background and use that as your reflection map with a colourkey set to
black (or similar with alphatest) then you can texture things with it to make a pseudo
fur effect that presents "scalp" at vertices whose normals point to the camera position
and gradually rotate out to sideways fur strands as the normal turns away from the camera
until the normal is perpendicular to the camera direction. I have not yet been able to
get hold of the perfect "ball of fur" image, so if anyone has one they wish to donate
I would be extremely grateful. I call this technique "pseudo fur-mapping" :)
The jaggy edges at the circumference of the circle the ball makes on the 2d image
provide the illusion of strands of fur at the silhouette of the fur-mapped object.
A very poor artists impression of what I mean...

hits to this page: