summaryrefslogtreecommitdiffstats
path: root/dev/a5-artrender/shaders/gouraud.vert
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--dev/a5-artrender/shaders/gouraud.vert23
1 files changed, 11 insertions, 12 deletions
diff --git a/dev/a5-artrender/shaders/gouraud.vert b/dev/a5-artrender/shaders/gouraud.vert
index fa763cb..ca40e12 100644
--- a/dev/a5-artrender/shaders/gouraud.vert
+++ b/dev/a5-artrender/shaders/gouraud.vert
@@ -32,27 +32,26 @@ out vec4 color;
void main() {
-
+
// transform the vertex position into "eye space"
- vec3 v;
+ vec3 v = vec3(model_view_matrix * vec4(vertex, 1.0));
// unit vector from the vertex to the light
- vec3 l;
-
+ vec3 l = normalize(light_in_eye_space - v);
// unit vector from the vertex to the eye point, which is at 0,0,0 in "eye space"
- vec3 e;
+ vec3 e = normalize(-v);
// normal transformed into "eye space"
- vec3 n;
-
+ vec3 n = (normal_matrix * vec4(normal, 0)).xyz;
// halfway vector
- vec3 h;
-
+ vec3 h = normalize(l + e);
// calculating lighting output the color for this vertex
- // ...
-
-
+ vec4 ambient = ka * Ia;
+ vec4 diffuse = kd * Id * max(dot(n, l), 0);
+ vec4 specular = ks * Is * pow(max(dot(n, h), 0), s);
+ color = ambient + diffuse + specular;
+
// do the standard projection of the incoming vertex
gl_Position = proj_matrix * model_view_matrix * vec4(vertex,1);
}