In 3D computer graphics, a shader is a program used to determine the final surface properties of an object. The most common use of shaders is to determine the final color of the object. Shaders can also be used to manipulate the object's position.
Programmable shaders were introduced in Pixar's RenderMan, which defines three major types:
- Light source shaders calculate the color of the light emitted from a point on the light source towards a point on the surface being illuminated.
- Surface shaders are used to model the optical properties of the object being illuminated. They output the final color and position of the point being illuminated by taking into account the incoming light and the physical properties of the object. Displacement shaders are a special case of surface shaders that manipulate only the object's position, not its color.
- Volume shaders manipulate the color of a light as it passes through a volume. They are used to create effects like fog.
Programmable shaders are quite powerful. Complicated surfaces can be rendered from simple geometry. For example, a shader can be used to render a grid of 3D ceramic tiles from a simple plane.
Up until recently, developers did not have the same level of control over the output from the graphics pipeline of graphics cards. Transformation and shading equations were hard-coded in the card. Vertex and pixel shaders were introduced to give the programmer greater control over the shading process. These programs are executed directly on the GPU at the proper point in the pipeline.
Shading languages
Shading languages in common use today include:
Production rendering
- RenderMan Shading Language, which is defined in the RenderMan Interface Specification , is the most common shading language for production-quality rendering.
Real-time rendering
The following languages are used to program GPUs:
- ARB Shading Language is an assembly language specified by the OpenGL Archtecture Review Board.
- Cg is a high-level shading language developed by Nvidia.
- OpenGL Shading Language is a standardized shading language to be used with OpenGL.
- DirectX High-Level Shader Language is a shading language to be used with DirectX.