I have a PointLight struct in C++
struct PointLight
{
glm::vec4 position; // 16 bytes
glm::vec4 color; // 16 bytes
float intensity; // 4 bytes rounded to 16 bytes?
float range; // 4 bytes rounded to 16 bytes?
};
usage in ssbo:
layout(std430, binding = 3) buffer lightSSBO
{
PointLight pointLight[];
};
Will the float elements be rounded up to 16 bytes due to the vec4s? Does std430 always round elements in an array to the size of the largest element?
Will I need to add padding to my struct to correctly access the variables?
struct PointLight
{
glm::vec4 position; // 16 bytes
glm::vec4 color; // 16 bytes
float intensity; // 4 bytes
float range; // 4 bytes
float padding[2]; // padding to make struct multiple of 16 bytes, because
// largest element vec4 is 16 bytes
// total 48 bytes
};