#version 330 // Input vertex attributes (from vertex shader) in vec2 fragTexCoord; in vec4 fragColor; // in vec3 worldPosition; in vec3 worldNormal; // Input uniform values uniform sampler2D texture0; uniform vec4 colDiffuse; // Output fragment color out vec4 finalColor; uniform vec3 ambient; uniform vec3 lightDir; uniform vec3 lightColor; // NOTE: Add your custom variables here void main() { // Texel color fetching from texture sampler vec4 texelColor = vec4(1); // texture(texture0, fragTexCoord); // final color is the color from the texture // times the tint color (colDiffuse) // times the fragment color (interpolated vertex color) float NDotL = max(dot(lightDir, -worldNormal), 0); // float toon = 0.5 * smoothstep(0.5, 0.51, NDotL) + 0.5; vec3 light = mix(vec3(ambient), lightColor, NDotL); finalColor = texelColor * colDiffuse * vec4(light, 1); }