DirectX® 9.0 and SmartShader™ 2.0 White Paper
Microsoft® DirectX® 9.0
DirectX 9.0 is the latest major revision of Microsoft's Application
Programming Interface (API) for Windows operating systems. It
is designed to unlock the capabilities of PC multimedia hardware.
The most significant new features of DirectX 9.0 are in the
area of 3D graphics, where technology is moving forward at the
fastest rate. These features are designed to bring movie-quality
effects and new levels of photo-realism to 3D games and other
interactive applications.
A long-standing goal of 3D graphics designers is to be able
to display the same cutting-edge visual effects used in movies
at interactive frame rates. One of the ways to facilitate this
process is to give designers the ability to port movie effects
directly to PC games and vice versa. DirectX 9.0 is designed
to expose these capabilities on systems with the latest graphics
hardware.
Today's graphics look pretty realistic, but there is always
a little something lacking that makes them look computer-generated.
Many new DirectX 9.0 features focus on reducing or eliminating
these inconsistencies to bring us a big step closer to photo-realism.
These same features provide the necessary flexibility to achieve
a range of interesting non-photo-realistic special effects as
well.
DirectX 9.0 is available as an update to Windows operating systems.
To fully experience the benefits it provides, you will need
one of the latest generation of high performance graphics accelerators
that supports all the major new features, including 2.0 Vertex
Shaders, 2.0 Pixel Shaders, and 128-bit floating point data
formats. The first available products to support these features
are the Radeon 9700 series and Radeon 9500 series GPUs from
ATI. The demos described in this paper provide examples of how
they can be used to achieve amazing new visual effects.
Shaders
Shaders are small programs that determine how a 3D object or
image is rendered. They are designed to execute on a graphics
processor rather than a CPU, which allows them to run at interactive
frame rates while freeing up the CPU for other tasks. There
are two types of shaders in DirectX - Vertex Shaders and Pixel
Shaders. Vertex Shaders are used to modify the geometry or shape
of 3D objects, and also to control lighting and shadows. Pixel
Shaders manipulate the color and appearance of surfaces.
Starting with DirectX 8.0, each version of DirectX has included
new versions of the vertex and pixel shader languages. DX9 introduces
version 2.0 Vertex and Pixel Shaders. Whereas earlier versions
of these shader languages were often incompatible with each
other, the full floating point instruction set of version 2.0
shaders was designed to be flexible enough to be compatible
with any future shading language.
2.0 Vertex Shaders
The version 2.0 Vertex Shader specification adds new flow control
commands, including loops, jumps and subroutines. As standard
features in higher-level languages like C, these commands make
it easier to code vertex shaders and enhance processing efficiency.
For example, one common application for vertex shaders is to
process lighting calculations in 3D scenes. With earlier versions
of the vertex shader language, you would have to write a new
shader to use in different environments with different lighting
conditions. With 2.0 Vertex Shaders, developers can write a
single general-purpose lighting shader that can handle any number
of lights with customizable colors, shapes, and positions by
calling different subroutines. Another example is real-time
fur rendering, in which the fur is built up on the surface of
a character by generating a series of concentric shells of textured
and alpha-blended geometry. A looping vertex shader routine
can generate these shells easily, repeating until the fur reaches
the desired length.
Earlier versions of the DirectX vertex shader language limited
shaders to a maximum of 128 instructions. With version 2.0,
vertex shaders can now be thousands or even tens of thousands
of instructions long - a massive increase in complexity and
power. In fact, using multiple passes, 2.0 vertex shaders with
practically unlimited instruction counts can be executed in
hardware. New operations like sines, cosines, and power functions
also simplify shader code, allowing real time processing of
effects that previously took thousands of times longer.
2.0 Pixel Shaders
Powerful programmable pixel shaders are essential for creating
photo-realistic, cinematic quality effects. The main things
limiting the complexity of a pixel shader are the number of
textures it can work with, and the maximum number of instructions
it can contain. The previous version of the DirectX pixel shader
language, version 1.4, was limited to a maximum of 6 textures
and 28 instructions. With the 2.0 Pixel Shader language in DirectX
9.0, the maximums have been raised to 16 textures and 160 instructions,
allowing far more complex shaders to be written than ever before.
In fact, these instruction counts are not really limitations,
since new high precision floating point data formats make multi-pass
pixel shader effects possible. This means 2.0 Pixel Shaders
of any length can be used, allowing the rendering of arbitrarily
complex visual effects - even the ones used in the latest computer
generated films and television shows. For example, 2.0 Pixel
Shaders can accurately simulate the scattering of light in semi-translucent
materials like skin, marble, wax, or car paint.
Like 2.0 Vertex Shaders, 2.0 Pixel Shaders have also been enhanced
with many new operations that make them more efficient and easier
to write. For example, a new square root operation makes it
feasible for 2.0 Pixel Shaders to make use of compressed bump
maps that take up far less memory than standard bump maps -
meaning high resolution bump maps can be used more liberally
in games than ever before.
Floating Point Data Formats
Another limitation of previous pixel shader versions was that
they could only work with integer values. For example, most
colors are represented using 8-bit integers for Red, Green,
and Blue, meaning each can have a value from 0 to 255. Since
integers cannot have fractional values, they do not work well
with operations like division and square roots. When they are
run through the complex mathematical calculations in pixel shaders,
errors can quickly build up that result in an obvious loss of
precision.
DirectX 9.0 supports several new floating-point color formats
that offer vastly greater range and precision than integer formats.
For example, while a 16-bit integer value is limited to a range
of +/-32,767, a 16-bit floating point value could represent
numbers as small as 0.0000000000000001, or as large as 10,000,000,000,000,000!
These levels of precision and range are standard when producing
cinema-quality graphics, and are essential in order to bring
the same quality to interactive PC applications.
 |
|
Figure 1: DirectX® Feature Comparison
|