source: opengl-game/gl-shaders/explosion.vert@ 845a2cb

points-test
Last change on this file since 845a2cb was 845a2cb, checked in by Dmitry Portnoy <dmitry.portnoy@…>, 4 years ago

test point size

  • 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() {
[845a2cb]21 /*
[adb104f]22 float duration = 0.5;
[7e10667]23 float t = cur_time - explosion_start_time[ubo_index] - start_time;
[db06984]24
[adb104f]25 if (t < 0.0) {
26 opacity = 0.0;
27 } else {
28 // Need to find out the last time this particle was at the origin
29 // If that is greater than the duration, hide the particle
30 float cur = floor(t / duration);
31 float end = floor((duration - start_time) / duration);
32 if (cur > end) {
33 opacity = 0.0;
34 } else {
35 opacity = 1.0 - (t / duration);
36 }
37 }
[db06984]38
[845a2cb]39 // this is the center of the explosion
40 // allow time to loop around so particle emitter keeps going
41 vec3 p = normalize(v_i) * mod(t, duration) / duration * 0.3;
[db06984]42
[dc19a39]43 gl_Position = proj * view * model_mats[ubo_index] * vec4(p, 1.0);
[845a2cb]44 */
45 opacity = 1.0;
46 gl_Position = vec4(0.0, 0.0, 0.0, 1.0);
47 gl_PointSize = 100.0; // size in pixels
[db06984]48}
Note: See TracBrowser for help on using the repository browser.