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.

Contents
Introduction
Types of shader
Simplified graphic processing unit pipeline
Parallel processing
Programming Shaders
See also
External links
Further reading
References

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 Units 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 maps 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 Quads (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:
DirectX Version Pixel Shader Vertex Shader
8.0 1.0, 1.1 1.0
8.1 1.2, 1.3, 1.4 1.1
9.0 2.0 2.0
9.0a 2_A, 2_B 2.x
9.0c 3.0 3.0
10.0 4.0 4.0
10.1 4.1 4.?

See also



List of common shading algorithms

External links



Geometry shader tutorial

★ Help scientists do DNA research with the shader units in your ATI graphics card or Playstation 3.

★ nVidia releases a new programming environment and language compiler specifically for writing science applications that run on the shader units of its graphics cards. Also see developer's home page.

OpenGL geometry shader extension

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

David S. Elbert, F. Kenton Musgrave, Darwyn Peachey, Ken Perlin, Steven Worley: ''Texturing and modeling: a procedural approach'', AP Professional, ISBN 0-12-228730-4. Ken Perlin 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


# Search ARB_shader_objects for the issue "32) Can you explain how uniform loading works?". This is an example of how a complex data structure must be broken in basic data elements.
# Required machinery has been introduced in OpenGL by ARB_multitexture but this specification is no more available since its integration in core OpenGL 1.2.
# Search again ARB_shader_objects for the issue "25) How are samplers used to access textures?". You may also want to check out "Subsection 2.14.4 Samplers".

This article provided by Wikipedia. To edit the contents of this article, click here for original source.

psst.. try this: add to faves