|
This sample application demonstrates
the use of a variety of new and old texture formats
to store normal information. The different formats can
be used to store normals at
varying levels of precision. In this sample, up
to 9 different textures will be created. Each
of these textures belong to one of four categories,
each of which requires a different form of "decompression"
inside of the pixel shader:
- Scale-and-biased 3-tuples
- D3DFMT_A8R8G8B8
- D3DFMT_A2R10G10B10
- D3DFMT_A16B16G16R16
- Two's complement 3-tuples
- D3DFMT_Q8W8V8U8
- D3DFMT_A2W10V10U10
- D3DFMT_Q16W16V16U16
- Scale-and-biased 2-tuple
- Two's complement 2-tuples
- D3DFMT_V8U8
- D3DFMT_V16U16
In the 2-tuple cases, the z component of the
normal must be derived from +sqrt(1-x2-y2). As a
result, the z component is assumed to be positive
and thus must be in surface local coordinates (aka
"tangent space"). In the scale-and-biased
cases, the sampled data is in the 0 to 1 range and must
be scaled and biased into the -1 to 1 range by the pixel
shader to be useable.
This sample creates 12 pixel shaders: specular,
diffuse and specular
+ diffuse for all four categories of normal decompression.
With the Up/Down arrow keys, the user can select between
texture formats. The S key cycles between
specular, diffuse
and specular + diffuse lighting modes. With
the lower-precision formats such as D3DFMT_A8R8G8B8,
precision artifacts are evident in the specular
highlight. These artifacts are eliminated when
using higher precision formats such as D3DFMT_Q16W16V16U16
or D3DFMT_G16R16. This added precision is also
necessary when using an environment map of relatively
high spatial frequency. This is the case in the
ATI Radeon 9700 Car Demo,
which uses the D3DFMT_G16R16 format for its normal maps.
|