-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel.fs
65 lines (58 loc) · 921 Bytes
/
model.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
62
63
64
65
#version 330 core
uniform float time;
uniform vec3 lightDir;
in vec3 vertexNormal;
out vec3 color;
void main() {
float h = mod(time, 360);
float s = 0.8;
float v = 0.8;
float hh = h / 60;
int i = int(hh);
float c = v * s;
float x = c * (1 - abs( mod( hh, 2 ) - 1 ) );
float m = v - c;
float r = 0.0;
float g = 0.0;
float b = 0.0;
switch(i) {
case 0:
r = c;
g = x;
b = 0;
break;
case 1:
r = x;
g = c;
b = 0;
break;
case 2:
r = 0;
g = c;
b = x;
break;
case 3:
r = 0;
g = x;
b = c;
break;
case 4:
r = x;
g = 0;
b = c;
break;
case 5:
r = c;
g = 0;
b = x;
break;
default:
break;
}
vec3 diffuseColor = vec3(r, g, b);
// Diffuse lighting
float intensity = clamp(dot(normalize(vertexNormal), -lightDir), 0.0f, 1.0f);
color = clamp((diffuseColor * intensity), 0.0f, 1.0f);
//color = clamp(vertexNormal, 0.0f, 1.0f);
//color = diffuseColor;
}