Talk:Uniform Buffer Object

From OpenGL Wiki
Revision as of 00:17, 8 December 2011 by Amoffat (talk | contribs) (Gotcha?)
Jump to: navigation, search


I removed this:

When uploading matrices into your UBO, if your layout is std140, your matrix rows might need to be padded to a specific size, just like how vec3s might need to be be padded to vec4s. For example, when uploading a mat3, send a mat4 and let your shader cast it back to a mat3 in the uniform block declaration.

This is not true. This may be in reference to some driver bug that someone encountered. If so, then it should be explicitly marked as such, with a driver version and the hardware it affects (NVIDIA/ATI/etc).

OpenGL is very clear on how std140 works. There is no ambiguity on the matter; there is no "might" anything. That's the whole point: to know up-front how big stuff is. This page is for describing how OpenGL works. Alfonse 11:24, 7 December 2011 (PST)

Hi Alfonse, thanks for your response. I used "might" in the context of "this might be your problem." I agree it was a poor choice of words. Maybe you can help me clarify what the Red Book says about matrices in std140?:

Stored as an array of C vectors each with R components, and potentially padded like other arrays. If the variable is an array of M column-major matrices, it is stored as an array of M C vectors each with R components (and potentially padded).

Does this mean that a mat3 is treated as an array of vec3s, and is therefore padded like vec3s are padded to vec4s? Thanks in advance for clearing this up. Amoffat 16:17, 7 December 2011 (PST)