## Pixel Shader 2.0 Specification

When, a bit more than a year ago, NVIDIA released GeForce3, which was the first 3D chip to include vertex as well as pixel shaders, the world of 3D developers welcomed the vertex shader, but criticized the half-hearted specs of the pixel shader. DirectX 9 is supposed to finally improve this situation, even though the new pixel shader 2.0 spec doesn't seem to be as much of a leap forward as one would have expected. The most important addition to the pixel shader spec is certainly the inclusion of 64-bit and 128-bit floating point color precision. Besides that, new instructions have been added and the maximum number of pixel shader instructions has been increased to (a still measly looking) 160, but there is still now flow control. NVIDIA's upcoming 'NV30' will go several steps further than that, but more about this in three or four months' time, when NVIDIA's new chip's review units will finally hit the reviewers' desks.

## Floating Point Precision Color

As already mentioned, the most important new spec of PS 2.0 is the inclusion of 64 or even 128-bit floating point color precision. Why is that so important?

So far, the highest color precision we could use on a PC was 32-bit. A 32-bit integer number can be anything between 0 and 232 -1 = 4,294,967,295. If you look at it from that point of view, you could say that 32-bit color supports more than 4 billion different colors. Is that not enough?

First of all, 32-bit color does not really allow 4 billion colors. In fact, only 24 bit are used for the 'RGB' (=red/green/blue) color information. The remaining 8 bit usually carry the 'alpha' value. 224 is only 16,777,216, and this is the number you certainly know as 'true color,' 16.7 million different colors. Still, this number looks rather respectable. However, if we look at it more closely, we can see that 32-bit color is even less impressive. The 24 bits that carry the color information consist of 8 bit for red, 8 bit for green and 8 bit for blue. This means that for each elementary color, you've got a precision of a measly 8-bit, allowing integer values from 0 to 255. That's not really a lot, is it? This 8-bit per color channel precision has one serious flaw, it doesn't allow a whole lot of dynamic. Dynamic means the difference between the lowest and the highest value. If we forget about the '0' value for a minute, and just start at '1,' then we can see that the biggest dynamic from this value to the max is only 255. This is what game developers are fighting with - they want to have very dark, as well as very bright areas in their 3D worlds, and the range from 1 to 255 for each color channel just isn't good enough.

Now in the computer world, there's two different ways of handling numbers. The easiest to understand are, of course, integer numbers, which are stored 'just as they are.' Floating point numbers work differently. Here the number consists of a sign bit, a few bits for the exponent and quite a lot of bits for the mantissa. The formula would be x = m*2e , where 'x' is the number, 'm' is the mantissa and 'e' is the exponent. As you can see, the smallest as well as largest floating point number is specified by the exponent, while the mantissa defines the precision. In the case of a 128-bit FP number, each color channel has a 32-bit floating point precision (IEEE single precision, remember 'SSE'?), which consists of 1 sign bit, 8 exponent bits (7 plus sign) and 23 mantissa bits. This allows a dynamic range from 0.00000000000000000000000000000000000000294 (=2-128 ) to 170,000,000,000,000,000,000,000,000,000,000,000,000 (=2127 ), and with 23-bit, a much higher precision than the 8-bit precision of the 32-bit color values.

The increase in dynamics as well as precision enables a quantum leap in terms of image quality. It also opens the door for a lot of new effects that weren't really possible before.

On the left you see the same scene in 32-bit color and on the right you see the dramatic increase in color and brightness dynamics due to the usage of 128-bit FP color precision.

ATi shows a demo of a low polygon car that is visually enhanced with dot3 bump mapping using a 64-bit precision normal map. This kind of effect was impossible with 32-bit integer normal maps, as you can see in the demo pictures below.

Unfortunately, 128-bit color requires four times the memory bandwidth of 32-bit color. It's going to take a while until memory technology will caught up with that.