Essentially I am trying to handle my shaders in the most dynamic way possible. I want to be able to associate certain objects with shaders, like a component-based system. So an object can have multiple shaders attached to it. The simplest way I can think of doing it is by having a map of shaders to objects.

I am targeting OpenGL 3.3 so that I can get decently modern code that works on the majority of systems owned by gamers.

My biggest issues revolve around two questions :

1) What is the best way to apply different shaders to different objects?

Thoughts : From what I have read, it seems like the best way is to designate what objects use what shaders, then begin using a shader, draw the corresponding objects, move to next shader.

2) What is the best way to apply multiple shaders to an object?
Thoughts : Should I just bind a shader program, draw what I need, get a texture back, then bind the next shader and pass it my texture? For example, if I had a shader that rendered one specific object in black and white, could I apply my normal shaders, then pass a resulting texture on to the new shaders to do the final processing? Is that too much overhead?

I apologize if my issues are hard to understand. Please ask any questions that can help make the issues more clear. Thanks in advance!
-Kreed

1) What is the best way to apply different shaders to different objects?

Switching shaders per object drawn could incur extra overhead. Say you have 4 objects, 2 shaders. Object 0 and Object 2 use shader 1, Object 1 and Object 3 use shader 2. If you draw object 0 - 4 in order, then you would have to bind a different shader every draw call which is enefficient (any kind of OpenGL state changes should be minimized). I would batch your object renderings so that you bind shader 0, then draw all objects that use shader 0, bind shader 1, draw all objects that use shader 1.

This can be accomplished in multiple ways. Probably the simplest (assuming you are in C++) is to use std::map with a key of shader, and value of std::vector of your objects. Then iterate over the map, and for each shader 1) bind shader, 2) loop through vector value and draw objects.