Shader Article Index for
Shader
 

Information About

Shader




A Shader in the field of Computer Graphics is a set of software instructions, which is used by the graphic resources primarily to perform Rendering effects.


INTRODUCTION

From a technical view a "Shader" is a part of the renderer, which is responsible for calculating the color of an object - as opposed to calculating the visibility of an object.

As Graphics Processing Unit s evolved their ability to provide shading functions, the major graphics libraries such as OpenGL and DirectX began to reflect this by defining
special shading functions in their API . This was introduced in the platform independent graphic library OpenGL version 1.5, and in the proprietary DirectX -Version 8.


Types of shader

The DirectX and OpenGL graphic libraries use three types of shader.

  • Vertex Shaders affect only a series of vertices and thus can only alter vertex properties like position, color, texture coordinate etc. The vertices computed by vertex shaders are typically passed to geometry shaders.

  • Geometry Shaders are used to combine a series of vertices into an object that can be affected by pixel shaders.

  • Pixel Shaders affect individual pixels of an existing primitive, to apply textures, Bump Map s and fog effects for example.


Unified Shader Model unifies the three aforementioned shaders in DirectX 10 . See NVIDIA faqs .

As these shader types are processed within the '' Graphics Processing Unit '' pipeline, the following gives an example how they are embedded in the pipeline:


Simplified graphic processing unit pipeline


  • CPU sends instructions and geometry data to the graphic card respectively the graphic processing unit

  • Within the vertex shader the geometry is transformed and some lighting calculations are performed.

  • If a geometry shader is in the graphic processing unit, some changes of the geometries in the scene are done now.

  • The calculated geometry from the past processes are put in the triangle setup. Furthermore triangles are transformed into Quad s (one Quad is a 2 × 2 pixel primitive.).

  • Pixel shader is applied.

  • Visibility test is performed. If visible, write the pixels in the framebuffer.



PARALLEL PROCESSING


Shaders are written to apply transformations to a large set of elements at a time, for example, to each pixel in an area of the screen, or for every vertex of a model. This is well suited to Parallel Processing , and most modern GPUs have a Multi-core design to facilitate this, vastly improving efficiency of processing.


PROGRAMMING SHADERS

Since the version 1.5, OpenGL has had a C -like Shader-Language available to it, called OpenGL Shading Language , or GLSL. There are also interfaces for the Cg shader language, developed by Nvidia, which is syntactically somewhat similar to GLSL.

In DirectX, shaders are programmed with High Level Shader Language , but the types and complexity of shader programs allowed differ depending on what version of DirectX is used.

The following table shows the relations between DirectX-Versions:


SEE ALSO



EXTERNAL LINKS



FURTHER READING

  • GLSL : ''OpenGL Shading Language @ Lighthouse 3D - GLSL Tutorial''

  • Steve Upstill : ''The RenderMan Companion: A Programmer's Guide to Realistic Computer Graphics'', Addison-Wesley, ISBN 0-201-50868-0

  • is the author of Perlin Noise , an important procedural texturing primitive.

  • Randima Fernando , Mark Kilgard . ''The Cg Tutorial: The Definitive Guide to Programmable Real-Time Graphics,'' Addison-Wesley Professional, ISBN 0-321-19496-9

  • Randi J. Rost : ''OpenGL Shading Language'', Addison-Wesley Professional, ISBN 0-321-19789-5

  • Riemer's DirectX & HLSL Tutorial : ''HLSL Tutorial using DirectX with lots of sample code''

  • GPGPU : ''general purpose GPU''

  • MSDN : DX10 Pipeline Stages



REFERENCES