[GLSL] The same named uniform in vertex and fragment shaders
In OGL-GLSL, the program object is combined of vertex and fragment programs. And we pass uniforms to the program, not to shaders. So, is it possible to have two different uniforms (one in vertex, and one i fragment shader) with the same name and to access these two different uniforms via application?
But what if I want them to be two different uniforms? Let's say I have a uniform "my_color" in vs and fs, and I want it to be (1,1,1,1) in vs, and (0,0,0,0) in fs. How to achieve that?
You can't, you need to have a different Uniform name. The memory space for shaders is organise per-program, not per-shader. So your Vertex/Fragment shader pair all share the same Memory Space.
This means that my_color in Vertex Shader is the exact same Variable as my_color in Fragment Shader. Think of it as two different functions accessing a global variable in C/C++.
Simply have the Uniform named something different in the fragment shader.
This means that my_color in Vertex Shader is the exact same Variable as my_color in Fragment Shader. Think of it as two different functions accessing a global variable in C/C++.
Simply have the Uniform named something different in the fragment shader.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement