[1908591] | 1 | #version 450
|
---|
| 2 | #extension GL_ARB_separate_shader_objects : enable
|
---|
| 3 |
|
---|
| 4 | layout (binding = 0) uniform UniformBufferObject {
|
---|
| 5 | mat4 model;
|
---|
| 6 | mat4 view;
|
---|
| 7 | mat4 proj;
|
---|
| 8 | } ubo;
|
---|
| 9 |
|
---|
| 10 | layout(location = 0) in vec3 vertex_position;
|
---|
| 11 | layout(location = 1) in vec3 vertex_color;
|
---|
[e1308e8] | 12 | layout(location = 2) in vec3 vertex_normal;
|
---|
[8e02b6b] | 13 | //layout(location = 3) in uint ubo_index;
|
---|
[1908591] | 14 |
|
---|
| 15 | layout(location = 0) out vec3 position_eye;
|
---|
| 16 | layout(location = 1) out vec3 color;
|
---|
[e1308e8] | 17 | layout(location = 2) out vec3 normal_eye;
|
---|
| 18 | layout(location = 3) out vec3 light_position_eye;
|
---|
[1908591] | 19 |
|
---|
| 20 | // fixed point light position
|
---|
[e1308e8] | 21 | //vec3 light_position_world = vec3(0.0, 0.0, 2.0);
|
---|
| 22 | vec3 light_position_world = vec3(0.4, 1.5, 0.8);
|
---|
| 23 | //vec3 light_position_world = vec3(0.0, 1.0, -1.0);
|
---|
[1908591] | 24 |
|
---|
[e1308e8] | 25 | // TODO: This does not account for scaling in the model matrix
|
---|
| 26 | // Check Anton's book to see how to fix this
|
---|
[1908591] | 27 | void main() {
|
---|
[8e02b6b] | 28 | position_eye = vec3(ubo.view * ubo.model * vec4(vertex_position, 1.0));
|
---|
[e1308e8] | 29 | //position_eye = vec3(view * model_mats[ubo_index] * vec4(vertex_position, 1.0));
|
---|
| 30 |
|
---|
| 31 | // Using 0.0 instead of 1.0 means translations won't effect the normal
|
---|
| 32 | normal_eye = normalize(vec3(ubo.view * ubo.model * vec4(vertex_normal, 0.0)));
|
---|
[8e02b6b] | 33 | //normal_eye = normalize(vec3(view * model_mats[ubo_index] * vec4(vertex_normal, 0.0)));
|
---|
| 34 | color = vertex_color;
|
---|
[aa00bf2] | 35 | light_position_eye = vec3(ubo.view * vec4(light_position_world, 1.0));
|
---|
[1908591] | 36 |
|
---|
[8e02b6b] | 37 | gl_Position = ubo.proj * vec4(position_eye, 1.0);
|
---|
[1908591] | 38 | }
|
---|