blob: 9becd4cec7b1d1a69dd11debd0415c89511621e2 (
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
#version 330 core
#preinclude "light.glsl"
out vec4 FragColor;
in vec2 in_texture_coords;
in vec3 in_frag_pos;
in vec3 in_normal;
uniform vec3 view_pos;
uniform sampler2D input_texture;
uniform Material material;
uniform PointLight light;
void main()
{
vec3 ambient_light = calc_ambient_light(material, in_texture_coords);
vec3 light_direction = normalize(light.position - in_frag_pos);
vec3 norm = normalize(in_normal);
vec3 diffuse_light = calc_diffuse_light(
material,
light,
light_direction,
norm,
in_texture_coords
);
vec3 specular_light = calc_specular_light(
material,
light,
light_direction,
norm,
view_pos,
in_frag_pos,
in_texture_coords
);
float attenuation = calc_attenuation(light, in_frag_pos);
diffuse_light *= attenuation;
specular_light *= attenuation;
FragColor = vec4((ambient_light + diffuse_light + specular_light), 1.0);
}
|