Shaders are a crucial part of computer graphics. A
shader (as the name suggests) shades 3d surfaces.
In certain rendering engines such as Renderman, shaders are needed to describe to the renderer what attributes the shaded surface has. Originally shaders had to be programmed and compiled in C or C++ but that is somewhat rarer today. There are very few commercial raytracers that actually require much programming nowadays, but there are still those that reward it. Writing shaders still requires programming though hundreds of shaders are usually already available to the artist. Traditionally, shaders have been divided into several general categories based on what role they play:
These are the most commmonly used shaders. They describe the reaction of surfaces to light and tell this information to the rendering engine.
In some computer graphics applications the term displacement shader is synonymous with bump map shader. In others, the two are terms describe different things. Bump mapping refers to a shader that alters the brightness value of pixels on an object depending on the incidence of light sources hitting the object, giving the impression of depth. This is sometimes called a displacement shader. Because this is only a shader, there is no real geometry added, saving CPU time when rendering, but at the cost of realism. Actual displacement maps work differently, by displacing an objects mesh according to the brightness value of a greyscale image. Displacement maps can be used not only to add more realism by changing geometry, they can be a simple solution to easily creating landscapes, hills and mountains.
Volume shaders use complex calculations to alter rays of light when they pass through transparent or translucent mediums, such as smoke, or water. Volume shaders often use complex refractive calculations and usually increase the render time significantly.
Light shaders describe all attributes of a light source, such as luminosity, colour, distribution and such. There are several advanced light shaders that implement Radiosity and other photorealistic effects.
These make final adjustments to the pixels of the image before they are output. These are comparable to the filters of Adobe Photoshop. Depth of field is an effect implemented through the use of imaging shaders: first, a depth map of the scene is rendered in greyscale, then that image is used as a mask for a blurring effect so that only far away objects seem out of focus.
Shaders are not only used in computer animation. Many graphics processers support shaders in hardware, such as the geForce4 and Radeon 9700 video cards. Even the current generation of video game consoles support shaders in some way, and the XBox has dedicated vertex and pixel shaders built into hardware. Celshading is an example of a shader implemented in realtime, through the use of vector calculations. In the game Jet Grind Radio, a shader is employed that seperates the colours into zones based on their angle of incidence to the light source. Thus the bright areas are contrasted to the darker giving the game an anime like feel to it. Another example of shaders being used to great effectiveness in video games is reflective surfaces, which are quite complex and sometimes difficult to use due to the amount of CPU power required to simulate reflection realistically.