Files
OpenGL_Intro/shaders/simple.frag

19 lines
528 B
GLSL

#version 460 core
layout(location = 0) out vec4 color;
in vec4 vColor;
in vec3 vNormal;
void main() {
vec3 lightDirection = normalize(vec3(0.8, -0.5, 0.6));
// ambient component
float ambientStrength = 0.1;
vec3 ambient = ambientStrength * vColor.rgb;
// diffuse component (Lambert)
float lambert = max(0.0, dot(normalize(vNormal), -lightDirection));
vec3 diffuse = vColor.rgb * lambert;
// combine ambient and diffuse
vec3 result = ambient + diffuse;
color = vec4(result, vColor.a);
}