1
\$\begingroup\$

I'm using 3 'types' of UBOs in my application: per-scene camera parameters, per-material parameters and per-object transform parameters.

I've used glUniformBlockBinding to assign the camera parameters to binding point 1, and the per-object parameters to binding point 2 - these are shared 'global' UBOs.

Each material needs it's own UBO to store the material parameters. Should I be using successive binding points for each material UBO - 3, 4, 5 etc?

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

You should put all materials in the same binding point. You don't bind every material you could ever use at the same time; you bind them as you need them.

Just as you don't bind every texture you could ever possibly need all at once. When rendering model A, you bind the textures and UBOs that model A needs, then when rendering model B, you bind the ones that it needs.

\$\endgroup\$
2
  • \$\begingroup\$ Aha! Thanks - I thought assigning bindings was an initialisation thing. \$\endgroup\$
    – James
    Commented Aug 8, 2012 at 22:55
  • \$\begingroup\$ @James: Assigning the bindings to a program is initialization (though you could do it later). Actually doing the bindings is runtime. You don't need a separate binding for each material you have. You just need a specific binding point for each type of thing you're using. \$\endgroup\$ Commented Aug 8, 2012 at 22:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .