Shader

From Wikipedia, the free encyclopedia

(Redirected from Shader model)
Jump to: navigation, search

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. Shaders are used to allow a 3D application designer to program the GPU (Graphics Processing Unit) "programmable pipeline", which has mostly superseded the older "fixed-function pipeline", allowing more flexibility in making use of advanced GPU programmability features.

Contents

From a technical view a "shader" is a part of the renderer, which is responsible for calculating the color of an object.

As Graphics Processing Units evolved, major graphics software libraries such as OpenGL and DirectX began to exhibit enhanced ability to program these new GPUs by defining special shading functions in their API. Changes were introduced to reflect shader capabilities in the platform independent graphics library OpenGL version 1.5, and in the proprietary DirectX-Version 8.

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

  • Vertex shaders affect only a series of vertices and thus can only alter vertex properties like position, color, and texture coordinate. The vertices computed by vertex shaders are typically passed to geometry shaders.[vague]
  • Geometry shaders can add and remove vertices from a mesh. Geometry shaders can be used to procedurally generate geometry or to add volumetric detail to existing meshes that would be too costly to process on the CPU.
  • Pixel shaders, more correctly known as Fragment shaders, calculate the color value of individual pixels when the polygons produced by the vertex & geometry shaders are rasterized. They are typically used for scene lighting and related effects such as bump mapping and color toning.

The Unified shader model unifies the three aforementioned shaders in OpenGL and DirectX 10. See NVIDIA faqs.

As these shader types are processed within the GPU pipeline, the following gives an example how they are embedded in the pipeline:

For more details on this topic, see Graphics pipeline.
  • The CPU sends instructions (compiled shading language programs) and geometry data to the graphics processing unit, located on the graphics card.
  • Within the vertex shader, the geometry is transformed and lighting calculations are performed.
  • If a geometry shader is in the graphic processing unit, some changes of the geometries in the scene are peformed.
  • The calculated geometry is triangulated (subdivided into triangles).
  • Triangles are transformed into pixel quads (one pixel quad is a 2 × 2 pixel primitive).
  • Pixel shader(s) is applied.
  • Visibility test(s) are performed. If visible, write the pixels in the framebuffer.[vague]

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.

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, or HLSL, 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, 1.1
8.1 1.2, 1.3, 1.4 1.0, 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.?

  1. ^  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.
  2. ^  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.
  3. ^  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".
Advanced Search
Included Web Search Engines


Safe Search

close

Top Matching Results

Occasionally Search.com will highlight specialized results that are based on the context of your query. Examples of specialized results include specific links to news, images, or video.

Top Matching Results may highlight information from other Search.com pages, content from the CNET Network of sites, or third party content. The listings are based purely on relevance. Search.com does not receive payment for listings in this section but our partners that provide this data may get paid for listing these products.

Sponsored Links

This section contains paid listings which have been purchased by companies that want to have their sites appear for specific search terms and related content. These listings are administered, sorted and maintained by a third party and are not endorsed by Search.com.

Search Results

Search.com sends your search query to several search engines at one time and integrates the results into one list which has been sorted by relevance using Search.com's proprietary algorithm. You can customize the list of search engines included in your metasearch from the preferences.

The search engines that are used in your metasearch may allow companies to pay to have their Web sites included within the results. To view the Paid Inclusion policy for a specific search engine, please visit their Web site. Search.com does not accept payment or share revenue with any search engine partner for listings in this section.