Vertex and Pixel Shaders Simplified | Posted by jonchappell on Aug 08th 05 08:20 AM
Vertex and Pixel Shaders have been an industry buzzword for a while now but a lot of people still don't know what they are.
Every scene in a game is constructed of thousands of tiny triangles. Each vertex (where two edges meet) of the triangles is assigned texture data, colour data, lighting data and other parameters. Vertex shaders are the next step up from Hardware Transform & Lighting (T&L). Hardware T&L processes lighting and vertex transformation data on the GPU itself instead of the system processor. This is much faster and leaves the CPU free for other tasks such as AI. The downside to this approach is that because the data is no longer processed by the CPU, it is difficult for programmers to modify the data. Vertex shaders solve this problem.
Vertex shaders operate on vertices and allow complex effects to be applied to whole surfaces such as sunlight reflecting off water (below). Pixel shaders on the other hand operate on individual pixels within a scene. This allows complex textures to be created such as fur or hair.
Shaders allow game programmers to modify data before it is rendered on the screen. This is similar to the way that a photographer can change the type of lens in order to affect the look of the image before it is recorded onto the film. Shaders make complex special effects possible such as cel shading which was used to create the cartoon style of the game XIII (below). They are also used extensively in Unreal 3 to create near Hollywood-quality graphics.
There are currently three shader models (software versions). Shader Model 1.0 was limited to 8-bit colour whilst Shader Models 2.0 and 3.0 supported greater colour depths and allowed for the execution of more instructions on each vertex or pixel (leading to more complex visual effects). It is likely that Windows Vista will improve on the shader model once again.
Shaders are definitely playing a big part in the future of gaming and machinima (creating movies from game engines). Some graphics cards today have as many as 16 shader pipelines to process 16 shader instructions per cycle (there are millions of cycles per second). Shaders are definitely a step towards photorealistic graphics, the Holy Grail of gaming.