| 1 |
#version 440 |
| 2 |
|
| 3 |
layout(location = 0) in vec4 position; |
| 4 |
|
| 5 |
// Instanced attributes to variate the translation and color of the cube |
| 6 |
layout(location = 1) in vec3 instTranslate; |
| 7 |
layout(location = 2) in vec3 instColor; |
| 8 |
|
| 9 |
layout(location = 0) out vec3 vColor; |
| 10 |
|
| 11 |
out gl_PerVertex { vec4 gl_Position; }; |
| 12 |
|
| 13 |
layout(std140, binding = 0) uniform buf { |
| 14 |
mat4 mvp; |
| 15 |
} ubuf; |
| 16 |
|
| 17 |
void main() |
| 18 |
{ |
| 19 |
vColor = instColor; |
| 20 |
mat4 t = mat4(1, 0, 0, 0, |
| 21 |
0, 1, 0, 0, |
| 22 |
0, 0, 1, 0, |
| 23 |
instTranslate.x, instTranslate.y, instTranslate.z, 1); |
| 24 |
gl_Position = ubuf.mvp * t * position; |
| 25 |
} |