diff options
author | Matt Strapp <matt@mattstrapp.net> | 2021-11-24 09:18:24 -0600 |
---|---|---|
committer | Matt Strapp <matt@mattstrapp.net> | 2021-11-24 09:18:24 -0600 |
commit | 843308f07547b969c97efc23848f4e81b50a5b24 (patch) | |
tree | b709343d4b06880dbd0b06776bc2aa8a57fd9602 /dev/a5-artrender/shaders/gouraud.vert | |
parent | Merge branch 'support-code' of https://github.umn.edu/umn-csci-4611-f21/share... (diff) | |
download | csci4611-843308f07547b969c97efc23848f4e81b50a5b24.tar csci4611-843308f07547b969c97efc23848f4e81b50a5b24.tar.gz csci4611-843308f07547b969c97efc23848f4e81b50a5b24.tar.bz2 csci4611-843308f07547b969c97efc23848f4e81b50a5b24.tar.lz csci4611-843308f07547b969c97efc23848f4e81b50a5b24.tar.xz csci4611-843308f07547b969c97efc23848f4e81b50a5b24.tar.zst csci4611-843308f07547b969c97efc23848f4e81b50a5b24.zip |
Do a5
Diffstat (limited to 'dev/a5-artrender/shaders/gouraud.vert')
-rw-r--r-- | dev/a5-artrender/shaders/gouraud.vert | 23 |
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); } |