the same uniform value is used within several shader programs
- Uniform Blocks
- from OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 4.3, Eighth Edition
- Publisher: Addison-Wesley Professional
- Released: March 2013
By "several shader programs", we do no mean different shader stages (vertex + fragment). Rather, we are talking about entirely different linked programs, each with their own set of stages: vertex, tess, geom, frag, comp, etc.
If two different stages of a shader program (say vert and frag) declare the same uniform variable, the scope of the variable is the whole program, and setting the variable with a glUniform<x>(...) from the host application will make it available to all stages that declare the uniform.
Note: scope of global variables is per shader stage, except uniforms it seems
Share this highlighthttp://www.safaribooksonline.com/a/opengl-programming-guide/5251/