summary refs log tree commit diff
path: root/assets/shaders/fragment.glsl
blob: 71435ef228ca2b2587c4774bc993bdffb4590873 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#version 330 core

uniform sampler2D tex;
uniform vec3 sun_direction;
uniform vec3 sky_color;

in vec3 surface_normal;
in vec2 frag_tex_coord;
in float depth;

out vec4 color;

void main() {
    float brightness = dot(normalize(surface_normal), normalize(-sun_direction));
    vec3 diffuse = vec3(max(brightness, 0.3));

    color = vec4(diffuse, 1.0) * texture(tex, frag_tex_coord);
    color = mix(vec4(sky_color, 1.0), color, 1 - depth);
}