I am implementing a 3d renderer in OpenGL. Here is how you would render some 3d models:
Renderer3D.begin(camera);
Renderer3D.setShader(shader_1);
Renderer3D.render(model_1, transform_1);
Renderer3D.setShader(shader_2);
Renderer3D.render(model_2, transform_2);
...
Renderer3D.end();
Each .render() call will issue a GPU draw-call. (by calling .glDraw()) Here, I am using 2 shaders: shader_1, and shader_2.
However, both shaders have a uniform variable:
mat4 u_camera_projection;
Now, since u_camera_projection is a uniform variable, I will have to bind it whenever I switch shaders. What I would love to have - and I don't know if this feature exists in OpenGL - are "global", "bindless" variables. Variables that you can bind once, from the CPU side, and then they are accessible as read data from ANY shader.