Vertex and pixel shaders

Vertex and pixel (or fragment) shaders are shaders that run on a graphics card, executed once for every vertex or pixel in a specified 3D mesh. They operate in the context of interactively rendering a 3D scene, usually using either the Direct3D or OpenGL API.



Flexible shaders were initially used for non-interactive rendering applications like Pixar's RenderMan, which was designed to render film-quality images.

3D hardware previously used fixed-function pipelines in which, for example, one was stuck with the lighting model chosen by the hardware vendor. Graphics hardware was able to do transformation and lighting (T&L for short) on the GPU, but it was not flexible. A vertex shader sidesteps the T&L stage in the pipeline and lets the user add on to it.

Pixel shaders operate after the geometry pipeline and before final rasterization. They operate in parallel with multitexturing to produce a final pixel color and z-value for the final, rasterization step in the graphics pipeline (where alpha blending and depth testing occur).

In years past, video cards from Nvidia and ATI Technologies started supporting pixel and vertex shaders in hardware, allowing their use for real-time rendering. The technology is not yet quite mature, but the latest generation of games, including Doom 3 and Half-Life 2 make increasing use of hardware shaders. A brewing standards battle between ATI and Nvidia is likely to prove entertaining viewing.


The programs are written in either the native assembly language of the card or in a high-level shader language like the aptly named High Level Shader Language. Some key facts about vertex and pixel shaders are that they

  • can only access data in the graphics card's own memory, such as texture and geometry data, and therefore cannot access data in the computer's main memory or cache.
  • operate independently for each vertex or pixel. This ensures that they can be trivially parallelized. For instance, ATI's latest cards run 16 shaders at a time.
  • have access to a rich instruction set including many vector and matrix operations, but often no branching.
  • may be limited to a certain number of instructions and texture reads per vertex or pixel, which varies by card and shader language version.


The capabilities of vertex and pixel shaders are still being explored, and since hardware capabilites are improving with each generation we can expect their abilities to approach those of programmable shaders such as RenderMan's.

There exist vertex shaders that:

There exist pixel shaders that:

  • Apply an accurate per-pixel Phong lighting model
  • Simulate multilayer metallic paint
  • Fake volume lighting, so that a spotlight lights up dust motes in the air
  • Simulate turbulent air flow and display swirling wisps of smoke
  • Apply depth of field to the scene

One of the most intriguing uses of hardware shaders is for physical simulation. The powerful vector math and parallelized architecture make current graphics cards much faster than general-purpose CPU's for certain simulations where the current state at a certain point is only dependent upon the previous state for a small area around it, like turbulent flow. Several projects are exploiting this unintended use.

The future

New technologies, including DirectX's Pixel Shader 3.0 specification and accompanying implementations, promise to increase shaders extensibility. Capabilities of more advanced programming languages, such as loops and if/then constructs, are being extended to the shader languages. Many experts see the logical continuation of this increasing flexibility to be the eventual merging of the pixel and vertex shaders into one unit. It seems likely that in the future the Graphics Processing Unit, already rivaling the complexity of the CPU, will take over more graphically related tasks currently performed by CPUs. (Note: The Pixel Shader 3.0 is already available in new NVidia cards, for example in GeForce 6800)

See also

External links


  • Art and Cultures
    • Art (
    • Architecture (
    • Cultures (
    • Music (
    • Musical Instruments (
  • Biographies (
  • Clipart (
  • Geography (
    • Countries of the World (
    • Maps (
    • Flags (
    • Continents (
  • History (
    • Ancient Civilizations (
    • Industrial Revolution (
    • Middle Ages (
    • Prehistory (
    • Renaissance (
    • Timelines (
    • United States (
    • Wars (
    • World History (
  • Human Body (
  • Mathematics (
  • Reference (
  • Science (
    • Animals (
    • Aviation (
    • Dinosaurs (
    • Earth (
    • Inventions (
    • Physical Science (
    • Plants (
    • Scientists (
  • Social Studies (
    • Anthropology (
    • Economics (
    • Government (
    • Religion (
    • Holidays (
  • Space and Astronomy
    • Solar System (
    • Planets (
  • Sports (
  • Timelines (
  • Weather (
  • US States (


  • Home Page (
  • Contact Us (

  • Clip Art (
Personal tools