blob: 467174cfe629b18eacdbd29631644a5702a85aaf (
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
|
#version 460 core
out vec4 FragColor;
in vec3 Normal;
in vec2 TexCoord;
in vec3 FragPos;
in mat3 TBN;
uniform float ambient_strength;
uniform sampler2D base_texture;
uniform sampler2D normal_texture;
uniform vec4 light_color;
uniform vec3 light_position;
void main() {
vec4 base_color = texture(base_texture, TexCoord);
vec3 normal = texture(normal_texture, TexCoord).rgb;
normal = normal * 2.0 - 1.0;
normal = normalize(TBN * normal);
vec3 light_direction = normalize(light_position - FragPos);
float diff = max(dot(normal, light_direction), 0.0);
vec4 diffuse_color = diff * light_color;
vec4 ambient_color = ambient_strength * light_color;
FragColor = (ambient_color + diffuse_color) * base_color;
}
|