Shader Variable: Difference between revisions

From OpenGL Wiki
Jump to navigation Jump to search
Ldo (talk | contribs)
mNo edit summary
The page has not been cleaned up, and is otherwise not good. And there are no links to it. It doesn't need to exist, but I'm not using admin powers to delete it.
 
(7 intermediate revisions by 2 users not shown)
Line 1: Line 1:
'''Shader Variables''' are used to pass information between [[shader]]s in [[GLSL]]. Some 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]]

Latest revision as of 21:46, 26 September 2012