GLSL: Difference between revisions
Created page with "OpenGL Shading Language (GLSL) is the shader language used in OpenGL and WebGL. ==Usage== ==Pipeline== ===Vertex Shader=== ===Geometry Shader=== ===Tesselation Shader=== ===..." |
|||
Line 5: | Line 5: | ||
==Pipeline== | ==Pipeline== | ||
===Vertex Shader=== | ===Vertex Shader=== | ||
In the vertex shader, your inputs are a model matrix, view matrix, and projection matrix uniforms as well as one vertex position in local coordinates. | |||
There may also be <code>attributes</code> which are per-vertex values such as UVs. | |||
Your vertex shader program is run once per each vertex of a mesh. | |||
The goal of the vertex shader is to output a position in screen coordinates. | |||
Typically this is done by multiplying with the model matrix to get world coordinates, then the view matrix to get camera coordinates, and finally the projection matrix to get screen coordinates. | |||
You can also do any other per-vertex calculations in this stages. | |||
These values can be passed to the following stages as <code>varying</code>'s. | |||
<code>varying</code>'s are linearly interpolated using barycentric coordinates. | |||
===Geometry Shader=== | ===Geometry Shader=== | ||
===Tesselation Shader=== | ===Tesselation Shader=== | ||
===Fragment Shader=== | ===Fragment Shader=== |
Revision as of 19:21, 14 September 2020
OpenGL Shading Language (GLSL) is the shader language used in OpenGL and WebGL.
Usage
Pipeline
Vertex Shader
In the vertex shader, your inputs are a model matrix, view matrix, and projection matrix uniforms as well as one vertex position in local coordinates.
There may also be attributes
which are per-vertex values such as UVs.
Your vertex shader program is run once per each vertex of a mesh.
The goal of the vertex shader is to output a position in screen coordinates.
Typically this is done by multiplying with the model matrix to get world coordinates, then the view matrix to get camera coordinates, and finally the projection matrix to get screen coordinates.
You can also do any other per-vertex calculations in this stages.
These values can be passed to the following stages as varying
's.
varying
's are linearly interpolated using barycentric coordinates.