HOME

TheInfoList



OR:

A shading language is a graphics
programming language A programming language is a system of notation for writing computer programs. Most programming languages are text-based formal languages, but they may also be graphical. They are a kind of computer language. The description of a programming ...
adapted to programming
shader In computer graphics, a shader is a computer program that calculates the appropriate levels of light, darkness, and color during the rendering of a 3D scene - a process known as ''shading''. Shaders have evolved to perform a variety of spec ...
effects (characterizing surfaces, volumes, and objects). Such language forms usually consist of special
data type In computer science and computer programming, a data type (or simply type) is a set of possible values and a set of allowed operations on it. A data type tells the compiler or interpreter how the programmer intends to use the data. Most progra ...
s, like "vector", "
matrix Matrix most commonly refers to: * ''The Matrix'' (franchise), an American media franchise ** ''The Matrix'', a 1999 science-fiction action film ** "The Matrix", a fictional setting, a virtual reality environment, within ''The Matrix'' (franchis ...
", "color" and "
normal Normal(s) or The Normal(s) may refer to: Film and television * ''Normal'' (2003 film), starring Jessica Lange and Tom Wilkinson * ''Normal'' (2007 film), starring Carrie-Anne Moss, Kevin Zegers, Callum Keith Rennie, and Andrew Airlie * ''Norma ...
". Due to the variety of target markets for
3D computer graphics 3D computer graphics, or “3D graphics,” sometimes called CGI, 3D-CGI or three-dimensional computer graphics are graphics that use a three-dimensional representation of geometric data (often Cartesian) that is stored in the computer for th ...
, different shading languages have been developed.


Offline rendering

Shading languages used in offline rendering produce 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 such shaders is time-consuming. The computational power required can be expensive because of their ability to produce photorealistic results. Most of the time, production rendering is run on large
computer cluster A computer cluster is a set of computers that work together so that they can be viewed as a single system. Unlike grid computers, computer clusters have each node set to perform the same task, controlled and scheduled by software. The comp ...
s.


RenderMan Shading Language

The
RenderMan Shading Language Renderman Shading Language (abbreviated RSL) is a component of the RenderMan Interface Specification, and is used to define shaders. The language syntax is C-like. A shader written in RSL can be used without changes on any RenderMan-compliant rend ...
(often referenced as RSL or SL, for short), which is defined in the ''
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. It includes the RenderMan Shading Language. As ...
'' 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 target surface. * ''Surface shaders'' model the optical properties of an illuminated object. They output the final color and position of the point by considering the incoming light and the object's physical properties. * ''Displacement shaders'' manipulate surface geometry independent of color. * ''Deformation shaders'' transform the entire space of a geometry. Only one RenderMan implementation, the AIR renderer by SiTex Graphics, implemented this shader type, supporting only 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 such as
fog Fog is a visible aerosol consisting of tiny water droplets or ice crystals suspended in the air at or near the Earth's surface. Reprint from Fog can be considered a type of low-lying cloud usually resembling stratus, and is heavily influ ...
. * ''Imager shaders'' describe a color transformation to final pixel values. This is much like an
image filter An image is a visual representation of something. It can be two-dimensional, three-dimensional, or somehow otherwise feed into the visual system to convey information. An image can be an artifact, such as a photograph or other two-dimensiona ...
, however the imager shader operates on data prior to quantization. Such data has a greater dynamic range and color resolution than can be displayed on a typical output device.


Houdini VEX Shading Language

Houdini Harry Houdini (, born Erik Weisz; March 24, 1874 – October 31, 1926) was a Hungarian-American escape artist, magic man, and stunt performer, noted for his escape acts. His pseudonym is a reference to his spiritual master, French magician ...
VEX (Vector Expressions) shading language (often abbreviated to "VEX") is closely modeled after RenderMan. However, its integration into a complete 3D package means that the shader writer can access the information inside the shader, a feature that is not usually available in a rendering context. The language differences between RSL and VEX are mainly syntactic, in addition to differences regarding the names of several shadeop names.


Gelato Shading Language

Gelato's shading language, like Houdini's VEX, is closely modeled after RenderMan. 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 shadeops have different names and parameters.


Open Shading Language

Open Shading Language Open Shading Language (OSL) is a shading language developed by Sony Pictures Imageworks for use in its Arnold Renderer. It is also supported by Illumination Research's 3Delight renderer, Otoy's Octane Render, V-Ray 3, Redshift (from April 20 ...
(OSL) was developed by
Sony Pictures Imageworks Sony Pictures Imageworks Inc. is a Canadian visual effects and computer animation studio headquartered in Vancouver, British Columbia, with an additional office on the Sony Pictures Studios lot in Culver City, California. SPI is a unit of Sony Pi ...
for use in its Arnold Renderer. It is also used by
Blender A blender (sometimes called a mixer or liquidiser in British English) is a kitchen appliance, kitchen and laboratory appliance used to mix, crush, purée or emulsion, emulsify food and other substances. A stationary blender consists of a blender ...
's Cycles render engine. OSL's surface and volume shaders define how surfaces or volumes scatter light in a way that allows for importance sampling; thus, it is well suited for physically-based renderers that support ray tracing and global illumination.


Real-time rendering

Shading languages for
real-time rendering Real-time computer graphics or real-time rendering is the sub-field of computer graphics focused on producing and analyzing images in real time. The term can refer to anything from rendering an application's graphical user interface ( GUI) to ...
are now widespread. They provide both higher hardware abstraction and a more flexible programming model than previous paradigms which hardcoded transformation and shading equations. This gives the programmer greater control over the rendering process and delivers richer content at lower overhead. Shaders that are designed to be executed directly on the
GPU A graphics processing unit (GPU) is a specialized electronic circuit designed to manipulate and alter memory to accelerate the creation of images in a frame buffer intended for output to a display device. GPUs are used in embedded systems, mobi ...
became useful for high throughput general processing because of their
stream programming In computer science, stream processing (also known as event stream processing, data stream processing, or distributed stream processing) is a programming paradigm which views data streams, or sequences of events in time, as the central input and ou ...
model; this led to the development of
compute shader In computing, a compute kernel is a routine compiled for high throughput accelerators (such as graphics processing units (GPUs), digital signal processors (DSPs) or field-programmable gate arrays (FPGAs)), separate from but used by a main prog ...
s running on similar hardware (see also:
GPGPU General-purpose computing on graphics processing units (GPGPU, or less often GPGP) is the use of a graphics processing unit (GPU), which typically handles computation only for computer graphics, to perform computation in applications traditiona ...
). Historically, only few such languages were successful in both establishing themselves and maintaining strong market position; a short description of those languages follows below.


ARB assembly language

The
OpenGL Architecture Review Board The OpenGL Architecture Review Board (ARB) was 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. On July 31, 2006, ...
established the
ARB assembly language ARB assembly language is a low-level shading language, which can be characterized as an assembly language. It was created by the OpenGL Architecture Review Board (ARB) to standardize GPU instructions controlling the hardware graphics pipeline. Hi ...
in 2002 as a standard low-level instruction set for programmable graphics processors. High-level
OpenGL OpenGL (Open Graphics Library) is a cross-language, cross-platform application programming interface (API) for rendering 2D and 3D vector graphics. The API is typically used to interact with a graphics processing unit (GPU), to achieve hardwa ...
shading languages often compile to ARB assembly for loading and execution. Unlike high-level shading languages, ARB assembly does not support control flow or branching. However, it continues to be used when cross-GPU portability is required.


OpenGL shading language

Also known as
GLSL OpenGL Shading Language (GLSL) is a high-level shading language with a syntax based on the C programming language. It was created by the OpenGL ARB (OpenGL Architecture Review Board) to give developers more direct control of the graphics pipeli ...
or ''glslang'', this standardized shading language is meant to be used with
OpenGL OpenGL (Open Graphics Library) is a cross-language, cross-platform application programming interface (API) for rendering 2D and 3D vector graphics. The API is typically used to interact with a graphics processing unit (GPU), to achieve hardwa ...
. The language unifies
vertex Vertex, vertices or vertexes may refer to: Science and technology Mathematics and computer science *Vertex (geometry), a point where two or more curves, lines, or edges meet *Vertex (computer graphics), a data structure that describes the position ...
and fragment processing in a single instruction set, allowing conditional loops and (more generally)
branches A branch, sometimes called a ramus in botany, is a woody structural member connected to the central trunk of a tree (or sometimes a shrub). Large branches are known as boughs and small branches are known as twigs. The term ''twig'' usually ...
. Historically, GLSL was preceded by the
ARB assembly language ARB assembly language is a low-level shading language, which can be characterized as an assembly language. It was created by the OpenGL Architecture Review Board (ARB) to standardize GPU instructions controlling the hardware graphics pipeline. Hi ...
.


Cg programming language

The programming language Cg, developed by
NVIDIA Nvidia CorporationOfficially written as NVIDIA and stylized in its logo as VIDIA with the lowercase "n" the same height as the uppercase "VIDIA"; formerly stylized as VIDIA with a large italicized lowercase "n" on products from the mid 1990s to ...
, was 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. Development of Cg was stopped in 2012 and the language is now deprecated.


DirectX Shader Assembly Language

The shader assembly language in Direct3D 8 and 9 is the main programming language for
vertex Vertex, vertices or vertexes may refer to: Science and technology Mathematics and computer science *Vertex (geometry), a point where two or more curves, lines, or edges meet *Vertex (computer graphics), a data structure that describes the position ...
and
pixel shader In computer graphics, a shader is a computer program that calculates the appropriate levels of light, darkness, and color during the rendering of a 3D scene - a process known as ''shading''. Shaders have evolved to perform a variety of spec ...
s in
Shader Model The High-Level Shader Language or High-Level Shading Language (HLSL) is a proprietary shading language developed by Microsoft for the Direct3D 9 API to augment the shader assembly language, and went on to become the required shading language ...
1.0/1.1, 2.0, and 3.0. The shader assembly language is a direct representation of the intermediate shader bytecode which is passed to the graphics driver for execution. The shader assembly language cannot be directly used to program unified Shader Model 4.0, 4.1, 5.0, and 5.1, although it retains its function as a representation of the intermediate bytecode for debug purposes.MSDN - DirectX and Gaming - Asm Shader Reference
/ref>


DirectX High-Level Shader Language

The
High-Level Shading Language The High-Level Shader Language or High-Level Shading Language (HLSL) is a proprietary shading language developed by Microsoft for the Direct3D 9 API to augment the shader assembly language, and went on to become the required shading language ...
(also called HLSL for short) is a C-style shader language for
DirectX Microsoft DirectX is a collection of application programming interfaces (APIs) for handling tasks related to multimedia, especially game programming and video, on Microsoft platforms. Originally, the names of these APIs all began with "Direct", ...
9 and higher and Xbox game consoles. It is related to Nvidia's Cg but is only supported by DirectX and Xbox. HLSL programs are compiled into bytecode equivalent of DirectX shader assembly language. HLSL was introduced as an optional alternative to the shader assembly language in Direct3D 9, but became a requirement in Direct3d 10 and higher, where the shader assembly language is deprecated.


Adobe Pixel Bender and Adobe Graphics Assembly Language

Adobe Systems Adobe Inc. ( ), originally called Adobe Systems Incorporated, is an American multinational computer software company incorporated in Delaware and headquartered in San Jose, California. It has historically specialized in software for the crea ...
added
Pixel Bender Adobe Pixel Bender, previously codenamed Hydra, is a programming language created by Adobe Systems for the description of image processing algorithms. The syntax is based on GLSL, and a Pixel Bender program is analogous to an OpenGL fragment ...
as part of the
Adobe Flash Adobe Flash (formerly Macromedia Flash and FutureSplash) is a multimedia Computing platform, software platform used for production of Flash animation, animations, rich web applications, application software, desktop applications, mobile apps, mo ...
10 API. Pixel Bender could only process pixel but not 3D-vertex data. Flash 11 introduced an entirely new 3D API called
Stage3D Stage3D ( codenamed ''Molehill'') is an Adobe Flash Player API for rendering interactive 3D graphics with GPU-acceleration, within Flash games and applications. Flash Player or AIR applications written in ActionScript 3 may use Stage3D to rend ...
, which uses its own shading language called Adobe Graphics Assembly Language (AGAL), which offers full 3D acceleration support. GPU acceleration for Pixel Bender was removed in Flash 11.8. AGAL is a low-level but platform-independent shading language, which can be compiled, for example, or
GLSL OpenGL Shading Language (GLSL) is a high-level shading language with a syntax based on the C programming language. It was created by the OpenGL ARB (OpenGL Architecture Review Board) to give developers more direct control of the graphics pipeli ...
.


PlayStation Shader Language

Sony , commonly stylized as SONY, is a Japanese multinational conglomerate corporation headquartered in Minato, Tokyo, Japan. As a major technology company, it operates as one of the world's largest manufacturers of consumer and professional ...
announced PSSL (
PlayStation Shader Language The PlayStation 4 system software is the updatable firmware and operating system of the PlayStation 4. The operating system is Orbis OS, based on FreeBSD 9. Technology System The native operating system of the PlayStation 4 is Orbis OS, whi ...
) as a platform-specific shading language similar to Cg/HLSL for the
PlayStation 4 The PlayStation 4 (PS4) is a home video game console developed by Sony Interactive Entertainment. Announced as the successor to the PlayStation 3 in February 2013, it was launched on November 15, 2013, in North America, November 29, 2013 in ...
. It is said to be largely compatible with HLSL shaders on PC, but with additional features for the PS4 platform.


Metal Shading Language

Apple has created a low-level graphics API called
Metal A metal (from Greek μέταλλον ''métallon'', "mine, quarry, metal") is a material that, when freshly prepared, polished, or fractured, shows a lustrous appearance, and conducts electricity and heat relatively well. Metals are typicall ...
, which runs on most Macs made since 2012, iPhones since the 5S, and iPads since the iPad Air. Metal introduces its own shading language called Metal Shading Language (MSL), which is based on
C++14 C++14 is a version of the ISO/IEC 14882 standard for the C++ programming language. It is intended to be a small extension over C++11, featuring mainly bug fixes and small improvements, and was replaced by C++17. Its approval was announced on August ...
and implemented using
clang Clang is a compiler front end for the C, C++, Objective-C, and Objective-C++ programming languages, as well as the OpenMP, OpenCL, RenderScript, CUDA, and HIP frameworks. It acts as a drop-in replacement for the GNU Compiler Collection (GCC), ...
and
LLVM LLVM is a set of compiler and toolchain technologies that can be used to develop a front end for any programming language and a back end for any instruction set architecture. LLVM is designed around a language-independent intermediate represen ...
. MSL unifies vertex, fragment and compute processing.


WebGPU Shading Language

WebGPU Shading Language (WGSL) is the shader language for
WebGPU WebGPU is the working name for a future web standard and JavaScript API for accelerated graphics and compute, aiming to provide "modern 3D graphics and computation capabilities". It is developed by the W3C ''GPU for the Web'' Community Group wi ...
. That is, an application using the WebGPU API uses WGSL to express the programs, known as shaders, that run on the GPU.


Translation

As more and more graphics APIs become available, developers face the problem of porting shaders from one shading languages to another. A few approaches are used: * Manual switching using
C preprocessor The C preprocessor is the macro preprocessor for the C, Objective-C and C++ computer programming languages. The preprocessor provides the ability for the inclusion of header files, macro expansions, conditional compilation, and line control ...
(CPP) statements. Cg/HLSL, GLSL, and MSL all implement CPP macros, so it is possible to wrap all the different operations into a common interface. Valve's Source 2 and NVIDIA's
FXAA Fast approximate anti-aliasing (FXAA) is a screen-space Spatial anti-aliasing, anti-aliasing algorithm created by Timothy Lottes at Nvidia. FXAA 3 is released under a public domain license. A later version, FXAA 3.11, is released under a 3-clause ...
3.11 do this. * Translate one language to the other. DirectX bytecode partially can be converted to GLSL via HLSLcc, and several tools for converting GLSL to HLSL such as
ANGLE In Euclidean geometry, an angle is the figure formed by two Ray (geometry), rays, called the ''Side (plane geometry), sides'' of the angle, sharing a common endpoint, called the ''vertex (geometry), vertex'' of the angle. Angles formed by two ...
and HLSL2GLSL exist. * Define a different intermediate language.
SPIR-V Standard Portable Intermediate Representation (SPIR) is an intermediate language for parallel compute and graphics by Khronos Group. It is used in multiple execution environments, including the Vulkan graphics API and the OpenCL compute API, to re ...
is designed partially for this purpose. It can be generated from HLSL or GLSL, and be decompiled into HLSL, GLSL, or MSL.


References


Notes

# Previous vertex shading languages (in no particular order) for OpenGL includ
EXT_vertex_shaderNV_vertex_program
the aforementione
ARB_vertex_programNV_vertex_program2
an
NV_vertex_program3
# For fragment shadin

is possibly the first shading language featuring high-level abstraction based o
NV_register_combinersNV_register_combiners2
for pixel math an
NV_texture_shaderNV_texture_shader2
an
NV_texture_shader3
for texture lookups
ATI_fragment_shader
did not even provide a "string oriented" parsing facility (although it has been later added b
ATI_text_fragment_shader

ARB_fragment_program
has been very successful
NV_fragment_program
an
NV_fragment_program2
are actually similar although the latter provides much more advanced functionality in respect to others. # Fx composer from NVIDIA home page, http://developer.nvidia.com/object/fx_composer_home.html # Rudy Cortes and Saty Raghavachary: ''The RenderMan Shading Language Guide'', Course Technology PTR, 1 edition (December 27, 2007), {{ISBN, 1-59863-286-8 Programming language classification