Content deleted Content added
Typo haveing -> having |
Jim McKeeth (talk | contribs) added Infobox and unofficial logo |
||
(29 intermediate revisions by 24 users not shown) | |||
Line 1:
{{Short description|High-level shading language}}
{{distinguish|Open Shading Language}}
{{Infobox software
[[File:Linux kernel and OpenGL video games.svg|thumb|300px|[[Video games]] outsource rendering calculations to the [[Graphics processing unit|GPU]] over [[OpenGL]] in real-time. Shaders are written in '''OpenGL Shading Language''' and compiled. The compiled programs are executed on the GPU.]]▼
| name = GLSL
| title = GLSL
| logo = GLSL_Logo_(Unofficial).svg
| logo size = x64px
| logo caption = ''Unofficial logo''
| screenshot =
| caption =
| collapsible =
| author = [[OpenGL ARB]]
| developer = [[Khronos Group]]
| released = {{Start date and age|2002|07|24}} (as an extension)
| discontinued =
| latest_release_version = 4.60.8
| latest_release_date = {{Start date and age|2023|08|14}}<ref>{{cite web|url=https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.4.60.html|title=The OpenGL® Shading Language, Version 4.60.8}}</ref>
| latest preview version =
| latest preview date = <!-- {{Start date and age|YYYY|MM|DD|df=yes/no}} -->
| programming language =
| operating_system =
| platform = [[Cross-platform]]
| size =
| genre = [[Programming Language]]
| license =
| website =
| standard =
| AsOf =
}}
▲[[File:Linux kernel and OpenGL video games.svg|thumb
'''OpenGL Shading Language''' ('''GLSL''') is a [[High level programming language|high-level]] [[shading language]] with a syntax based on the [[C (programming language)|C programming language]]. It was created by the [[OpenGL ARB]] (OpenGL Architecture Review Board) to give developers more direct control of the [[graphics pipeline]] without having to use [[ARB assembly language]] or hardware-specific languages.
Line 59 ⟶ 88:
| 3.00.6<ref>{{cite web|url=https://www.khronos.org/registry/OpenGL/specs/es/3.0/GLSL_ES_Specification_3.00.pdf|title=GLSL ES Language Specification, Version 3.00, revision 6}}</ref> || 3.0 || 2.0 || 3.30 || 29 January 2016 || #version 300 es
|-
|3.10.5<ref>{{Cite web|title=The OpenGL ES® Shading Language, version 3.10, revision 5|url=https://www.khronos.org/registry/OpenGL/specs/es/3.1/GLSL_ES_Specification_3.10.pdf}}</ref>
|3.1
|
|GLSL ES 3.00
|29 January 2016
|#version 310 es
|-
|3.20.6<ref>{{Cite web|title=The OpenGL ES® Shading Language, Version 3.20.6|url=https://www.khronos.org/registry/OpenGL/specs/es/3.2/GLSL_ES_Specification_3.20.pdf}}</ref>
|3.2
|
|GLSL ES 3.10
|10 July 2019
|#version 320 es
|}
The two languages are related but not directly compatible. They can be interconverted through [[Standard Portable Intermediate Representation|
== Language ==
===Operators===
GLSL contains the same operators as the [[operators in C and C++]], with the exception of [[Pointer (computer programming)|pointer]]s. [[Bitwise operators]] were added in version 1.30.
===Functions and control structures===
Similar to the [[C (programming language)|C programming language]], GLSL supports loops and branching, for instance: if-else, for, switch, etc. Recursion is forbidden and checked for during compilation.
User-defined functions are supported and built-in functions are provided. The graphics card manufacturer may optimize built-in functions at the hardware level. Many of these functions are similar to those in the math library of the C programming language while others are specific to graphics programming. Most of the built-in functions and operators, can operate both on scalars and vectors (up to 4 elements), for one or both operands. Common built-in functions that are provided and are commonly used for graphics purposes are: {{code|mix}}, {{code|smoothstep}}, {{code|normalize}}, {{code|
=== Preprocessor ===
GLSL defines a subset of the [[C preprocessor]] (CPP), combined with its own special directives for specifying versions and OpenGL extensions. The parts removed from CPP are those relating to file names such as {{code|#include}} and {{code|__FILE__}}.<ref>{{cite book |title=OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 4.3, Eighth Edition |url=https://www.oreilly.com/library/view/opengl-programming-guide/9780132748445/ch02lev2sec5.html |language=en |chapter=Shader Preprocessor}}</ref>
The {{code|GL_ARB_shading_language_include}} extension<ref>{{cite web |title=ARB_shading_language_include |url=https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_shading_language_include.txt |website=Khronos.org |
==Compilation and execution==
GLSL shaders are not stand-alone applications; they require an application that utilizes the OpenGL API, which is available on many different platforms (e.g., [[Linux]], [[macOS]], [[Microsoft Windows|Windows]]). There are language bindings for [[C (programming language)|C]], [[C++]], [[C sharp (programming language)|C#]], [[JavaScript]], [[Delphi (programming language)|Delphi]], [[Java (programming language)|Java]], and many more.
GLSL shaders themselves are simply a set of [[String (computer science)|strings]] that are passed to the hardware vendor's driver for compilation from within an application using the OpenGL API's entry points. Shaders can be created [[Wiktionary:on the fly|on the fly]] from within an application, or read-in as text files, but must be sent to the driver in the form of a string.
Line 104 ⟶ 145:
*[[ARB assembly language]], a low-level shading language
*[[Cg (programming language)|Cg]], a high-level shading language for programming vertex and pixel shaders
*[[High-
*[[TGSI]], a low-level intermediate language introduced by [[Gallium3D]]
*[[AMDIL]], a low-level intermediate language used internally at AMD
*[[RenderMan Shading Language]]
*[[WebGPU Shading Language|WGSL]], a shading language with a Rust-like syntax for WebGPU originally based on [[SPIR-V]]
*[[Metal (API)|Metal Shading Language]], a shading language used with [[Apple Inc.|Apple]] platform's proprietary Metal [[Graphics API]]<ref>{{cite web|url=https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf]|title=Metal Shading Language Specification Version 3.2}}</ref>
*[[Open Shading Language]], a shading language developed by [[Sony Pictures Imageworks]]
== References ==
Line 117 ⟶ 161:
* {{cite book | first=Randi J. | last=Rost | author-link = Randi J. Rost | title=OpenGL Shading Language | edition=3rd |publisher=Addison-Wesley | date=30 July 2009 | isbn = 978-0-321-63763-5 }}
* {{cite book | first1=John | last1=Kessenich | first2=David | last2=Baldwin | first3=Randi | last3=Rost | title = The OpenGL Shading Language | version=Version 1.10.59 | publisher = 3Dlabs, Inc. Ltd. }}
* {{cite book |
==External links==
Line 132 ⟶ 176:
[[Category:OpenGL]]
[[Category:Shading languages]]
[[Category:Virtual reality]]
|