Shaders/Materials

I imagine the number of shaders we can compile is a finite resource. I couldn’t find a GetInteger for it.
However I can think of situations where the shader is the same, but only some uniforms or textures change.
For instance, we can have a bumpmap shader for all walls and floors in a FPS, but of course they use different textures or different bump factors (a uniform).
What would be the best approach?
To compile different shaders for each case, or to have a common shader and a sort of “material” entity, that refers to a particular shaders and contains a set of uniforms/textures to use?
Isn’t settings uniforms painly slow?

I couldn’t find a GetInteger for it.

Nor will you find a GetInteger for the number of buffer objects, textures, or any other object that you can create.

Isn’t settings uniforms painly slow?

No more than any other state change would be.

You should not create a program for every instance of an object. You will simply have to set the uniforms and textures for each instance as needed. Uniform Buffers make this a bit easier, allowing you to allocate per-instance storage for each use of that shader.

Remember: every OpenGL game that uses shaders has to do this. So it’s not the slowest thing in the world.

Thanks for your answer. At first I thought it would have required a big refactor, but now I’m just caching ShaderPrograms with vertexSourceFileName “+” fragmentSourceFileName as key when loading shaders.