Same shader on multiple objects w/ different uniforms

This is a simple question, is it possible to render multiple objects with the same shader BUT modify the value of a uniform between objects? For example:


shader(“simple”)->setUniform(“color”)= blue;
shader(“simple”)->setUniform(“color”)= red;
shader(“simple”)->setUniform(“color”)= green;


Obviously this isn’t exact code but hopefully it is clear enough to explain my question. I’m having problems implementing something I thought was easy but it’s not working so I want to eliminate the obvious before diving into full debug mode…

Yes you can.

Yes. Consider OpenGL like a state machine. You set a shader and all the remaining draw calls will use that shader. If you change the shader state at some point, all the remaining calls after that will use the new states. Hope you get the point.

thanks. that’s what I thought but I wanted to be sure. I think this has something to do w/ the scene graph API I’m using so I’ll post there. Thanks for the “re-assurance” :slight_smile:

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.