I am improving my Lightning system and make it more structured.
In my fragment shader I’ve got the following structure:
const int MAX_NUM_LIGHTS = 20;
layout(std140)struct Light { // Simple point lights for testing
vec3 color;
float intensity;
vec3 position;
};
layout(std140)uniform Lights {
Light lights[MAX_NUM_LIGHTS];
};
When I fill my UBO with the following floats: (index: value)
0: 1.0 //Light 1 color.r
1: 1.0 //Light 1 color.g
2: 1.0 //Light 1 color.b
3: 100.0 //Light 1 intensity
4: 64.0 //Light 1 position.x
5: 10.0 //Light 1 position.y
6: 64.0 //Light 1 position.z
7: 0.0 //Light 2 color.r
8: 0.0 //Light 2 color.g
9: 0.0 //Light 2 color.b
10: 100.0 //Light 2 intensity
11: 32.0 //Light 2 position.x
12: 10.0 //Light 2 position.y
13: 32.0 //Light 2 position.z
14: 0.0
....
Everything works fine for the first light, but the second light has a blue color, while it should have a black color.
Am I missing something important when I fill my UBO?