Talk:Uniform (GLSL)

From OpenGL Wiki
Revision as of 08:51, 28 August 2012 by MarkTheFox (talk | contribs) (Created page with "Regarding the explanation of the layout on uniform variables created from a structure it seems there is a small mistake on the layout value for the second example, shouldn't i...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Regarding the explanation of the layout on uniform variables created from a structure it seems there is a small mistake on the layout value for the second example, shouldn't it be 7 instead of 2 for manyStructs[0].thirdField ? (0*3 [array] + 2 [struct offset] + 5 [base location]) Here is the corresponding part of the page :

struct MyStruct
{
  vec2 firstField;
  vec4 secondField;
  mat2 thirdField;
};

layout(location = 5) uniform MyStruct manyStructs[3];

"manyStructs[0].firstField" will have the location 5. "manyStructs[0].thirdField will have the location 2. "manyStructs[2].secondField" will have the location (2*3 [array] + 1 [struct offset] + 5 [base location]), or 12. And so forth.