1 | #version 150 |
---|
2 | |
---|
3 | // |
---|
4 | // Explanation of different particle types |
---|
5 | // |
---|
6 | #define PT_LAUNCHER 0 //Firework Launcher - launches a PT_SHELL every so many seconds |
---|
7 | #define PT_SHELL 1 //Unexploded shell - flies from the origin and explodes into many PT_EMBERXs |
---|
8 | #define PT_EMBER1 2 //basic particle - after it's emitted from the shell, it dies |
---|
9 | #define PT_EMBER2 3 //after it's emitted, it explodes again into many PT_EMBER1s |
---|
10 | #define PT_EMBER3 4 //just a differently colored ember1 |
---|
11 | #define P_SHELLLIFE 3.0 |
---|
12 | #define P_EMBER1LIFE 2.5 |
---|
13 | #define P_EMBER2LIFE 1.5 |
---|
14 | #define P_EMBER3LIFE 2.0 |
---|
15 | |
---|
16 | in vec4 position; |
---|
17 | uniform float inTimer; |
---|
18 | uniform float inType; |
---|
19 | uniform vec3 inVelocity; |
---|
20 | |
---|
21 | out block { |
---|
22 | vec3 pos; |
---|
23 | vec4 color; |
---|
24 | float radius; |
---|
25 | } ColoredFirework; |
---|
26 | |
---|
27 | uniform mat4 worldViewProj; |
---|
28 | |
---|
29 | //The vertex shader that prepares the fireworks for display |
---|
30 | void main() |
---|
31 | { |
---|
32 | // |
---|
33 | // Pass the point through |
---|
34 | // |
---|
35 | ColoredFirework.pos = position.xyz; //Multiply by world matrix? |
---|
36 | ColoredFirework.radius = 1.5; |
---|
37 | |
---|
38 | // |
---|
39 | // calculate the color |
---|
40 | // |
---|
41 | if( inType == PT_LAUNCHER ) |
---|
42 | { |
---|
43 | ColoredFirework.color = vec4(1,0.1,0.1,1); |
---|
44 | ColoredFirework.radius = 1.0; |
---|
45 | } |
---|
46 | else if( inType == PT_SHELL ) |
---|
47 | { |
---|
48 | ColoredFirework.color = vec4(0.1,1,1,1); |
---|
49 | ColoredFirework.radius = 1.0; |
---|
50 | } |
---|
51 | else if( inType == PT_EMBER1 ) |
---|
52 | { |
---|
53 | ColoredFirework.color = vec4(1,1,0.1,1); |
---|
54 | ColoredFirework.color *= (inTimer / P_EMBER1LIFE ); |
---|
55 | } |
---|
56 | else if( inType == PT_EMBER2 ) |
---|
57 | { |
---|
58 | ColoredFirework.color = vec4(1,0.1,1,1); |
---|
59 | } |
---|
60 | else if( inType == PT_EMBER3 ) |
---|
61 | { |
---|
62 | ColoredFirework.color = vec4(1,0.1,0.1,1); |
---|
63 | ColoredFirework.color *= (inTimer / P_EMBER3LIFE ); |
---|
64 | } |
---|
65 | } |
---|