rendlib/assets/shaders/shader.frag
Kevin Jerebica a176afab7e init: kick-off repository from gravity's SC
source code was taken from my project gravity and
modified so I can reuse the renderer in other projects.
I will also upgrade it, free it from old bugs, put more
effort into learning the math behind rendering, etc.
2024-10-08 00:15:42 +02:00

22 lines
549 B
GLSL

#version 330 core
in vec4 frag_pos;
in vec4 frag_normal;
in vec3 object_color;
out vec4 outy;
void main() {
vec4 norm = normalize(frag_normal);
vec4 ambient = vec4(0.7, 0.7788, 0.46, 1.0);
vec4 light_color = vec4(0.7, 0.7, 0.7, 1.0);
vec4 color = vec4(object_color.xyz, 1.0f);
vec4 light_location = vec4(0.0, 100.0, 0.0, 1.0);
vec4 light_direction = normalize(light_location - frag_pos);
float diff = max(dot(norm.xyz, light_direction.xyz), 0.0);
vec4 diffuse = diff * light_color;
outy = color + diffuse;
}