Uniforms

Uniforms are available to both the vertex shader and the fragment shader. While attributes differ every time the vertex shader is invoked, uniforms are constant throughout a rendering cycle  that is, during the drawArrays or drawElements WebGL call.

Parallel Processing

We process vertices in parallel; therefore, each copy/thread of the vertex shader processes a different vertex.

We can use uniforms to pass along information about lights (such as diffuse color and direction), and materials (diffuse color):

uniform vec3 uLightDirection;  // incoming light source direction
uniform vec4 uLightDiffuse; // light diffuse component
uniform vec4 uMaterialDiffuse; // material diffuse color

Again, the uniform keyword tells us that these variables are uniforms, and the vec3 and vec4 ESSL types tell us that these variables have three or four components. For the colors, these components are the red, blue, green, and alpha channels (RGBA), and for the light direction, these components are the x, y, and z coordinates that define the vector in which the light source is directed in the scene.