Shading language

Last updated

A shading language is a graphics programming language adapted to programming shader effects. Shading languages usually consist of special data types like "vector", "matrix", "color" and "normal".

Contents

Offline rendering

Shading languages used in offline rendering tend to be close to natural language, 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 [1] (RSL or SL, for short), defined in the RenderMan Interface Specification , 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:

Houdini VEX Shading Language

Houdini 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. [2]

Gelato Shading Language

Gelato's [3] 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 (OSL) was developed by Sony Pictures Imageworks for use in its Autodesk Arnold Renderer. It is also used by 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 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).

Historically, a few such languages dominated the market; they are described below.

ARB assembly language

The OpenGL Architecture Review Board established the ARB assembly language in 2002 as a standard low-level instruction set for programmable graphics processors.

High-level OpenGL 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 or glslang, this standardized [4] shading language is meant to be used with OpenGL.

The language unifies vertex and fragment processing in a single instruction set, allowing conditional loops and branches. GLSL was preceded by the ARB assembly language.

Cg programming language

The Cg language, developed by Nvidia, [5] 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 shaders 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. [6]

DirectX High-Level Shader Language

The High-Level Shading Language (HLSL) is a C-style shader language for DirectX 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 added Pixel Bender as part of the Adobe Flash 10 API. Pixel Bender could only process pixel but not 3D-vertex data. Flash 11 introduced an entirely new 3D API called Stage3D, which uses its own shading language called Adobe Graphics Assembly Language (AGAL), which offers full 3D acceleration support. [7] [8] GPU acceleration for Pixel Bender was removed in Flash 11.8. [9] [10]

AGAL is a low-level but platform-independent shading language, which can be compiled, for example, to the ARB assembly language [ citation needed ] or GLSL.

PlayStation Shader Language

Sony announced PlayStation Shader Language (PSSL) as a shading language similar to Cg/HLSL, but specific to the PlayStation 4. 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. [11]

Metal Shading Language

Apple has created a low-level graphics API, called Metal, which runs on most Macs made since 2012, iPhones since the 5S, and iPads since the iPad Air. Metal has its own shading language called Metal Shading Language (MSL), which is based on C++14 and implemented using clang and LLVM. MSL unifies vertex, fragment and compute processing. [12]

WebGPU Shading Language

WebGPU Shading Language (WGSL) is the shader language for WebGPU. That is, an application using the WebGPU API uses WGSL to express the programs, known as shaders, that run on the GPU. [13]

Translation

To port shaders from one shading language to another, a few approaches are used: [14]

Related Research Articles

<span class="mw-page-title-main">OpenGL</span> Cross-platform graphics API

OpenGL 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 hardware-accelerated rendering.

Direct3D is a graphics application programming interface (API) for Microsoft Windows. Part of DirectX, Direct3D is used to render three-dimensional graphics in applications where performance is important, such as games. Direct3D uses hardware acceleration if it is available on the graphics card, allowing for hardware acceleration of the entire 3D rendering pipeline or even only partial acceleration. Direct3D exposes the advanced graphics capabilities of 3D graphics hardware, including Z-buffering, W-buffering, stencil buffering, spatial anti-aliasing, alpha blending, color blending, mipmapping, texture blending, clipping, culling, atmospheric effects, perspective-correct texture mapping, programmable HLSL shaders and effects. Integration with other DirectX technologies enables Direct3D to deliver such features as video mapping, hardware 3D rendering in 2D overlay planes, and even sprites, providing the use of 2D and 3D graphics in interactive media ties.

<span class="mw-page-title-main">High-Level Shader Language</span> 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 for the unified shader model of Direct3D 10 and higher.

Core Image is a pixel-accurate, near-realtime, non-destructive image processing technology in Mac OS X. Implemented as part of the QuartzCore framework of Mac OS X 10.4 and later, Core Image provides a plugin-based architecture for applying filters and effects within the Quartz graphics rendering layer. The framework was later added to iOS in iOS 5.

<span class="mw-page-title-main">Shader</span> Type of program in a graphical processing unit (GPU)

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 specialized functions in computer graphics special effects and video post-processing, as well as general-purpose computing on graphics processing units.

<span class="mw-page-title-main">OpenGL ES</span> Subset of the OpenGL API for embedded systems

OpenGL for Embedded Systems is a subset of the OpenGL computer graphics rendering application programming interface (API) for rendering 2D and 3D computer graphics such as those used by video games, typically hardware-accelerated using a graphics processing unit (GPU). It is designed for embedded systems like smartphones, tablet computers, video game consoles and PDAs. OpenGL ES is the "most widely deployed 3D graphics API in history".

<span class="mw-page-title-main">Software rendering</span> Generating images by computer software

Software rendering is the process of generating an image from a model by means of computer software. In the context of computer graphics rendering, software rendering refers to a rendering process that is not dependent upon graphics hardware ASICs, such as a graphics card. The rendering takes place entirely in the CPU. Rendering everything with the (general-purpose) CPU has the main advantage that it is not restricted to the (limited) capabilities of graphics hardware, but the disadvantage is that more transistors are needed to obtain the same speed.

<span class="mw-page-title-main">OpenGL Shading Language</span> High-level shading language

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 to give developers more direct control of the graphics pipeline without having to use ARB assembly language or hardware-specific languages.

<span class="mw-page-title-main">Perl OpenGL</span>

Perl OpenGL (POGL) is a portable, compiled wrapper library that allows OpenGL to be used in the Perl programming language.

<span class="mw-page-title-main">Unified shader model</span> GPU whose shading hardware has equal capabilities for all stages of rendering

In the field of 3D computer graphics, the unified shader model refers to a form of shader hardware in a graphical processing unit (GPU) where all of the shader stages in the rendering pipeline have the same capabilities. They can all read textures and buffers, and they use instruction sets that are almost identical.

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.

<span class="mw-page-title-main">WebGL</span> JavaScript bindings for OpenGL in web browsers

WebGL is a JavaScript API for rendering interactive 2D and 3D graphics within any compatible web browser without the use of plug-ins. WebGL is fully integrated with other web standards, allowing GPU-accelerated usage of physics, image processing, and effects in the HTML canvas. WebGL elements can be mixed with other HTML elements and composited with other parts of the page or page background.

Stage3D 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 3D graphics, and such applications run natively on Windows, Mac OS X, Linux, Apple iOS and Google Android. Stage3D is similar in purpose and design to WebGL.

<span class="mw-page-title-main">Metal (API)</span> iOS, macOS, and tvOS graphics rendering API

Metal is a low-level, low-overhead hardware-accelerated 3D graphic and compute shader API created by Apple, debuting in iOS 8. Metal combines functions similar to OpenGL and OpenCL in one API. It is intended to improve performance by offering low-level access to the GPU hardware for apps on iOS, iPadOS, macOS, and tvOS. It can be compared to low-level APIs on other platforms such as Vulkan and DirectX 12.

Vulkan is a low-level, low-overhead cross-platform API and open standard for 3D graphics and computing. It was intended to address the shortcomings of OpenGL, and allow developers more control over the GPU. It is designed to support a wide variety of GPUs, CPUs and operating systems, and it is also designed to work with modern multi-core CPUs.

<span class="mw-page-title-main">Standard Portable Intermediate Representation</span> Internal code for computer graphics

Standard Portable Intermediate Representation (SPIR) is an intermediate language for parallel computing and graphics by Khronos Group. It is used in multiple execution environments, including the Vulkan graphics API and the OpenCL compute API, to represent a shader or kernel. It is also used as an interchange language for cross compilation.

This is a glossary of terms relating to computer graphics.

Caustic Graphics was a computer graphics and fabless semiconductor company that developed technologies to bring real-time ray-traced computer graphics to the mass market.

<span class="mw-page-title-main">Cg (programming language)</span> Shading language

Cg and High-Level Shader Language (HLSL) are two names given to a high-level shading language developed by Nvidia and Microsoft for programming shaders. Cg/HLSL is based on the C programming language and although they share the same core syntax, some features of C were modified and new data types were added to make Cg/HLSL more suitable for programming graphics processing units.

References

  1. Staff (1986–2012). "The RISpec". Pixar. Archived from the original on 25 July 2011. Retrieved 9 June 2012.
  2. Staff. "Houdini". Side FX. Side Effects Software Inc. Archived from the original on 22 July 2008. Retrieved 9 June 2012.
  3. NVIDIA Corporation (2003–2008). "Home". NVIDIA Gelato Zone. NVIDIA Corporation. Archived from the original on April 26, 2006. Retrieved 9 June 2012.
  4. Staff (1997–2012). "OpenGL Shading Language". OpenGL. The Khronos Group. Retrieved 9 June 2012.
  5. Staff (2012). "Cg Toolkit". NVIDIA Developer Zone. NVIDIA Corporation. Retrieved 9 June 2012.
  6. "Asm Shader Reference - Win32 apps". learn.microsoft.com. December 10, 2019.
  7. Joseph Labrecque (2011). What's New in Adobe AIR 3 . O'Reilly Media, Inc. pp.  17–26. ISBN   978-1-4493-1108-7.
  8. Remi Arnaud (2011). "3D in a Web Browser". In Eric Lengyel (ed.). Game Engine Gems 2. CRC Press. pp. 207–212. ISBN   978-1-56881-437-7.
  9. "Stage3D". scratch.mit.edu. Retrieved 2014-08-05.
  10. "Adobe Flash Player 11.8 - Bug 3591185: Pixel Bender shader performance drastically degraded in FP11.8. Closed as "NeverFix"". Archived from the original on April 22, 2014.
  11. Stenson, Richard; Ho, Chris. "PlayStation Shading Language for PS4". GDC Europe 2013.
  12. Metal Shading Language Guide
  13. "WebGPU Shading Language".
  14. Pranckevičius, Aras (28 March 2014). "Cross Platform Shaders in 2014 · Aras' website".
  15. "SPIR-V Toolchain". LunarXchange.

Notes

  1. ^ Previous vertex shading languages (in no particular order) for OpenGL include EXT_vertex_shader, NV_vertex_program, the aforementioned ARB_vertex_program, NV_vertex_program2 and NV_vertex_program3.
  2. ^ For fragment shading nvparse is possibly the first shading language featuring high-level abstraction based on NV_register_combiners, NV_register_combiners2 for pixel math and NV_texture_shader, NV_texture_shader2 and NV_texture_shader3 for texture lookups. ATI_fragment_shader did not even provide a "string oriented" parsing facility (although it has been later added by ATI_text_fragment_shader). ARB_fragment_program, has been very successful. NV_fragment_program and NV_fragment_program2 are actually similar although the latter provides much more advanced functionality in respect to others.
  3. ^ Fx composer from NVIDIA home page, http://developer.nvidia.com/object/fx_composer_home.html
  4. Rudy Cortes and Saty Raghavachary: The RenderMan Shading Language Guide, Course Technology PTR, 1 edition (December 27, 2007), ISBN   1-59863-286-8