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
|
Rev | Line | |
---|
[db06984] | 1 | #version 410 core
|
---|
| 2 |
|
---|
[fe5e3ca] | 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 | */
|
---|
[c5fb958] | 12 | uniform mat4 model_mat;
|
---|
[adb104f] | 13 |
|
---|
| 14 | uniform float explosion_start_time;
|
---|
| 15 | uniform float cur_time;
|
---|
[db06984] | 16 |
|
---|
| 17 | layout (location = 0) in vec3 v_i; // initial velocity
|
---|
| 18 | layout (location = 1) in float start_time;
|
---|
[fe5e3ca] | 19 | //layout(location = 2) in uint ubo_index;
|
---|
[db06984] | 20 |
|
---|
| 21 | out float opacity;
|
---|
| 22 |
|
---|
| 23 | void main() {
|
---|
[adb104f] | 24 | float duration = 0.5;
|
---|
| 25 | float t = cur_time - explosion_start_time - start_time;
|
---|
[db06984] | 26 |
|
---|
[adb104f] | 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 | }
|
---|
[db06984] | 40 |
|
---|
[adb104f] | 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
|
---|
[db06984] | 44 |
|
---|
[c5fb958] | 45 | //gl_Position = proj * view * model_mats[ubo_index] * vec4(p, 1.0);
|
---|
[fe5e3ca] | 46 | gl_Position = proj * view * model_mat * vec4(p, 1.0);
|
---|
[db06984] | 47 | gl_PointSize = 15.0; // size in pixels
|
---|
| 48 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.