O'Reilly logo
  • Musharraf Azeem thinks this is interesting:

the same uniform value is used within several shader programs


Cover of OpenGL Programming Guide: The Official Guide to Learning OpenGL, Version 4.3, Eighth Edition


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