Hi i am having an issue with uniform buffer object in opengl 330 core.
So I have a struct at my c++ code.
struct DirectionalLightUBO {
Mat4 shadowMatrix[4];
Vec3f direction;
float pad1;
Vec3f color;
float pad2;
float cascadeDepths[4];
};
struct LightDataUBO {
DirectionalLightUBO directionalLights[4];
int directionalLightCount;
} lightDataUBO;
And then I have a uniform buffer at my glsl
struct DirectionalLight {
mat4 shadowMatrix[4];
vec3 direction;
float pad1;
vec3 color;
float pad2;
float cascadeDepths[4];
};
layout (std140) uniform LightData {
DirectionalLight directionalLights[4];
int directionalLightCount;
};
I sucessfully transfer the value of my ubo up to pad2. But the value of cascadeDepths is not the same as what I set in my c++ code. The weird thing is if I change the cascadeDepths[4] to vec4 in the glsl then the data from my c++ code map nicely to glsl where cascadeDepths[0] -> vec4.x, cascadeDepths[1] -> vec4.y and so on. Is there something that i miss here?