Shader input and output variables
Until now, we've been speaking about the language itself; how it's similar to the C programming language, but focusing specially on the differences. That was only the language part. Now it's time to see some of the functional parts of GLSL and cover an important topic: the inputs and outputs of the shaders.
Uniform variables
Suppose, you want to create a shader that makes use of a simple light. Well, shaders don't know about lights or any other high-level concept. Shaders only know about math and programming. So, if the language doesn't have support for lights, how would I use the light's position or color in a shader?
You need to pass those variables from your application to your shader and perform the lighting calculations inside the shader.
A parameter that is passed from the application to the shaders is called a uniform variable. Those variables are always read-only (constant), global to the shaders that form the current executable program.
The procedure...