Help end child hunger

GLSL Tutorial – Communication Application => Shader

 
Prev: Subroutines Next: Attribute Variables
 

The shader pipepline receives vertices as inputs. These vertices have one or more attributes. Furthermore OpenGL allows the definition of variables that are not associated to the vertices but are required to compute the shader effect. An example for such a variable could be a light’s position.

From a GLSL point of view variables come in two flavours:

  • attributes
  • uniforms

A uniform variable is constant for all vertices in an OpenGL draw call. It may be viewed as a global variable whose values do not change for every vertex in an OpenGL draw call. Examples of these type of variables are transformation matrices, light’s attributes, fog settings, and variables such as gravity and speed, etc…

Uniform variables can also be grouped in blocks allowing a more effective data setup and transfer from the application to the shader.

An attribute is specific for a vertex, and typically varies from vertex to vertex. The most obvious is the vertex position. Texture coordinates and normals are also amongst common vertex attributes. These are written in buffers and bounded to a particular shader attribute.

 

Prev: Subroutines Next: Attribute Variables
 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: