From c230f5aaea3df46ae9a4d7c1c9761e55ef827b82 Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 27 Nov 2023 20:02:08 +0100 Subject: feat(engine): add lighting maps --- engine/fragment.glsl | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 engine/fragment.glsl (limited to 'engine/fragment.glsl') diff --git a/engine/fragment.glsl b/engine/fragment.glsl new file mode 100644 index 0000000..428e87f --- /dev/null +++ b/engine/fragment.glsl @@ -0,0 +1,34 @@ +#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; + +void main() +{ + vec3 ambient_light = calc_ambient_light(in_texture_coords); + + vec3 light_direction = normalize(light.position - in_frag_pos); + vec3 norm = normalize(in_normal); + + vec3 diffuse_light = calc_diffuse_light(light_direction, norm, in_texture_coords); + + vec3 specular_light = calc_specular_light( + light_direction, + norm, + view_pos, + in_frag_pos, + in_texture_coords + ); + + FragColor = vec4((ambient_light + diffuse_light + specular_light), 1.0); +} -- cgit v1.2.3-18-g5258