In computer graphics, a pixel shader, also known as a fragment shader, is a program that dictates the color, brightness, contrast, and other characteristics of a single pixel (fragment). A programmer who specializes is writing pixel shader programs is known as a shading artist.
How does it work?
The shader itself refers to code that determines how the pixel will look in a given scenario. For instance, if the pixel to be rendered is on the visible surface of the sphere, some of the factors to be considered are:
- What light sources illuminate this fragment of the sphere and what types of light are they? What color is the light?
- What is the specularity of the sphere's surface material — does it reflect light sharply like metal, or does it diffuse it like plastic?
- Is there a texture mapped to the surface? If so, the corresponding pixel in the texture's bitmap will contribute to the color of the fragment.
- Is there a bump map associated with the surface of the sphere? If so, a bitmap or mathematical procedure will affect the brightness of the light to simulate a bumpy texture on the surface.
- Is the surface partially transparent? Are there partially transparent objects between the sphere and the camera?
- Do any other objects cast shadows on the sphere?