Pixel shader

Updated: 04/26/2017 by Computer Hope
Sphere shading

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 a pixel appears in a representation of a virtual environment. For instance, if the pixel to be rendered is on the visible surface of the sphere, factors affecting its appearance include:

  • 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 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 affects 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?

Programming terms, Texture mapping