Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Shader
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Types == There are three types of shaders in common use (pixel, vertex, and geometry shaders), with several more recently added. While older graphics cards utilize separate processing units for each shader type, newer cards feature [[unified shader]]s which are capable of executing any type of shader. This allows graphics cards to make more efficient use of processing power. === 2D shaders === 2D shaders act on [[digital images]], also called [[texture (computer graphics)|''textures'']] in the field of computer graphics. They modify attributes of [[pixel]]s. 2D shaders may take part in rendering [[3d geometry|3D geometry]]. Currently the only type of 2D shader is a pixel shader. ==== Pixel shaders ==== Pixel shaders, also known as [[fragment (computer graphics)|fragment]] shaders, compute [[color]] and other attributes of each "fragment": a unit of rendering work affecting at most a single output [[pixel]]. The simplest kinds of pixel shaders output one screen [[pixel]] as a color value; more complex shaders with multiple inputs/outputs are also possible.<ref>{{cite web|url=http://www.lighthouse3d.com/tutorials/glsl-tutorial/fragment-shader/|title=GLSL Tutorial – Fragment Shader|date=June 9, 2011}}</ref> Pixel shaders range from simply always outputting the same color, to applying a [[lighting]] value, to doing [[bump mapping]], [[shadows]], [[specular highlight]]s, [[translucency]] and other phenomena. They can alter the depth of the fragment (for [[Z-buffering]]), or output more than one color if multiple [[render target]]s are active. In 3D graphics, a pixel shader alone cannot produce some kinds of complex effects because it operates only on a single fragment, without knowledge of a scene's geometry (i.e. vertex data). However, pixel shaders do have knowledge of the screen coordinate being drawn, and can sample the screen and nearby pixels if the contents of the entire screen are passed as a texture to the shader. This technique can enable a wide variety of two-dimensional [[Post processing (images)|postprocessing]] effects such as [[Gaussian blur|blur]], or [[edge detection]]/enhancement for [[Cel shader|cartoon/cel shaders]]. Pixel shaders may also be applied in ''intermediate'' stages to any two-dimensional images—[[sprite (computer graphics)|sprite]]s or [[texture (computer graphics)|texture]]s—in the [[Graphics pipeline|pipeline]], whereas [[vertex shaders]] always require a 3D scene. For instance, a pixel shader is the only kind of shader that can act as a [[video postprocessing|postprocessor]] or [[video filter|filter]] for a [[video stream]] after it has been [[rasterization|rasterized]]. === 3D shaders === 3D shaders act on [[3D model]]s or other geometry but may also access the colors and textures used to draw the model or [[Polygon mesh|mesh]]. Vertex shaders are the oldest type of 3D shader, generally making modifications on a per-vertex basis. Newer geometry shaders can generate new vertices from within the shader. Tessellation shaders are the newest 3D shaders; they act on batches of vertices all at once to add detail—such as subdividing a model into smaller groups of triangles or other primitives at runtime, to improve things like [[curve]]s and [[:wikt:bump|bump]]s, or change other attributes. ==== Vertex shaders ==== Vertex shaders are run once for each 3D [[vertex (computer graphics)|vertex]] given to the graphics processor. The purpose is to transform each vertex's 3D position in virtual space to the 2D coordinate at which it appears on the screen (as well as a depth value for the Z-buffer).<ref>{{cite web|url=http://www.lighthouse3d.com/tutorials/glsl-tutorial/vertex-shader/|title=GLSL Tutorial – Vertex Shader|date=June 9, 2011}}</ref> Vertex shaders can manipulate properties such as position, color and texture coordinates, but cannot create new vertices. The output of the vertex shader goes to the next stage in the pipeline, which is either a geometry shader if present, or the [[rasterizer]]. Vertex shaders can enable powerful control over the details of position, movement, lighting, and color in any scene involving [[3D model]]s. ==== Geometry shaders ==== Geometry shaders were introduced in Direct3D 10 and OpenGL 3.2; formerly available in OpenGL 2.0+ with the use of extensions.<ref>[http://www.opengl.org/wiki/Geometry_Shader Geometry Shader - OpenGL]. Retrieved on December 21, 2011.</ref> This type of shader can generate new graphics [[primitive (geometry)|primitive]]s, such as points, lines, and triangles, from those primitives that were sent to the beginning of the [[graphics pipeline]].<ref>{{cite web|url=http://msdn.microsoft.com/en-us/library/bb205123(VS.85).aspx|title=Pipeline Stages (Direct3D 10) (Windows)|website=msdn.microsoft.com|date=January 6, 2021 }}</ref> Geometry shader programs are executed after vertex shaders. They take as input a whole primitive, possibly with adjacency information. For example, when operating on triangles, the three vertices are the geometry shader's input. The shader can then emit zero or more primitives, which are rasterized and their fragments ultimately passed to a [[pixel shader]]. Typical uses of a geometry shader include point sprite generation, geometry [[Tessellation (computer graphics)|tessellation]], [[shadow volume]] extrusion, and single pass rendering to a [[cube map]]. A typical real-world example of the benefits of geometry shaders would be automatic mesh complexity modification. A series of line strips representing control points for a curve are passed to the geometry shader and depending on the complexity required the shader can automatically generate extra lines each of which provides a better approximation of a curve. ==== Tessellation shaders ==== As of OpenGL 4.0 and Direct3D 11, a new shader class called a tessellation shader has been added. It adds two new shader stages to the traditional model: tessellation control shaders (also known as hull shaders) and tessellation evaluation shaders (also known as Domain Shaders), which together allow for simpler meshes to be subdivided into finer meshes at run-time according to a mathematical function. The function can be related to a variety of variables, most notably the distance from the viewing camera to allow active [[level of detail (computer graphics)|level-of-detail]] scaling. This allows objects close to the camera to have fine detail, while further away ones can have more coarse meshes, yet seem comparable in quality. It also can drastically reduce required mesh bandwidth by allowing meshes to be refined once inside the shader units instead of downsampling very complex ones from memory. Some algorithms can upsample any arbitrary mesh, while others allow for "hinting" in meshes to dictate the most characteristic vertices and edges. ==== Primitive and Mesh shaders ==== Circa 2017, the [[AMD Vega]] [[microarchitecture]] added support for a new shader stage—primitive shaders—somewhat akin to compute shaders with access to the data necessary to process geometry.<ref>{{cite web|url=http://www.trustedreviews.com/news/amd-vega-specs-performance-release-date-technology-explained|title=Radeon RX Vega Revealed: AMD promises 4K gaming performance for $499 - Trusted Reviews|date=July 31, 2017}}</ref><ref>{{Cite web|url=https://techreport.com/review/31224/the-curtain-comes-up-on-amds-vega-architecture/|title=The curtain comes up on AMD's Vega architecture|date=January 5, 2017}}</ref> Nvidia introduced mesh and task shaders with its [[Turing (microarchitecture)|Turing microarchitecture]] in 2018 which are also modelled after compute shaders.<ref>{{cite web|url=https://devblogs.nvidia.com/nvidia-turing-architecture-in-depth/|title=NVIDIA Turing Architecture In-Depth|date=September 14, 2018}}</ref><ref>{{cite web|url=https://devblogs.nvidia.com/introduction-turing-mesh-shaders/|title=Introduction to Turing Mesh Shaders|date=September 17, 2018}}</ref> Nvidia Turing is the world's first GPU microarchitecture that supports mesh shading through DirectX 12 Ultimate API, several months before Ampere RTX 30 series was released.<ref>{{cite web | url=https://www.nvidia.com/en-us/geforce/news/directx-12-ultimate-game-ready-driver/ | title=DirectX 12 Ultimate Game Ready Driver Released; Also Includes Support for 9 New G-SYNC Compatible Gaming Monitors }}</ref> In 2020, AMD and Nvidia released [[RDNA 2]] and [[Ampere (microarchitecture)|Ampere]] microarchitectures which both support mesh shading through [[DirectX#DirectX 12 Ultimate|DirectX 12 Ultimate]].<ref>{{Cite web|date=2020-03-19|title=Announcing DirectX 12 Ultimate|url=https://devblogs.microsoft.com/directx/announcing-directx-12-ultimate/|access-date=2021-05-25|website=DirectX Developer Blog|language=en-US}}</ref> These mesh shaders allow the GPU to handle more complex algorithms, offloading more work from the CPU to the GPU, and in algorithm intense rendering, increasing the frame rate of or number of triangles in a scene by an order of magnitude.<ref>{{Cite web|date=2021-05-21|title=Realistic Lighting in Justice with Mesh Shading|url=https://developer.nvidia.com/blog/realistic-lighting-in-justice-with-mesh-shading/|access-date=2021-05-25|website=NVIDIA Developer Blog|language=en-US}}</ref> Intel announced that Intel Arc Alchemist GPUs shipping in Q1 2022 will support mesh shaders.<ref>{{Cite web|url=https://www.anandtech.com/show/16895/a-sneak-peek-at-intels-xe-hpg-gpu-architecture|title=Intel Architecture Day 2021: A Sneak Peek At The Xe-HPG GPU Architecture|first=Ryan|last=Smith|website=www.anandtech.com}}</ref> === Unified shaders === [[Unified shader]] is the combination of 2D shader and 3D shader. [[NVIDIA]] called "unified shaders" as "CUDA cores"; [[AMD]] called this as "shader cores"; while [[Intel Corp.|Intel]] called this as "ALU cores".<ref>{{Cite web | url=https://www.techpowerup.com/gpu-specs/docs/amd-gcn1-architecture.pdf | title=AMD graphics cores next (GCN) architecture | website=www.techpowerup.com}}</ref> === Compute shaders === [[Compute shader]]s are not limited to graphics applications, but use the same execution resources for [[GPGPU]]. They may be used in graphics pipelines e.g. for additional stages in animation or lighting algorithms (e.g. [[tiled forward rendering]]). Some rendering APIs allow compute shaders to easily share data resources with the graphics pipeline. === Ray tracing shaders === [[Ray tracing (graphics)|Ray tracing]] shaders are supported by [[Microsoft]] via [[DirectX Raytracing]], by [[Khronos Group]] via [[Vulkan (API)|Vulkan]], [[GLSL]], and [[SPIR-V]],<ref>{{cite web |url=https://www.khronos.org/blog/vulkan-ray-tracing-final-specification-release |title=Vulkan Ray Tracing Final Specification Release |date=2020-11-23 |df=mdy |department=Blog |website=[[Khronos Group]] |access-date=2021-02-22}}</ref> by [[Apple Inc.|Apple]] via [[Metal (API)|Metal]]. [[NVIDIA]] and [[AMD]] called "ray tracing shaders" as "ray tracing cores". Unlike unified shader, one ray tracing shader can contains multiple ALUs.<ref>{{Cite web| title=RTSL: a Ray Tracing Shading Language | url=https://graphics.stanford.edu/~boulos/papers/rtsl.pdf | archive-url=https://web.archive.org/web/20111012221101/http://graphics.stanford.edu/~boulos/papers/rtsl.pdf | archive-date=2011-10-12}}</ref> === Tensor shaders === Tensor shaders may be integrated in [[AI accelerator|NPU]]s or [[GPU]]s. Tensor shaders are supported by [[Microsoft]] via [[DirectML]], by [[Khronos Group]] via [[OpenVX]], by [[Apple, Inc.|Apple]] via [[Core ML]], by [[Google, Inc.|Google]] via [[TensorFlow]], by [[Linux Foundation]] via [[ONNX]].<ref> {{Cite web |title=NNAPI Migration Guide {{!}} Android NDK |url=https://developer.android.com/ndk/guides/neuralnetworks/migration-guide |access-date=2024-08-01 |website=Android Developers |language=en}}</ref> [[NVIDIA]] and [[AMD]] called "tensor shaders" as "tensor cores". Unlike unified shader, one tensor shader can contains multiple ALUs.<ref>{{Cite web| title=Review on GPU Architecture | url=https://www.irjet.net/archives/V11/i7/IRJET-V11I7124.pdf | archive-url=https://web.archive.org/web/20240906010254/https://www.irjet.net/archives/V11/i7/IRJET-V11I7124.pdf | archive-date=2024-09-06}}</ref>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)