Best practice for managing many shaders and merging multiple shaders into one? 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 &amp; 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?
I target mobile/tablet devices with my product
  this is less of a concern with desktop GPUs. 
  unity and unreal allowing full flexibility on adding shaders &amp; materials at-will


Well, Unity and Unreal can also be used to make games targetting mobile/tablet devices, right?
Do you think you can throw at them all the shaders &amp; materials you want, and expect them to magically output a performant application every time?
Try to do it and you will find that they also struggle at some point.  

This can also happen on desktop ; the newest smartphones are totally faster than my oldest laptop.   


  What is the best practice for managing multiple (dozens) of shaders in a scene with many materials?
  how many parameters are too much?


The best practice is to test on the real hardware that you are targetting. If you target a wide range of mobile devices, then you have to decide the lowest spec that your product will officially support.
Then, it is a matter of finding a good balance between performance (few materials/shaders) and visual quality (more variety/complexity).
If you are comfortable with the process, you can prepare a number of performance profiles based on the type of device that will run your product (lower-end, higher-end?), with better quality for the higher end.  


  Since shaders do have a lot 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.


You meant Uniform Buffer Object, not Vertex Buffer Object, right?
I expect that the size of the uniform data that you pass to the GPU is not that big?
However if your shaders are complex, it could take time for the GPU to execute them. 

Here again it is a balance, between the amount of parameters that you pass, and the complexity of the shader, that you have to find.
You just can try different solutions on real hardware, note down the performance and aspect of each one, and somehow compare them ; to find the optimal solution for your product.