Assignment 3
Qn 1
Using the camera setting below: glLookAt (100, 0, 100, 20, 0, 20, 0, 1, 0);
Modify the above code and write the glutIdleFunc (animate) function to accelerate from the original position at 𝑡𝑡 = 0 sec to (200, 0, 100) at 𝑡𝑡 = 2 sec. Include a term which can control the rate of acceleration.
Qn 2
a) Write OpenGL code which sets up the following lighting:
A distant light at with lighting direction (0, 1, 0)
The R, G, B components all have the same intensity.
The ambient, diffuse and specular component all have intensity 0.5.
b) Write OpenGL code for the material characteristics of a sphere The R, G, B components all have equal parameters.
Ambient reflection coefficient 𝑘𝑘 = 0.1 𝑎𝑎
Diffuse reflection coefficient 𝑘𝑘𝑑𝑑 = 0.3 Specular reflection coefficient 𝑘𝑘𝑠𝑠 = 0.9 Specular reflection exponent 𝑛𝑛𝑠𝑠 = 2
c) Derive the R intensity at a point on an object positioned at (0, 0, 0) with outward surface normal vector � 1 , 1 ,0�. The camera in Qn 1 is used.
d) What kind of shading method will you recommend for this object? Why?
√2 √2
1
Qn 3
The triangle below is part of a quadrilateral mesh. It is scanned from left to right, top to bottom:
A(0, 5)
C(10,10) D P(x, 6) E
B(10, 0)
a) Let Gouraud shading be used. If the intensities at vertex 𝐴𝐴 and 𝐶𝐶 are 𝐼𝐼𝐴𝐴 = 0.5 and 𝐼𝐼𝐶𝐶 = 1.0 respectively, what is the intensity at 𝐷𝐷?
b) Let Phong shading be used. If the unit normal at 𝐷𝐷 and 𝐸𝐸 are 𝑁𝑁𝐷𝐷 = (0,0,1) 𝑁𝑁𝐸𝐸 = (0, 1, 0)
Derive the incremental form for the normal of a point 𝑃𝑃(𝑥𝑥) which lies on the line segment ����
𝐷𝐷𝐸𝐸.
Qn 4 (This question requires knowledge of Lecture 8)
b) An object is composed of a 100 × 100 quadrilateral mesh. On average, each quadrilateral in the mesh projects to 500 pixels. There are 30 objects in the scene. The graphics monitor has resolution 2560 × 1440. Estimate the number of elementary operations needed by
i) Z buffer
ii) Ray casting for which the objects are all spheres
iii) Ray casting for which the objects are all complex. For this question, assume that it is
easy to test whether a pixel ray intersects a triangle.
a) The point in Qn 2 c) is not hidden. How do you know that? What technique is involved?
2