-
Notifications
You must be signed in to change notification settings - Fork 3
/
skybox.frag
47 lines (39 loc) · 940 Bytes
/
skybox.frag
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
#version 330 core
// Andy Thai
struct DirLight {
vec3 direction;
vec3 ambient;
vec3 diffuse;
vec3 specular;
};
// Inputs to the fragment shader are the outputs of the same name from the vertex shader.
// Note that you do not have access to the vertex shader's default output, gl_Position.
in vec3 TexCoords;
in vec3 Normal;
// You can output many things. The first vec4 type output determines the color of the fragment
out vec4 color;
// Uniform
uniform samplerCube skybox;
uniform DirLight dirLight;
void main()
{
vec3 norm = normalize(Normal);
vec3 l = normalize(dirLight.direction);
color = texture(skybox, TexCoords);
// Diffuse switch
/*
float diffuse = max(0.0f, dot(norm, l));
if (diffuse > 0.75f) {
// Do nothing
}
else if (diffuse > 0.5f) {
color = color * 0.6f;
}
else if (diffuse > 0.25f) {
color = color * 0.4f;
}
else {
color = color * 0.3f;
}
*/
}