A shader is a piece of code used by 3D engines to determine how an object should be rendered. Normal programs run on the CPU of your computer, but shaders run on the GPU, your graphics card. When used properly, shaders can make games look much more professional and allow advanced effects like shadows, normal mapping and reflection.
There are several different types of shaders:
- Vertex shaders tell the engine what colour and position each vertex of an object should be relative the the camera. All the engine now has to do is rasterize the object using the vertex positions and colours, and possibly a texture you have textured it with.
- Pixel shaders take this process one step further. With a pixel shader, the programmer has control over what colour every pixel of the render can look like. Usually they tell look up the location of that pixel on a texture and maybe two and combine the result of the two.
- Geometry shaders allow the GPU to modify the geometry of the object. This means they can add and remove vertices and move them.
There are many different ways of programming shaders. Microsoft's HLSL language is designed for use with DirectX, and this is primarily what DarkGDK uses. OpenGL has a similar GLSL language. ATI has made a language called Cg with identical syntax to HLSL, but is implemented in a different way. Before these languages, graphics programmers would write shaders in Assembly Language. This allows much more control and can be optimized much further, but is more advanced than other methods and can be very daunting to beginners.
DarkGDK is built upon DirectX 9, which means that at most you can use HLSL shader model 3. This does not have a geometry shader, only pixel and vertex.