source: opengl-game/explosion.vert@ 9cd92ae

feature/imgui-sdl points-test
Last change on this file since 9cd92ae 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
Line 
1#version 410 core
2
3#define MAX_NUM_OBJECTS 1024
4
5uniform mat4 view, proj;
6uniform float cur_time;
7
8uniform float explosion_start_time[1012];
9
10layout (std140) uniform models {
11 mat4 model_mats[MAX_NUM_OBJECTS];
12};
13
14layout (location = 0) in vec3 v_i; // initial velocity
15layout (location = 1) in float start_time;
16layout(location = 2) in uint ubo_index;
17
18out float opacity;
19
20void main() {
21 float duration = 0.5;
22 float t = cur_time - explosion_start_time[ubo_index] - start_time;
23
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 }
37
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
41
42 gl_Position = proj * view * model_mats[ubo_index] * vec4(p, 1.0);
43 gl_PointSize = 15.0; // size in pixels
44}
Note: See TracBrowser for help on using the repository browser.