#version 460 in vec3 in_vertex; in vec3 in_normal; in vec2 in_texcoord; uniform mat4 mvp; uniform mat4 model; uniform float factor; out vec2 f_texcoord; out vec4 light; void main(void) { gl_Position = mvp * vec4(in_vertex + (clamp(factor, 0, 1) * in_normal), 1.0); f_texcoord = in_texcoord; vec3 normal = (model * vec4(in_normal, 1.0)).xyz; vec3 Direction = vec3(10, 5, 3); // Light direction vec3 I = vec3(1, .4, 0.4); // Light Intensity vec3 R = I * clamp(dot(normalize(Direction), normalize(normal)), 0, 1); // Note: r is without the material vec3 Direction2 = vec3(10, -5, 3); // Light direction vec3 I2 = vec3(.3, .3, .9); // Light Intensity // If you don't use clamp, then you can do this instead float dp = dot(normalize(Direction2), normalize(normal)); if(dp < 0) dp = 0; vec3 R2 = I2 * dp; // Again, R2 lacks the material vec3 A = vec3(.1, .2, .1); // Same thing for A, no material light = vec4(R2 + R + A, 1.0); }