I built a 2D graphics engine and I created a batch system for it, so if I have 1000 sprites with the same texture, I can draw them with a single openGl call.
This is achieved by placing all vertices of all sprites with the same texture in the same vbo verbal array.
Instead of "printing these peaks, printing these peaks, printing these peaks," I "put all the peaks in what to print," just to be extremely clear. Easy enough, but now I'm trying to achieve the same thing in 3D, and I have a big problem.
The problem is that I use the Project View Model matrix to place and render my models, which is a common approach to rendering a model in 3D space.
For each model on the screen, I need to pass the MVP matrix to the shader so that I can use it to convert each vertex to the desired position.
If I made the conversion outside the shader, it would be executed by the processor, which I do not understand very well for obvious reasons.
But the problem is there. I need to pass the matrix to the shader, but the matrix is ββdifferent for each model.
Therefore, I can not do the same with 2d sprites, because changing the shader shape requires drawing every time.
I hope I understand, maybe you have a good idea that I didnβt have, or you already had the same problem. I know there is a solution somewhere, because in an engine like Unity, you can use the same shader for several models and get away with one draw call