Vertex Shaders and Pixel Shaders

Compatibility

For most PC systems, backwards compatibility has always been a bit of a headache. In a perfect world, all game-players would have a useable version of the game, even if they're running on a P-60 with a standard 2D graphics card. Unfortunately, it's impossible to write games that can run on any hardware; a cut-off point must always be made. For the moment, over half of the buying public are running hardware which can accelerate the fixed-function pipeline in hardware, but a very small percentage have hardware which can accelerate vertex shaders. So, until next generation graphics cards make up ~10% of the market, the only people that really need to worry about vertex shaders are people who are working on OEM titles, and the really big companies who are keen to use all the latest graphical effects. Although, that said, vertex shader emulation does mean that particularly cool types of vertex processing can still be carried out in software on older hardware T&L cards.

Summary

Overall, it's going to be impossible not to use vertex shaders and pixel shaders within a few years' time. The hardware vendors and Microsoft all like the new paradigm, so closing your eyes to the shader implementations won't get you anywhere!

It's a shame that a lot of the work that used to be done by the driver has been moved into the domain of the games programmer, but we're just going to have to learn to make the most of it. The currently available vertex shader implementation makes it very difficult to get much out of shaders without writing complicated API wrappers such as the fragment-based system described above. With any luck, DX9 will introduce flow control into the vertex shader architecture. At that point, we should be able to carry out the lighting with a constant piece of code for each vertex shader. The lighting itself can be specified in the constant memory, but it looks like the code-size limit will remain, so it may still be necessary to have a simple form of fragment processing, in order to avoid reaching this limit.

There is no doubt that the shader architecture opens up new possibilities within the hardware. The software implementation of vertex shaders is good enough to emulate useful vertex shaders on older hardware, and if you're writing technical demonstrations, you'll love the freedom that the shader architecture gives you. For game engines, you'll need to look at what shaders will give you, versus the amount of work shader support will require.

Hopefully this article has introduced a few methods that you may be able to use to open up the shader architecture within your own projects, as well as shedding some light on the pitfalls associated with them. It's not a perfect architecture, but it does let us produce some great effects.

TOPICS