PDA

View Full Version : Uniform location across different GLSL program object



km,
12-11-2006, 02:24 PM
Hi,

I have a query regarding a uniform variables used in a shader which is bound to multiple program objects.

If I have a shaders named as: sh1.vert, sh1.frag and sh2.frag and they are combined to create a program object as:
prog1(sh1.vert, sh1.frag)
and prog2(sh1.vert, sh2.frag).

Now in normal rendering is something like this.

prog1->enable();
render();
.. something else

prog2->enable();
render();
... repeat.

In above scenario if I have declared a uniform in sh1.vert as " uniform vec4 pos; ".

Then do I need to reset the uniform again if I switch the program objects?

In gDebugger it shows that second program object has values initialized to zero rather than having same values as set previously. Memory location is still the same when queried for active uniforms in both cases.

Any suggestions?

zeoverlord
12-11-2006, 03:43 PM
Originally posted by km,:
Then do I need to reset the uniform again if I switch the program objects?I am not sure, but it's not that much of an time sink and uniforms do change often each time a new shader is loaded, so i made my shader/texture engine feed new uniforms every time a new shader is loaded just to keep them up to date.

Komat
12-11-2006, 11:56 PM
The values of uniforms are associated with program object. Each program object has its own copy which will be used when that program object is active even if it uses shared shader object.

km,
12-12-2006, 07:55 AM
I think I mis-read it somehow, thank for informing Komat. Will check on it.