Shading language
Encyclopedia
A shading language is a special programming language
Programming language
A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine and/or to express algorithms precisely....

 adapted to map on shader
Shader
In the field of computer graphics, a shader is a computer program that is used primarily to calculate rendering effects on graphics hardware with a high degree of flexibility...

 programming. Those kind of languages usually have special data types like color and normal
Surface normal
A surface normal, or simply normal, to a flat surface is a vector that is perpendicular to that surface. A normal to a non-flat surface at a point P on the surface is a vector perpendicular to the tangent plane to that surface at P. The word "normal" is also used as an adjective: a line normal to a...

. Because of the various target markets of 3D graphics, different shading languages have been developed: a brief overview is given below.

Offline rendering

Shading languages used in offline rendering are geared towards maximum image quality. Material properties are totally abstracted, little programming skill and no hardware knowledge is required. These kind of shaders are often developed by artists to get the right "look", just as texture mapping, lighting and other facets of their work.

Processing these kinds of shaders is usually a time-consuming process. The computational power required to get this kind of shading to work can be rather expensive because of their ability to produce photorealistic results. Most of the time, production rendering is run on large computer clusters.

RenderMan Shading Language

The RenderMan Shading Language
RenderMan Shading Language
Renderman Shading Language is a component of the RenderMan Interface Specification, and is used to define shaders. The language syntax is C-like....

 (often referenced as RSL or SL, for short), which is defined in the RenderMan Interface Specification
RenderMan Interface Specification
The RenderMan Interface Specification, or RISpec in short, is an open API developed by Pixar Animation Studios to describe three-dimensional scenes and turn them into digital photorealistic images...

, is the most common shading language for production-quality rendering. It is also one of the first shading languages ever implemented.

The language defines six major shader types:
  • Light source shaders compute the color of the light emitted from a point on the light source towards a point on the surface being illuminated.
  • Surface shaders model the optical properties of the object being illuminated. They output the final color and position of the point being illuminated by taking into account the incoming light and the physical properties of the object.
  • Displacement shaders manipulate the surface's geometry independent of its color.
  • Deformation shaders transform the entire space that a geometry is defined in. Only one RenderMan implementation, the AIR renderer, actually implemented this shader type with the restriction of only supporting a single linear transformation applied to the space (this was more like a Transformation shader, if such a type existed).
  • Volume shaders manipulate the color of a light as it passes through a volume. They create effects like fog
    Fog
    Fog is a collection of water droplets or ice crystals suspended in the air at or near the Earth's surface. While fog is a type of stratus cloud, the term "fog" is typically distinguished from the more generic term "cloud" in that fog is low-lying, and the moisture in the fog is often generated...

    .
  • Imager shaders describe a color transformation to final pixel values. This is much like an image filter
    Digital image processing
    Digital image processing is the use of computer algorithms to perform image processing on digital images. As a subcategory or field of digital signal processing, digital image processing has many advantages over analog image processing...

    , however the imager shader operates on prequantized
    Quantization (image processing)
    Quantization, involved in image processing, is a lossy compression technique achieved by compressing a range of values to a single quantum value. When the number of discrete symbols in a given stream is reduced, the stream becomes more compressible. For example, reducing the number of colors...

     data, which typically has a greater dynamic range than can be displayed on the output device.

Houdini VEX Shading Language

Houdini
Houdini (software)
Houdini is a high-end 3D animation package developed by Side Effects Software which is headquartered in Toronto, Canada. It is a rewrite of the PRISMS ecosystem of standalone tools. Its chief distinction from other packages is that it has been designed as a purely procedural environment...

 VEX (Vector Expressions) shading language (often referenced as VEX, for short) is closely modeled after the RenderMan Shading Language. Since it is integrated into a complete 3D package though, the shader writer has access to information inside the shader which is commonly not available in a rendering context.
The language differences between RSL and VEX are mainly syntactical. A few shadeop
Shadeop
Shadeop is a term used in computer graphics rendering to refer to an atomic, built-in function used in a shader.It is a portmanteau that blends the terms shading and operation.-Meaning in the RenderMan context:...

s have different names.

Gelato Shading Language

Gelato
Gelato (software)
Gelato is a hardware-accelerated, offline renderer created by graphics card manufacturer Nvidia. It was originally intended for use with its Quadro FX GPU, although a Quadro class GPU is no longer a requirement, as it now also supports GeForce cards. Designed to produce film-quality images, Gelato...

's shading language, like Houdini's VEX, is closely modeled after the RenderMan Shading Language.
The differences between Gelato Shading Language and RSL are mainly syntactical -- Gelato uses semicolons instead of commas to separate arguments in function definitions and a few shadeop
Shadeop
Shadeop is a term used in computer graphics rendering to refer to an atomic, built-in function used in a shader.It is a portmanteau that blends the terms shading and operation.-Meaning in the RenderMan context:...

s have different names and parameters.

Real-time rendering

Until recently, developers did not have the same level of control over the output from the graphics pipeline
Graphics pipeline
In 3D computer graphics, the terms graphics pipeline or rendering pipeline most commonly refers to the current state of the art method of rasterization-based rendering as supported by commodity graphics hardware. The graphics pipeline typically accepts some representation of a three-dimensional...

 of graphics cards, but shading languages for real-time rendering are now widespread. They provide both higher hardware abstraction and a more flexible programming model when compared to previous paradigms which hardcoded transformation and shading equations. This results in both giving the programmer greater control over the rendering process, and delivering richer content at lower overhead.

Quite surprisingly, those shaders which are designed to be executed directly on the GPU
Graphics processing unit
A graphics processing unit or GPU is a specialized circuit designed to rapidly manipulate and alter memory in such a way so as to accelerate the building of images in a frame buffer intended for output to a display...

 at the proper point in the pipeline for maximum performance, also scored successes in general processing because of their stream programming
Stream processing
Stream processing is a computer programming paradigm, related to SIMD , that allows some applications to more easily exploit a limited form of parallel processing...

 model.

This kind of shading language is usually bound to a graphics API
Application programming interface
An application programming interface is a source code based specification intended to be used as an interface by software components to communicate with each other...

, although some applications also provide built-in shading languages with limited functionalities.

Historically, only few of those languages were successful in both establishing themselves and maintaining strong market position; a short description of those languages follows below.

ARB low-level assembly language

The OpenGL Architecture Review Board
OpenGL Architecture Review Board
The OpenGL Architecture Review Board is an industry consortium that governed the OpenGL specification.It was formed in 1992, and defined the conformance tests, approved the OpenGL specification and advanced the standard...

 established ARB (GPU assembly language)
ARB (GPU assembly language)
ARB - OpenGL Assembly Language is a low-level shading language. It was created by the OpenGL ARB to standardize GPU instructions controlling the hardware graphics pipeline.-History:...


in 2002 as a standard low-level instruction set for programmable graphics processors.

High-level OpenGL
OpenGL
OpenGL is a standard specification defining a cross-language, cross-platform API for writing applications that produce 2D and 3D computer graphics. The interface consists of over 250 different function calls which can be used to draw complex three-dimensional scenes from simple primitives. OpenGL...

 shading languages compile to ARB for loading and execution. Unlike high-level shading languages, ARB assembly does not support flow control or branching. However, it continues to be used for portability to a variety of GPUs.

OpenGL shading language

Also known as GLSL
GLSL
OpenGL Shading Language , is a high-level shading language based on the syntax of the C programming language...

 or glslang, this standardized high level shading language is meant to be used with OpenGL
OpenGL
OpenGL is a standard specification defining a cross-language, cross-platform API for writing applications that produce 2D and 3D computer graphics. The interface consists of over 250 different function calls which can be used to draw complex three-dimensional scenes from simple primitives. OpenGL...

.

The language unifies vertex
Vertex pipeline
The function of the vertex pipeline in any GPU is to take geometry data , work with it if needed with either fixed function processes , or a vertex shader program , and create all of the 3D data points in a scene to a 2D plane for display on a computer monitor.It is possible to eliminate unneeded...

 and fragment processing
Fragment processing
Fragment processing is a term in computer graphics referring to a collection of operations applied to fragments generated by the rasterization operation in the rendering pipeline....

 in a single instruction set, allowing conditional loops and (more generally) branches
Branch (computer science)
A branch is sequence of code in a computer program which is conditionally executed depending on whether the flow of control is altered or not . The term can be used when referring to programs in high level languages as well as program written in machine code or assembly language...

.

Historically, GLSL was preceded by various OpenGL extensions such as 'ARB vertex program' and 'ARB fragment program'. These preceding extensions were limited, low-level, assembly
Assembly language
An assembly language is a low-level programming language for computers, microprocessors, microcontrollers, and other programmable devices. It implements a symbolic representation of the machine codes and other constants needed to program a given CPU architecture...

-like languages and their usage is now discouraged. The preceding extensions were themselves preceded by other proposals which did not survive in the new version.

Cg programming language

This language developed by NVIDIA
NVIDIA
Nvidia is an American global technology company based in Santa Clara, California. Nvidia is best known for its graphics processors . Nvidia and chief rival AMD Graphics Techonologies have dominated the high performance GPU market, pushing other manufacturers to smaller, niche roles...

 has been designed for easy and efficient production pipeline integration. The language features API independence and comes with a large variety of free tools to improve asset management.

The first Cg
Cg programming language
Cg is a high-level shading language developed by Nvidia in close collaboration with Microsoft for programming vertex and pixel shaders...

 implementation
Implementation
Implementation is the realization of an application, or execution of a plan, idea, model, design, specification, standard, algorithm, or policy.-Computer Science:...

s were rather restrictive because of the hardware being abstracted but they were still innovative when compared to previous methods. Cg seems to have survived the introduction of the newer shading languages very well, mainly of its established momentum in the digital content creation
Digital content creation
Digital Content Creation is a modern term denoting the creation and modification of digital content, such as animation, audio, graphics, images and video, as part of the production process before presentation in its final medium. This large field encompasses many segments such as 3D graphics,...

 area, although the language is seldom used in final products.

A distinctive feature of Cg is the use of connectors, special data structures to link the various stages of processing. Connectors define the input from application to vertex processing stage and the attributes to be interpolated as input to fragment processing.

DirectX High-Level Shader Language

The high level shader language (also called HLSL for short) is a C-style shader language for DirectX
DirectX
Microsoft DirectX is a collection of application programming interfaces for handling tasks related to multimedia, especially game programming and video, on Microsoft platforms. Originally, the names of these APIs all began with Direct, such as Direct3D, DirectDraw, DirectMusic, DirectPlay,...

8, 9, 10, 11, Xbox and Xbox 360. It is similar to Nvidia's Cg but is only supported by DirectX and Xbox game consoles.
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK