Changeset adb104f in opengl-game for explosion.vert
- Timestamp:
- Jan 10, 2019, 4:38:01 AM (6 years ago)
- Branches:
- feature/imgui-sdl, master, points-test
- Children:
- 8fbd34f
- Parents:
- db06984
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
explosion.vert
rdb06984 radb104f 1 1 #version 410 core 2 2 3 uniform float elapsed_system_time; 3 // TODO: Pass the explosion center in as a uniform 4 5 uniform float explosion_start_time; 6 uniform float cur_time; 4 7 5 8 layout (location = 0) in vec3 v_i; // initial velocity … … 9 12 10 13 void main() { 11 float t = elapsed_system_time - start_time;12 t = mod(t, 3.0); // allow time to loop around so particle emitter keeps going14 float duration = 0.5; 15 float t = cur_time - explosion_start_time - start_time; 13 16 14 vec3 p = vec3(0.0, 0.0, 0.0); 15 vec3 a = vec3(0.0, -1.0, 0.0); // gravity 16 p += v_i * t + 0.5 * a * t * t; 17 if (t < 0.0) { 18 opacity = 0.0; 19 } else { 20 // Need to find out the last time this particle was at the origin 21 // If that is greater than the duration, hide the particle 22 float cur = floor(t / duration); 23 float end = floor((duration - start_time) / duration); 24 if (cur > end) { 25 opacity = 0.0; 26 } else { 27 opacity = 1.0 - (t / duration); 28 } 29 } 17 30 18 opacity = 1.0 - (t / 3.0); 31 vec3 p = vec3(0.0, 0.0, 0.0); // this is the center of the explosion 32 vec3 a = vec3(0.0, 0.1, 0.0); 33 p += normalize(v_i) * mod(t, duration) / duration * 0.3; // allow time to loop around so particle emitter keeps going 19 34 20 35 gl_Position = vec4(p, 1.0);
Note:
See TracChangeset
for help on using the changeset viewer.