Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/Shader_HS18/programs/GLSL150/ParticleGS_DisplayVS.glsl @ 12189

Last change on this file since 12189 was 12115, checked in by wiesep, 6 years ago

Changed folder structure, deletet some unused files and cleaned up code

File size: 1.9 KB
Line 
1#version 150
2
3//
4// Explanation of different particle types
5//
6// Firework Launcher - launches a PT_SHELL every so many seconds.
7#define PT_LAUNCHER 0
8// Unexploded shell - flies from the origin and explodes into many PT_EMBERX's.
9#define PT_SHELL    1
10// Basic particle - after it's emitted from the shell, it dies.
11#define PT_EMBER1   2
12// After it's emitted, it explodes again into many PT_EMBER1's.
13#define PT_EMBER2   3
14// Just a differently colored ember1.
15#define PT_EMBER3   4
16#define P_SHELLLIFE 3.0
17#define P_EMBER1LIFE 2.5
18#define P_EMBER2LIFE 1.5
19#define P_EMBER3LIFE 2.0
20
21in vec3 position;
22// timer
23in float uv0;
24// type
25in float uv1;
26// velocity
27in vec3 uv2;
28
29out block {
30    vec3 pos;
31    vec4 colour;
32    float radius;
33} ColouredFirework;
34
35uniform mat4 worldViewProj;
36
37//The vertex shader that prepares the fireworks for display
38void main()
39{
40    float inTimer = uv0;
41    float inType = uv1;
42   
43    //
44    // Pass the point through
45    //
46    ColouredFirework.pos = position; // Multiply by world matrix?
47    ColouredFirework.radius = 1.5;
48   
49    // 
50    // calculate the colour
51    //
52    if (inType == PT_LAUNCHER)
53    {
54        // red
55        ColouredFirework.colour = vec4(1, 0.1, 0.1, 1);
56        ColouredFirework.radius = 1.0;
57    }
58    else if (inType == PT_SHELL)
59    {
60        // cyan
61        ColouredFirework.colour = vec4(0.1, 1, 1, 1);
62        ColouredFirework.radius = 1.0;
63    }
64    else if (inType == PT_EMBER1)
65    {
66        // yellow
67        ColouredFirework.colour = vec4(1, 1, 0.1, 1);
68        ColouredFirework.colour *= (inTimer / P_EMBER1LIFE);
69    }
70    else if (inType == PT_EMBER2)
71    {
72        // fuschia
73        ColouredFirework.colour = vec4(1, 0.1, 1, 1);
74    }
75    else if (inType == PT_EMBER3)
76    {
77        // red
78        ColouredFirework.colour = vec4(1, 0.1, 0.1, 1);
79        ColouredFirework.colour *= (inTimer / P_EMBER3LIFE);
80    }
81}
Note: See TracBrowser for help on using the repository browser.