Chapter 7: Realism through Normal Mapping


Overview

The really cool advantage of using shaders is that every step of the rendering pipeline can be customized. For Pixel Shader version 1.1 (GeForce 3) you have just eight instructions available and in reality the programmable pipeline is not really so great because all it does is emulate the Pixel Shader instructions with preprogrammed hardware. Pixel Shader 2.0 is much more flexible by allowing many more functions (as you saw in the previous chapter the normalize and pow methods are only available for Pixel Shader 2.0 and up) and the ability to write more instructions (the limit is 96 here, but some methods require more than one instruction).

Pixel Shader version 3.0 is even better by allowing better flow control, which means you can exit the shader code based on programmed conditions to optimize the performance. Complex shaders in Pixel Shader 3.0 can have up to 512 instructions and even with very fast graphics hardware this is a lot. When rendering many million of pixels it takes a lot of time to execute that many instructions for every single pixel, even when you have 16, 24, or even 32 pixel shader units working in parallel; the new NVidia 8800 GTX graphic card has even 128 shader units working in parallel. Sometimes you might want to skip complex calculations if a pixel is not affected by several lights or doesn’t lie in the shadow. This way you can still achieve great looking and expensive Pixel shader effects, but you limit them to where they are required. Sounds great, but in reality most new games just use Pixel Shader 2.0 because it is supported by many graphics cards; most typical games don’t support the more expensive graphics hardware.

Shader Model 4.0 was introduced with Direct3D 10 (early 2006) and the first graphics hardware (GeForce 8800) to support it was available by the end of 2006, but Direct3D 10 only works on Vista and the hardware is quite expensive. It will take a while until game developers can fully utilize shader model 4.0. XNA currently only supports shader models 1.1 up to 3.0. Shader Model 4.0 allows even more instructions and introduces geometry shaders that manipulate and even add geometry data before your vertex and pixel shaders are executed. All shader units are also unified in Shader Model 4.0, which means you can use them for whatever you want. There are no longer just 8 vertex and 16 pixel units, you just have 128 shader units and they all can be used for geometry, vertex and pixels shaders. This is great for level-of-detail effects and amazing effects like displacement mapping. In 2007 you can hopefully expect some cool demos, but games will probably not use geometry shaders until 2008 or later.




Professional XNA Game Programming
Professional XNA Programming: Building Games for Xbox 360 and Windows with XNA Game Studio 2.0
ISBN: 0470261285
EAN: 2147483647
Year: 2007
Pages: 138

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net