source: opengl-game/explosion.vert@ 99d44b2

feature/imgui-sdl points-test
Last change on this file since 99d44b2 was 7e10667, checked in by Dmitry Portnoy <dmitry.portnoy@…>, 6 years ago

Finish switching to the new model group rendering algorithm for TYPE_EXPLOSION objects

  • Property mode set to 100644
File size: 1.2 KB
RevLine 
[db06984]1#version 410 core
2
[fe5e3ca]3#define MAX_NUM_OBJECTS 1024
4
5uniform mat4 view, proj;
[7e10667]6uniform float cur_time;
7
8uniform float explosion_start_time[1012];
9
[fe5e3ca]10layout (std140) uniform models {
11 mat4 model_mats[MAX_NUM_OBJECTS];
12};
[adb104f]13
[db06984]14layout (location = 0) in vec3 v_i; // initial velocity
15layout (location = 1) in float start_time;
[dc19a39]16layout(location = 2) in uint ubo_index;
[db06984]17
18out float opacity;
19
20void main() {
[adb104f]21 float duration = 0.5;
[7e10667]22 float t = cur_time - explosion_start_time[ubo_index] - start_time;
[db06984]23
[adb104f]24 if (t < 0.0) {
25 opacity = 0.0;
26 } else {
27 // Need to find out the last time this particle was at the origin
28 // If that is greater than the duration, hide the particle
29 float cur = floor(t / duration);
30 float end = floor((duration - start_time) / duration);
31 if (cur > end) {
32 opacity = 0.0;
33 } else {
34 opacity = 1.0 - (t / duration);
35 }
36 }
[db06984]37
[adb104f]38 vec3 p = vec3(0.0, 0.0, 0.0); // this is the center of the explosion
39 vec3 a = vec3(0.0, 0.1, 0.0);
40 p += normalize(v_i) * mod(t, duration) / duration * 0.3; // allow time to loop around so particle emitter keeps going
[db06984]41
[dc19a39]42 gl_Position = proj * view * model_mats[ubo_index] * vec4(p, 1.0);
[db06984]43 gl_PointSize = 15.0; // size in pixels
44}
Note: See TracBrowser for help on using the repository browser.