-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathshader.fs
70 lines (47 loc) · 1.01 KB
/
shader.fs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#version 330 core
out vec4 FragColor;
uniform float intensity;
uniform vec4 grid_color;
uniform vec4 dipole_color;
uniform bool grid;
uniform bool dipole;
uniform float max_inte;
void main()
{
if (grid == true )
{
FragColor = grid_color;
}
else if (grid == false )
{
float inc = 6.0 * max_inte;
float x = intensity * inc;
float r = 0.0f; float g = 0.0f; float b = 0.0f;
if ((0 <= x && x <= 1) || (5 <= x && x <= 6))
r = 1.0f;
else if (4 <= x && x <= 5)
r = x - 4.0f;
else if (1 <= x && x <= 2)
r = 1.0f - (x - 1.0f);
if (1 <= x && x <= 3)
g = 1.0f;
else if (0 <= x && x <= 1)
g = x - 0.0f;
else if (3 <= x && x <= 4)
g = 1.0f - (x - 3.0f);
if (3 <= x && x <= 5)
b = 1.0f;
else if (2 <= x && x <= 3)
b = x - 2.0f;
else if (5 <= x && x <= 6)
b = 1.0f - (x - 5.0f);
if (dipole == true )
{
FragColor = dipole_color;
}
else if (dipole == false )
{
FragColor = vec4(r, g, b, 1.0f);
}
}
}