#version 460 layout(triangles, equal_spacing, ccw) in; uniform mat4 mvp; uniform mat4 model; in vec4 fct[]; out vec4 fca; //in vec4 cntr[]; vec4 n4_test(vec4 p){ vec3 offset = p.xyz; return vec4(normalize(offset), 1); } void main(){ vec4 p = gl_TessCoord.r * gl_in[0].gl_Position + gl_TessCoord.g * gl_in[1].gl_Position + gl_TessCoord.b * gl_in[2].gl_Position; gl_Position = mvp * n4_test(p); // This ONLY works because we have a sphere! vec3 normal = (model * p).xyz; // This is the diffuse color AND the ambient color // They don't have to be the same vec3 material = vec3(1, 1, 1); vec3 Direction = vec3(10, 5, 3); // Light direction vec3 I = vec3(1, .4, 0.4); // Light Intensity vec3 R = material * I * clamp(dot(normalize(Direction), normalize(normal)), 0, 1); 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 = material * I2 * dp; vec3 A = material * vec3(.1, .2, .1); fca = vec4(R2 + R + A, 1.0); }