Lets consider such situation.
The scene contains given objects: ABCDE.
Where order from camera (from nearest to farthest): AEBDC.
And objects AC use shader1, ED - shader2, B - shader3.
Objects AC use same shader, but different texture.
Now what to deal with such situation?
Do instructions like glUniform
, glBindTexture
etc. to change value in a program that is already in use cause overhead?
There is no one answer to this question. Does changing OpenGL state "cause overhead"? Of course they do; nothing is free. The question is whether the overhead caused by state change will be worse than the less effective depth test support.
That cannot be answered, because the answer depends on how much overdraw there is, how costly your fragment shaders are, how many state changes a particular sequence of draw calls will require, and numerous other intangibles that cannot be known beforehand.
That's why profiling before optimization is important.