|
|
(2 intermediate revisions by 2 users not shown) |
Line 1: |
Line 1: |
| {{cleanup}}
| |
|
| |
|
| '''Shader Variables''' in [[GLSL]] [[Shader|shader programs]] are not just the usual local and global variables as found in most programming languages; there are additional special types of them that are used to pass information between shaders. Some such variables are [[GLSL Predefined Variables|predefined]] by the language, but the programmer can also define their own. These variables can be of the following types:
| |
|
| |
| * ''[[GLSL Uniform|Uniforms]]'' are set once by the client program before drawing a group of vertices with the shader. Their values are thus shared among all vertices in that group, which might comprise a single object, or a single part of an object with common material settings, or whatever. Uniforms can be read by all shaders, not just the vertex shader.
| |
| * ''[[GLSL Attribute|Attributes]]'' are defined on a per-vertex basis, and are passed by the client program in ''vertex arrays'' to the [[Vertex Shader|vertex shader]]. These may specify information such as the position of each vertex, the normal at the vertex, colour/lighting info, texture coordinates etc—their interpretation is entirely up to the shader program.
| |
| * ''[[GLSL Interpolator|Interpolators]]'' (commonly called ''varying'' variables in OpenGL terminology) are outputs from the vertex shader and inputs to the [[Fragment Shader|fragment shader]]. The vertex shader defines a single value at each vertex, which is automatically linearly interpolated across all fragments which are being rendered between that vertex and its neighbours before being fed to the fragment shader. In GLSL versions prior to 1.30 (pre-OpenGL-3.0), they were defined with the {{code|varying}} [[GLSL Type Qualifiers#Deprecated_qualifiers|type qualifier]] in both the vertex and fragment shaders; in later versions, they are simply declared with the {{code|out}} qualifier in the vertex shader, and the {{code|in}} qualifier in the fragment shader.
| |
|
| |
| [[Category:OpenGL Shading Language]]
| |