28 lines
744 B
GLSL
28 lines
744 B
GLSL
#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;
|
|
}
|