I have managed to greatly minimize draw calls on my recent project, but as I'm adding more shaders, I see that I have to switch more times and that is causing a lot of draw calls. What is the best practice for managing multiple (dozens) of shaders in a scene with many materials?
I read that it's best to combine them together and you have a shader variable "mode" that you switch upon inside the shader, to end up with the specific branch of code in the shader that is to handle the fragment.
Since shaders do have alot of parameters populated from the model material/mesh and sent down to the fragment shader, I fear that unifying the shaders and passing too many parameters in the VBO each frame/vertex/fragment, would be really bad for performance. I target mobile/tablet devices with my product so this is important, I understand that this is less of a concern with desktop GPUs. I see modern engines like unity and unreal allowing full flexibility on adding shaders & materials at-will and their scenes render perfectly - how do they do that without increasing their shader switching and draw calls?
So how many parameters are too much? And what is the best recomendation to manage multiple shaders in a drawing a scene. I understand and have allready applied grouping and rendering each material at once to minimize shader switching, but that has its limitations if there are dozens of shaders.
Is there a technique or capability I'm missing?