Worksheet 4, Part 6 — Lighting and shading questions

Answers refer to our implementation: the full Phong reflection model with a distant white light \(\ell_e=(0,0,-1)\), computed in world space, with \(L_i=L_e\) (no shadows) and \(k_a=k_d\).

a) Flat vs. Gouraud vs. Phong shading

All three use the same reflection model; they differ in where/how often it is evaluated and what is interpolated across a triangle:

ShadingLighting evaluatedInterpolated across triangleLook
Flatonce per triangle (single face normal)nothing — constant colourfaceted
Gouraudper vertex (vertex shader)the resulting coloursmooth, weak highlights
Phongper fragment (fragment shader)the normal (and position), re-normalizedsmooth, sharp highlights

How to implement flat shading: use a single normal per triangle (the geometric face normal \(\vec n=\widehat{(b-a)\times(c-a)}\)), or mark the colour/normal output with WGSL's @interpolate(flat) so the provoking vertex's value is used for the whole triangle (no interpolation).

Gouraud or Phong for highlights? Phong. The specular term \((\max(\vec\omega_r\!\cdot\vec\omega_o,0))^s\) is a sharply-peaked, non-linear function of the normal. Gouraud only samples it at the vertices and then linearly interpolates the colour, so a highlight falling between vertices is smeared or missed entirely (visible in our Part 4 as a soft blob). Phong interpolates the normal and re-evaluates per pixel, so the highlight is crisp and correctly placed (Part 5).

b) Directional vs. point light

The distinction is encoded in the homogeneous \(w\) of the light position \(\boldsymbol p_\ell=(x,y,z,w)\):

c) Does the eye position influence the shading?

Yes, but only the specular term. Ambient and diffuse depend on \(\vec n,\ \vec\omega_i\) and the material — not on the viewer. The specular term depends on the direction to the observer \(\vec\omega_o=\widehat{\boldsymbol e-\boldsymbol x}\) (through \(\vec\omega_r\!\cdot\vec\omega_o\)), so moving the eye moves the highlight. For a purely diffuse material (\(k_s=0\)) the eye position has no effect at all.

d) Effect of setting the specular term to \((0,0,0)\)

The highlight disappears and the sphere becomes a purely diffuse (Lambertian) surface plus ambient: \(L_o=k_d L_e\max(\vec n\!\cdot\vec\omega_i,0)+k_a L_a\). It looks matte/chalky and loses all view dependence (see (c)).

e) Effect of increasing the shininess exponent \(s\)

Because the specular falloff is \((\cos\phi)^{s}\), a larger \(s\) makes the highlight smaller, tighter and brighter at its centre — the surface looks harder/glossier (more mirror-like). A smaller \(s\) spreads the highlight into a broad, soft sheen — a more matte, rougher-looking surface.

f) In what coordinate space did we compute the lighting?

In world space: we transform the position and normal by the model matrix (\(\boldsymbol x_w=M\boldsymbol x,\ \vec n_w=\,\)normalize\((M\,\vec n)\)) and supply the eye point and light direction in world coordinates. Eye space would give identical results (the eye then sits at the origin). Since our sphere uses \(M=I\), world space coincides with object space here.

Note: a normal is transformed with the normal matrix \(N=(M^{T})^{-1}\). With only rotation/uniform scale (our case) this reduces to \(M\) itself, so transforming the normal by \(M\) is correct.