GLSL has many global variables that are predefined such as gl_LightSource. They are global because any shader can access them.
How do I define custom global variables in GLSL?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Global variables don’t exist in GLSL. The
gl_*variables are hardcoded variables (think of them as automatically added compile-time) to access non-programmable elements of the pipeline from a shader. In Core OpenGL 3.0 most of them were removed, includinggl_LightSource. The user is now expected to handle his own matrices and lights and send them to the shaders as uniforms. If you want to see a list of all the ones that remain, you should look at the GLSL Reference Pages.What you want are uniforms. If you want to synchronize uniforms between shaders, store the location of the uniform and iterate through all your programs to upload the uniform to each shader.