feature/imgui-sdl
points-test
Last change
on this file since 0e0f851 was 0e0f851, checked in by Dmitry Portnoy <dmp1488@…>, 7 years ago |
Add a dedicated shader for asteroids, add an OpenGL debug callback, and start implementing the ability for asteroids to change color as they take damage.
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Rev | Line | |
---|
[ec4456b] | 1 | #version 410
|
---|
| 2 |
|
---|
[14ff67c] | 3 | #define MAX_NUM_OBJECTS 1024
|
---|
[93baa0e] | 4 |
|
---|
[0e0f851] | 5 | uniform mat4 view, proj, hp;
|
---|
[14ff67c] | 6 |
|
---|
| 7 | layout (std140) uniform models {
|
---|
| 8 | mat4 model_mats[MAX_NUM_OBJECTS];
|
---|
[e165b85] | 9 | };
|
---|
| 10 |
|
---|
[0e0f851] | 11 | /*
|
---|
| 12 | layout (std140) uniform hp_uniform {
|
---|
| 13 | mat4 hp[MAX_NUM_OBJECTS];
|
---|
| 14 | };
|
---|
| 15 | */
|
---|
| 16 |
|
---|
[d0b9596] | 17 | layout(location = 0) in vec3 vertex_position;
|
---|
| 18 | layout(location = 1) in vec3 vertex_color;
|
---|
[9dd2eb7] | 19 | layout(location = 2) in vec3 vertex_normal;
|
---|
[14ff67c] | 20 | layout(location = 3) in uint ubo_index;
|
---|
[8b7cfcf] | 21 |
|
---|
[f7d35da] | 22 | out vec3 position_eye, normal_eye, color, light_position_eye, light2_position_eye;
|
---|
[9dd2eb7] | 23 |
|
---|
| 24 | // fixed point light position
|
---|
| 25 | vec3 light_position_world = vec3(0.0, 0.0, 2.0);
|
---|
[cf2d1e5] | 26 | vec3 light2_position_world = vec3(0.0, 1.5, -0.1);
|
---|
[ec4456b] | 27 |
|
---|
| 28 | void main() {
|
---|
[14ff67c] | 29 | position_eye = vec3(view * model_mats[ubo_index] * vec4(vertex_position, 1.0));
|
---|
[c8dc5c6] | 30 | normal_eye = normalize(vec3(view * model_mats[ubo_index] * vec4(vertex_normal, 0.0)));
|
---|
[0e0f851] | 31 | //color = vertex_color * (hp[ubo_index][0][0] * 10.0); //(hp[ubo_index*4] / 10.0);
|
---|
| 32 | color = vertex_color * (hp[0][0] * 2.0 / 10.0);
|
---|
[9dd2eb7] | 33 | light_position_eye = vec3(view * vec4(light_position_world, 1.0));
|
---|
[f7d35da] | 34 | light2_position_eye = vec3(view * vec4(light2_position_world, 1.0));
|
---|
[9dd2eb7] | 35 |
|
---|
| 36 | gl_Position = proj * vec4(position_eye, 1.0);
|
---|
[ec4456b] | 37 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.