from Wikipedia, the free encyclopedia

Shader (" shader " from English shade for shade) are hardware or software modules that implement certain rendering effects in 3D computer graphics .

Hardware shader

Hardware shader (also shaders , shader units ) are small processing units in current graphics chips (Windows since DirectX version 8, platform-independent since OpenGL approachable 2.0). Shaders can be programmed to create 3D effects. While fragment shaders change the fragments and thus can ultimately calculate the resulting pixel color, vertex shaders are used for geometric calculations and dynamic changes to objects. So produce z. B. Both shaders combine the water effect in the computer game Far Cry . They can also be used to simulate lava, paint, fur, etc. Since DirectX 10 or OpenGL 3.2, the third shader type has been added, the geometry shader , which receives the polygon data output by the vertex shader and can edit it even more flexibly, even adding further geometry to the scene (the vertex shader can only manipulate existing geometry). With DirectX 11 and OpenGL 4.0, the tessellation shader was added, which can refine the geometry between the vertex and the geometry shader in two steps (tessellation control and tessellation evaluation (OpenGL terminology) or Hull and domain shaders (DirectX terminology)).

Shader units must not be understood as processing units (such as coprocessors ) that are separate from the rest , but rather as a fixed part of the graphics chip within its rendering pipelines . The vertex shader is just a programmable T&L unit , the pixel shader historically emerged from the combiner - the exact structure of the shader hardware is not fully documented. These shader units conform to the DirectX and OpenGL standards via the graphics driver.

Since the functional scope of vertex and pixel shaders has increased over time, the concept of unified shaders was ultimately developed, in which the hardware difference between vertex and pixel shaders disappears. This also had the advantage that no special hardware was required for the later added shader types (geometry and tessellation), that is, they are implemented with the same hardware that also uses vertex and pixel shaders. All shader units of the graphics chip can now perform the same operations, which means that a fixed separation between the shader types is no longer useful. As a result, the graphics driver can now decide for itself which shader unit is used at what point in time, which potentially means better performance than with graphics cards with fixed shader types.

Processing chain

  • CPU sends control commands and geometry data to the graphics card .
  • The corner points of the geometry are transformed in the vertex shader .
  • In the tessellation shader (more precisely: tessellation control shader and tessellation evaluation shader) the primitives (e.g. triangles) can be further subdivided.
  • If a geometry shader is present and active on the graphics chip, the geometry data now run through it, and further changes are made to the scene.
  • Now the primitive is rasterized, creating individual fragments. The information available only per corner point ( vertex ) is interpolated over the triangular area.
  • In the pixel shader there are arithmetic arithmetic units (shader units) and texture units (texture mapping units, TMUs).
  • After the fragment calculation is completed, the visibility test (Z-test) is performed. If it is visible, a write process takes place in the framebuffer. Under certain circumstances, this step can be carried out immediately after the rasterization (Early Z-Test).


Shaders are written in specially designed languages ​​(in the beginning: assembly language , today: Cg , GLSL , HLSL ) and when the 3D application is running, the graphics card driver translates it into machine code that the graphics card can understand, which is then executed in the shader units. With low-cost graphics chips, however, the shader units are often left out, which means that the shaders have to be calculated using the CPU, which is much slower.

So that the functionality of the shader can also be used uniformly by applications, both DirectX and OpenGL interfaces for your application. Over time, the range of functions and performance of the initially fairly simple shader units have increased significantly; Today their programmability is so advanced that you can use them to do a lot of calculations that previously only CPUs could do, often much faster. This is known as the General Purpose Computation on Graphics Processing Unit .

Problem with different versions

The first hardware shaders were designed to be relatively simple, so a software interface didn't have to offer much. However, as the functionality of the shaders grew over time, the interfaces had to be expanded accordingly, which was often done in consultation with the graphics card manufacturer, especially with DirectX. As a result, not every graphics chip supports every shader version, and there is no upward compatibility . This means that when programming 3D graphics applications with shaders, you have to make sure that there is an alternative solution for older graphics cards that do not support the actually desired shader version, otherwise they cannot display the graphics at all or only display them in a very different way. If an application contains several shader solutions for different shader versions or different graphics cards, it's called these solutions render paths ( English rendering path ). Especially in the phases in which the graphics card's main competitors ATI and Nvidia published their own special shader versions, it was often necessary and therefore common to incorporate two (or more) render paths in applications: one ATI-optimized and one Nvidia-optimized , possibly even more.


Under Direct3D, DirectX's 3D graphics interface, shaders are programmed in the HLSL language, with different shader versions being offered depending on the DirectX version. The following table shows the relationship between the individual DirectX and Shader versions:

Shader Remarks
 pixel  Vertex Geometry domain  Hull 
08.0 1.0 1.0 - - - was intended for the 3dfx Rampage, but it was never released
1.1 1.0 - - - lowest common denominator for all DirectX 8 graphics chips
08.0a 1.2 1.0 - - - especially from the 3DLabs -Grafikchips P9 and P10 supports
1.3 - - - specially supported by the Nvidia GeForce 4 Ti series , the Matrox Parhelia and the SiS Mirage 2
08.1 1.4 - - - especially from the Radeon 8000 series and XGI Volari V3-series supports
09.0 2.0 2.0 - - - lowest common denominator for all DirectX 9 graphics chips
09.0a 2_A 2.x - - - especially from the GeForce FX series supports
09.0b 2 B - - - especially from the ATI Radeon x7xx and X8xx support
09.0c 3.0 3.0 - - - common denominator for more modern DirectX 9 graphics chips
10.0 4.0 4.0 4.0 - - Unified Shader Model, Geometry Shader
10.1 4.1 4.1 4.1 - - Gather4, read z-values ​​from buffers with anti-aliasing
11 5.0 5.0 5.0 5.0 5.0 Support for tessellation through domain and hull shaders in conjunction with a tessellation unit


From version 2.0, OpenGL has its own C -like shader language integrated, the OpenGL Shading Language , or GLSL for short. Previously, shader programming was only possible through manufacturer-dependent interfaces . By using GLSL, you are no longer limited to using proprietary technology or using it on the Windows platform and you can now use shaders on a wide variety of platforms such as macOS or Linux .


  • Uli Theuerjahr: Direct3D Real Time Rendering for computer games. DirectX programming in C ++. Roulio Press, Schönberg 2007, ISBN 978-3-00-022340-2 .

Web links

Individual evidence

  1. ^ AnandTech: A Place for SiS; New Athlon64, P4 and Integrated Graphics Chipsets , July 27, 2004 article
  2. OpenGL Shading Language , documentation on the GLSL