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.

Contents

Background

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.

Details

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.

Capabilities

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

Navigation

  • Art and Cultures
    • Art (https://academickids.com/encyclopedia/index.php/Art)
    • Architecture (https://academickids.com/encyclopedia/index.php/Architecture)
    • Cultures (https://www.academickids.com/encyclopedia/index.php/Cultures)
    • Music (https://www.academickids.com/encyclopedia/index.php/Music)
    • Musical Instruments (http://academickids.com/encyclopedia/index.php/List_of_musical_instruments)
  • Biographies (http://www.academickids.com/encyclopedia/index.php/Biographies)
  • Clipart (http://www.academickids.com/encyclopedia/index.php/Clipart)
  • Geography (http://www.academickids.com/encyclopedia/index.php/Geography)
    • Countries of the World (http://www.academickids.com/encyclopedia/index.php/Countries)
    • Maps (http://www.academickids.com/encyclopedia/index.php/Maps)
    • Flags (http://www.academickids.com/encyclopedia/index.php/Flags)
    • Continents (http://www.academickids.com/encyclopedia/index.php/Continents)
  • History (http://www.academickids.com/encyclopedia/index.php/History)
    • Ancient Civilizations (http://www.academickids.com/encyclopedia/index.php/Ancient_Civilizations)
    • Industrial Revolution (http://www.academickids.com/encyclopedia/index.php/Industrial_Revolution)
    • Middle Ages (http://www.academickids.com/encyclopedia/index.php/Middle_Ages)
    • Prehistory (http://www.academickids.com/encyclopedia/index.php/Prehistory)
    • Renaissance (http://www.academickids.com/encyclopedia/index.php/Renaissance)
    • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
    • United States (http://www.academickids.com/encyclopedia/index.php/United_States)
    • Wars (http://www.academickids.com/encyclopedia/index.php/Wars)
    • World History (http://www.academickids.com/encyclopedia/index.php/History_of_the_world)
  • Human Body (http://www.academickids.com/encyclopedia/index.php/Human_Body)
  • Mathematics (http://www.academickids.com/encyclopedia/index.php/Mathematics)
  • Reference (http://www.academickids.com/encyclopedia/index.php/Reference)
  • Science (http://www.academickids.com/encyclopedia/index.php/Science)
    • Animals (http://www.academickids.com/encyclopedia/index.php/Animals)
    • Aviation (http://www.academickids.com/encyclopedia/index.php/Aviation)
    • Dinosaurs (http://www.academickids.com/encyclopedia/index.php/Dinosaurs)
    • Earth (http://www.academickids.com/encyclopedia/index.php/Earth)
    • Inventions (http://www.academickids.com/encyclopedia/index.php/Inventions)
    • Physical Science (http://www.academickids.com/encyclopedia/index.php/Physical_Science)
    • Plants (http://www.academickids.com/encyclopedia/index.php/Plants)
    • Scientists (http://www.academickids.com/encyclopedia/index.php/Scientists)
  • Social Studies (http://www.academickids.com/encyclopedia/index.php/Social_Studies)
    • Anthropology (http://www.academickids.com/encyclopedia/index.php/Anthropology)
    • Economics (http://www.academickids.com/encyclopedia/index.php/Economics)
    • Government (http://www.academickids.com/encyclopedia/index.php/Government)
    • Religion (http://www.academickids.com/encyclopedia/index.php/Religion)
    • Holidays (http://www.academickids.com/encyclopedia/index.php/Holidays)
  • Space and Astronomy
    • Solar System (http://www.academickids.com/encyclopedia/index.php/Solar_System)
    • Planets (http://www.academickids.com/encyclopedia/index.php/Planets)
  • Sports (http://www.academickids.com/encyclopedia/index.php/Sports)
  • Timelines (http://www.academickids.com/encyclopedia/index.php/Timelines)
  • Weather (http://www.academickids.com/encyclopedia/index.php/Weather)
  • US States (http://www.academickids.com/encyclopedia/index.php/US_States)

Information

  • Home Page (http://academickids.com/encyclopedia/index.php)
  • Contact Us (http://www.academickids.com/encyclopedia/index.php/Contactus)

  • Clip Art (http://classroomclipart.com)
Toolbox
Personal tools