I´m trying to implement a Uniform Block.
This is how the block looks like in my fragment shader:
struct Light {
uint LightType;
vec3 Direction;
float SpotBlur;
vec3 AmbientColor;
float LinearAttenuation;
vec3 DiffuseColor;
float QuadraticAttenuation;
vec3 SpecularColor;
float CubicAttenuation;
vec3 Position;
float SpotCutoff;
};
layout(std140) uniform LightBlock
{
Light values;
} lights[32];
As you can see, I defined an array of the Light struct with a fixed size of 32. I can upload the data without any problems but now comes what I dont understand. If the "lights" array has a relatively small size (something around 6) all of my shader uniforms are found. but when increasing the "lights" size then it begins to kinda override my uniforms. For example it could not find my "modelViewProjection" matrix from the vertex shader anymore (returned -1 as the uniform location).
[32]
belong tovalues
instead oflights
? At the moment you define 32 blocks, not a block with 32 entries. – BDLvec3
in interface blocks. Your layout in particular is really bad, since after everyfloat
/int
, there is 12 bytes of padding (vec3
is aligned to 16 bytes). – Nicol Bolas