I’m using three ‘types’ of UBOs in my application: per-frame camera parameters, per-material parameters and per-instance transform parameters. I believe this is the correct way of using UBOs.
I’ve used glUniformBlockBinding to assign binding point 1 to the shared camera parameters, and binding point 2 to the per-instance parameters as a matter of convention. I’m not so sure what to do with material parameters, since each material needs its own UBO (set once at load time). Should I use successive binding points for each material UBO - 3, 4, 5, etc?
Any advice is much appreciated.
I always thought the goal of UBOs was to share uniform resources across multiple shaders. If you are not accessing the UBO from more and one or two shaders, then you’re wasting your time codeing this way and performance will actually drop.
So, are your material UBOs being access by more than 1 or 2 shaders each? The same question with the per-instance UDBOs?
Camera UBOs are quite possibly one of the best case uses of UBO IMHO.
I think I’m justified in using UBOs for per-material data - if a material has 10 parameters then I can either call glUniform() for each parameters when I use that material, or I can upload the UBO data once on load and call glBindBufferRange(). That has to be faster, right?
As for per-instance data - is glUniform() really faster than glBufferSubData() for switching in instance parameters? If so, can anyone tell me why?