Tutorial 7
Tutorial 7
Tutorial 7
More complicated global models of illumination also consider light inter-reflected between
polygons. And ray-tracing methods can be used to model mirrored surfaces, refraction, etc. And
there are other more advanced models.
∑ [I k ]
lights
I a ka + i diff ( N ⋅ L) + I i k spec ( R ⋅ V ) n
i =1
Specular R = 2N(N·L) – L
= 2(0,0,1) T[0.986] – (0.164,0,0.986)T
= (-0.164,0,0.986)
V = (1,2,5) T - (0.333,1,1)T
= (0.160,0.239,0.958) T (normalized)
R·V = 0.971
Iikspec(R·V)n = 0.5(0.6)(0.971)10
= 0.5(0.6)(0.745)
= 0.224
For this example the incident light is 0.738*(1,1,1) – since the light is white
If the object, for example, were dark red (r,g,b) = (0.5,0,0), then the light reflected from P
would be (0.5,0,0)·(0.738, 0.738, 0.738) = (0.369,0,0).
Flat shading
• Entire surface (polygon) has one colour
• Cheapest to compute, and least accurate (so you need a dense
triangulation for decent-looking results)
• OpenGL – glShadeModel(GL_FLAT)
Phong shading
• Compute illumination for every pixel during scan conversion
• Interpolate normals at each pixel too
• Expensive, but more accurate
• Not supported in OpenGL (directly)
Gouraud shading
• Just compute illumination at vertices
• Interpolate vertex colours across polygon pixels
• Cheaper, but less accurate (spreads highlights)
• OpenGL - glShadeModel(GL_SMOOTH)
Phong illumination
• Don’t confuse shading and illumination!
• Shading describes how to apply an illumination model to a
polygonal surface patch
• All these shading methods could use Phong illumination (ambient,
diffuse, and specular) or any other local illumination model
BSP trees
[Hill: 707-711. Foley & van Dam: p. 675-680]
First, create a root node and partition plane. Obviously the root does not have any children.
We work through drawing the BSP from a point in the scene, following the algorithm.
Example: from a point in the extreme lower-right corner:
behind(0) 0 front(0)
front(3b) 3b behind(3b) 0 front(0)
….
5b 3b 4b 0 5ff 3f 5fb 4f