summaryrefslogtreecommitdiff
path: root/engine/fragment-color.glsl
blob: fcf8d282b6b1d6a78c79f89453dda21c9650db8d (plain)
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
#version 330 core

#preinclude "light.glsl"

out vec4 FragColor;

in vec3 in_frag_color;
in vec3 in_frag_pos;
in vec3 in_normal;

uniform vec3 view_pos;

void main()
{
	vec3 ambient_light = ambient_light_strength * light_color;

	vec3 light_direction = normalize(light_pos - in_frag_pos);
	vec3 norm = normalize(in_normal);

	vec3 diffuse_light = calc_diffuse_light(light_direction, norm);

	vec3 specular_light =
		calc_specular_light(light_direction, norm, view_pos, in_frag_pos);

	FragColor =
		vec4((ambient_light + diffuse_light + specular_light) * in_frag_color, 1.0);
}