OpenGL Shading Language: Difference between revisions

Content deleted Content added
Enlarge the image size by setting it to the default.
added Infobox and unofficial logo
 
(15 intermediate revisions by 12 users not shown)
Line 1:
{{Short description|High-level shading language}}
{{distinguish|Open Shading Language}}
 
{{Infobox software
| 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|[[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.]]
Line 60 ⟶ 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|url-status=live}}</ref>
|3.1
|
Line 67 ⟶ 95:
|#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|url-status=live}}</ref>
|3.2
|
Line 75 ⟶ 103:
|}
 
The two languages are related but not directly compatible. They can be interconverted through [[Standard Portable Intermediate Representation|SPIRSPIRV-Cross]].<ref>{{Citation|title=KhronosGroup/SPIRV-Cross|date=2019-09-06|url=https://github.com/KhronosGroup/SPIRV-Cross|publisher=The Khronos Group|access-date=2019-09-08}}</ref>
 
== Language ==
Line 89 ⟶ 117:
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 |access-date=2020-05-31}}</ref> (implemented for example in Nvidia drivers<ref>{{cite web |title=NVIDIA driver 265.90 WHQL Quadro |url=https://forums.laptopvideo2go.com/topic/27639-nvidia-driver-26590-whql-quadro/?tab=comments#comment-134520 |archive-url=https://web.archive.org/web/20210308165926/https://forums.laptopvideo2go.com/topic/27639-nvidia-driver-26590-whql-quadro/?tab=comments#comment-134520 |url-status=dead |archive-date=March 8, 2021 |website=LaptopVideo2Go Forums }}</ref> on Windows and Linux, and all Mesa 20.0.0<ref>{{cite web |title=Mesa 20.0.0 Release Notes / 2020-02-19 |url=https://www.mesa3d.org/relnotes/20.0.0.html |website=www.mesa3d.org |access-date=2020-05-31 |archive-date=2020-05-12 |archive-url=https://web.archive.org/web/20200512220620/https://mesa3d.org/relnotes/20.0.0.html |url-status=dead }}</ref> drivers on Linux, FreeBSD and Android) implements ability to use {{code|#include}} in source code, allowing easier sharing of code and definitions between many shaders without extra manual pre-processing. Similar extension {{code|GL_GOOGLE_include_directive}} and {{code|GL_GOOGLE_cpp_style_line_directive}} exist for using GLSL with Vulkan, and are supported in reference SPIR-V compiler ({{code|glslang}} aka glslangValidator).<ref>{{cite web |title=#include directive support by antiagainst · Pull Request #46 · KhronosGroup/glslang |url=https://github.com/KhronosGroup/glslang/pull/46 |website=GitHub |access-date=2020-05-31 |language=en}}</ref><ref>{{cite web |title=Preprocessing line number handling by antiagainst · Pull Request #38 · KhronosGroup/glslang |url=https://github.com/KhronosGroup/glslang/pull/38 |website=GitHub |language=en}}</ref><ref>{{cite web |title=Extend the syntax of #line and __FILE__ to support filename strings by antiagainst · Pull Request #43 · KhronosGroup/glslang |url=https://github.com/KhronosGroup/glslang/pull/43 |website=GitHub |language=en}}</ref>
 
==Compilation and execution==
Line 117 ⟶ 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-Level Shader Language|HLSL]], a high-level shading language for use with [[Direct3D]] and [[SPIR-V]]
*[[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 130 ⟶ 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 | firstfirst1=Mike| lastlast1=Bailey | first2=Steve | last2=Cunningham | title = Graphics Shaders: Theory and Practice | edition=2nd | publisher=CRC Press | date=22 April 2009 | isbn = 978-1-56881-434-6 }}
 
==External links==
Line 145 ⟶ 176:
[[Category:OpenGL]]
[[Category:Shading languages]]
[[Category:Virtual reality]]