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