Shading Language
   HOME

TheInfoList



OR:

A shading language is a graphics
programming language A programming language is a system of notation for writing computer programs. Programming languages are described in terms of their Syntax (programming languages), syntax (form) and semantics (computer science), semantics (meaning), usually def ...
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 s ...
effects. Shading languages usually consist of special
data type In computer science and computer programming, a data type (or simply type) is a collection or grouping of data values, usually specified by a set of possible values, a set of allowed operations on these values, and/or a representation of these ...
s like "vector", "
matrix Matrix (: matrices or matrixes) or MATRIX may refer to: Science and mathematics * Matrix (mathematics), a rectangular array of numbers, symbols or expressions * Matrix (logic), part of a formula in prenex normal form * Matrix (biology), the m ...
", "color" and " normal".


Offline rendering

Shading languages used in offline rendering tend to be close to
natural language A natural language or ordinary language is a language that occurs naturally in a human community by a process of use, repetition, and change. It can take different forms, typically either a spoken language or a sign language. Natural languages ...
, so that no special knowledge of programming is required. Offline rendering aims to produce maximum-quality images, at the cost of greater time and compute than real-time rendering.


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 ...
(RSL or SL, for short), 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. A ...
'', is a common shading language for production-quality rendering. It is also one of the first shading languages ever implemented. It defines six major shader types: * ''Light source shaders'' compute the color of light emitted from a point on a light source to a point on a target surface. * ''Surface shaders'' model the color and position of points on an object's surface, based on incoming light and the object's physical properties. * ''Displacement shaders'' manipulate surface geometry independent of color. * ''Deformation shaders'' transform the entire space. Only one RenderMan implementation, the AIR renderer by SiTex Graphics, implemented this shader type, supporting only a single linear transformation applied to the space. * ''Volume shaders'' manipulate the color of 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 influenc ...
. * ''Imager shaders'' describe a color transformation to final pixel values. This is like an image filter, except the imager shader operates on data prior to quantization. Such data have more dynamic range and color resolution than can be displayed on a typical output device.


Houdini VEX Shading Language

Houdini Erik Weisz (March 24, 1874 – October 31, 1926), known professionally as Harry Houdini ( ), was a Hungarian-American escapologist, illusionist, and stunt performer noted for his escape acts. Houdini first attracted notice in vaudeville in ...
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 Shadeop is a term used in Rendering (computer graphics), computer graphics rendering to refer to an atomic, built-in Subroutine, function used in a shader. It is a portmanteau that blends the terms shading and Instruction_(computer_science), ope ...
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
shadeop Shadeop is a term used in Rendering (computer graphics), computer graphics rendering to refer to an atomic, built-in Subroutine, function used in a shader. It is a portmanteau that blends the terms shading and Instruction_(computer_science), ope ...
s have different names and parameters.


Open Shading Language

Open Shading Language (OSL) was developed by
Sony Pictures Imageworks Sony Pictures Imageworks Inc. (simply known as Imageworks) is a visual effects and computer animation studio headquartered in Vancouver, British Columbia and Montreal, Quebec, with an additional office on the Sony Pictures Studios lot in Culver C ...
for use in its
Autodesk Arnold Autodesk Arnold (also known as simply Arnold) is a computer program for rendering three-dimensional, computer-generated scenes using unbiased, physically-based, Monte Carlo path tracing techniques. Created in Spain by Marcos Fajardo, it was ...
Renderer. It is also used by
Blender A blender (sometimes called a mixer (from Latin ''mixus, the PPP of miscere eng. to Mix)'' or liquidiser in British English) is a kitchen and laboratory appliance used to mix, crush, purée or emulsify food and other substances. A stationary ...
'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 Global illumination (GI), or indirect illumination, is a group of algorithms used in 3D computer graphics that are meant to add more realistic lighting Lighting or illumination is the deliberate use of light to achieve practical or aest ...
.


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. They deliver more control and richer content with less overhead. Shaders that are designed to be executed directly on the GPU became useful for high-throughput general processing because of their stream programming model; this led to the development of compute shaders 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, a few such languages dominated the market; they are described 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 in 2002 as a standard low-level instruction set for programmable graphics processors. High-level
OpenGL OpenGL (Open Graphics Library) is a Language-independent specification, cross-language, cross-platform application programming interface (API) for rendering 2D computer graphics, 2D and 3D computer graphics, 3D vector graphics. The API is typic ...
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 pipe ...
or ''glslang'', this standardized shading language is meant to be used with
OpenGL OpenGL (Open Graphics Library) is a Language-independent specification, cross-language, cross-platform application programming interface (API) for rendering 2D computer graphics, 2D and 3D computer graphics, 3D vector graphics. The API is typic ...
. The language unifies vertex and fragment processing in a single instruction set, allowing conditional loops and
branches A branch, also called a ramus in botany, is a stem that grows off from another stem, or when structures like veins in leaves are divided into smaller veins. History and etymology In Old English, there are numerous words for branch, includi ...
. GLSL was preceded by the ARB assembly language.


Cg programming language

The Cg language, developed by
Nvidia Nvidia Corporation ( ) is an American multinational corporation and technology company headquartered in Santa Clara, California, and incorporated in Delaware. Founded in 1993 by Jensen Huang (president and CEO), Chris Malachowsky, and Curti ...
, was designed for easy and efficient production pipeline integration. It features API independence and comes with many 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 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 s ...
s in Shader Model 1.0/1.1, 2.0, and 3.0. It 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.


DirectX High-Level Shader Language

The High-Level Shading Language (HLSL) 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. ( ), formerly Adobe Systems Incorporated, is an American software, computer software company based in San Jose, California. It offers a wide range of programs from web design tools, photo manipulation and vector creation, through to ...
added Pixel Bender as part of the
Adobe Flash Adobe Flash (formerly Macromedia Flash and FutureSplash) is a mostly discontinuedAlthough it is discontinued by Adobe Inc., for the Chinese market it is developed by Zhongcheng and for the international enterprise market it is developed by Ha ...
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 render ...
, 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 pipe ...
.


PlayStation Shader Language

Sony is a Japanese multinational conglomerate (company), conglomerate headquartered at Sony City in Minato, Tokyo, Japan. The Sony Group encompasses various businesses, including Sony Corporation (electronics), Sony Semiconductor Solutions (i ...
announced PlayStation Shader Language (PSSL) as a shading language similar to Cg/HLSL, but specific to 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 ...
. PSSL is said to be largely compatible with the HLSL shader language from DirectX 12, but with additional features for the PS4 and PS5 platforms.


Metal Shading Language

Apple An apple is a round, edible fruit produced by an apple tree (''Malus'' spp.). Fruit trees of the orchard or domestic apple (''Malus domestica''), the most widely grown in the genus, are agriculture, cultivated worldwide. The tree originated ...
has created a low-level
graphics API A graphics library or graphics API is a program library designed to aid in rendering computer graphics to a monitor. This typically involves providing optimized versions of functions that handle common rendering tasks. This can be done purely in ...
, called
Metal A metal () is a material that, when polished or fractured, shows a lustrous appearance, and conducts electrical resistivity and conductivity, electricity and thermal conductivity, heat relatively well. These properties are all associated wit ...
, which runs on most
Mac Mac or MAC may refer to: Common meanings * Mac (computer), a line of personal computers made by Apple Inc. * Mackintosh, a raincoat made of rubberized cloth * Mac, a prefix to surnames derived from Gaelic languages * McIntosh (apple), a Canadi ...
s made since 2012,
iPhone The iPhone is a line of smartphones developed and marketed by Apple that run iOS, the company's own mobile operating system. The first-generation iPhone was announced by then–Apple CEO and co-founder Steve Jobs on January 9, 2007, at ...
s since the 5S, and
iPad The iPad is a brand of tablet computers developed and marketed by Apple Inc., Apple that run the company's mobile operating systems iOS and later iPadOS. The IPad (1st generation), first-generation iPad was introduced on January 27, 2010. ...
s since the
iPad Air The iPad is a brand of tablet computers developed and marketed by Apple that run the company's mobile operating systems iOS and later iPadOS. The first-generation iPad was introduced on January 27, 2010. Since then, the iPad product lin ...
. Metal has its own shading language called Metal Shading Language (MSL), which is based on
C++14 C14, C.XIV or C-14 may refer to: Time * The 14th century * Carbon-14, a radioactive isotope of carbon ** Radiocarbon dating, C-14 dating, a method for dating events Science * IEC 60320#C14, IEC 60320 C14, a polarised, three pole socket electrical ...
and implemented using
clang Clang () is a compiler front end for the programming languages C, C++, Objective-C, Objective-C++, and the software frameworks OpenMP, OpenCL, RenderScript, CUDA, SYCL, and HIP. It acts as a drop-in replacement for the GNU Compiler ...
and
LLVM LLVM, also called LLVM Core, is a target-independent optimizer and code generator. It can be used to develop a Compiler#Front end, frontend for any programming language and a Compiler#Back end, backend for any instruction set architecture. LLVM i ...
. MSL unifies vertex, fragment and compute processing.


WebGPU Shading Language

WebGPU Shading Language WebGPU Shading Language (WGSL) is a High level programming language, high-level shading language with a syntax inspired by Rust (programming language), Rust. It was initially developed by the W3C GPU for the Web Community Group to provide develo ...
(WGSL) is the shader language for
WebGPU WebGPU API is a JavaScript, Rust, C++, and C API for cross-platform efficient graphics processing unit (GPU) access. Using a system's underlying Vulkan, Metal, or Direct3D 12 technologies, WebGPU allows for graphics processing, games, and mor ...
. That is, an application using the WebGPU API uses WGSL to express the programs, known as shaders, that run on the GPU.


Translation

To port shaders from one shading language to another, a few approaches are used: * Define a common interface. For example, Cg/HLSL, GLSL, and MSL all implement
C preprocessor The C preprocessor (CPP) is a text file processor that is used with C, C++ and other programming tools. The preprocessor provides for file inclusion (often header files), macro expansion, conditional compilation, and line control. Although ...
macros, so it is possible to wrap all the different operations into a common interface. Valve's Source 2 and NVIDIA's FXAA 3.11 do this. * Translate one language to the other. For example, DirectX bytecode can be partially converted to GLSL via HLSLcc, and several tools for converting GLSL to HLSL such as
ANGLE In Euclidean geometry, an angle can refer to a number of concepts relating to the intersection of two straight Line (geometry), lines at a Point (geometry), point. Formally, an angle is a figure lying in a Euclidean plane, plane formed by two R ...
and HLSL2GLSL exist. * Define an intermediate language.
SPIR-V Standard Portable Intermediate Representation (SPIR) is an intermediate language for General-purpose computing on graphics processing units, parallel computing and graphics by Khronos Group. It is used in multiple execution environments, including ...
is designed partially for this purpose. It can be generated from HLSL or GLSL, and be decompiled into HLSL, GLSL, or MSL.


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.

# Rudy Cortes and Saty Raghavachary: ''The RenderMan Shading Language Guide'', Course Technology PTR, 1 edition (December 27, 2007),


References

{{Reflist, 2 Programming language classification