Should I ever use a `vec3` inside of a uniform buffer or shader storage buffer object?
Clash Royale CLAN TAG #URR8PPP Should I ever use a `vec3` inside of a uniform buffer or shader storage buffer object? The vec3 type is a very nice type. It only takes up 3 floats, and I have data that only needs 3 floats. And I want to use one in a structure in a UBO and/or SSBO: vec3 layout(std140) uniform UBO { vec4 data1; vec3 data2; float data3; }; layout(std430) buffer SSBO { vec4 data1; vec3 data2; float data3; }; Then, in my C or C++ code, I can do this to create matching data structures: struct UBO { vector4 data1; vector3 data2; float data3; }; struct SSBO { vector4 data1; vector3 data2; float data3; }; Is this a good idea? 1 Answer 1 NO! Never do this! When declaring UBOs/SSBOs, pretend that all 3-element vector and matrix types don't exist . Pretend that the only types are scalars, 2, and 4 element vectors (and matrices). You will save yourself a very great d...