voxelVis.frag 561 Bytes
Newer Older
Bastian Krayer's avatar
Bastian Krayer committed
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
#version 430 core

in VertexData {
    vec3 pos;
    vec3 normal;
    vec4 col;
}
fs_in;

out vec4 fragmentColor;

void main() {
    vec3 light = vec3(-10, 10, 10);
    vec3 lvec = normalize(light - fs_in.pos);

    float cos_phi = max(dot(fs_in.normal, lvec), 0.0f);

    vec3 eye = normalize(-fs_in.pos);
    vec3 reflection = normalize(reflect(-lvec, fs_in.normal));
    float cos_psi = pow(max(dot(reflection, eye), 0.0f), 15);

    fragmentColor =
        0.3 * fs_in.col + 0.7 * cos_phi * fs_in.col + 0.3 * cos_psi * vec4(1);
    fragmentColor.a = 0.85;
}