COSC363-18S1 (C) Computer Graphics 2018
Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit
Mid-year Examinations, 2018
COSC363-18S1 (C) Computer Graphics
Question 1. [10 marks for the whole question] Transformations
Assume that you are given a function drawObject () that draws a rectangular-shaped axis aligned object shown in Fig. 1a. The origin of the coordinate frame, denoted by O, is located at one end of the object.
y
Note: z-axis is perpendicular to the paper,
towards the reader.
z Fig. 1a
P
Fig. 1b
You are also given the following set of instructions for creating the model shown in Fig. 1c: Step 1: Create the object (Object- 1) as in Fig. 1b, by calling drawObject().
Step 2: Create another copy of the object, make its axis vertical (you will need to specify the angle and axis of rotation) and then translate it to the point P = (xp, yp, zp). (Object-2)
Step 3: Create a third copy of the object, scale it by a factor 0.5 along the x-axis, and translate it to the point Q = (xq, yq, zq). (Object-3). Steps 1-3 generate the model shown in Fig. 1b.
Step 4: Rotate the second and third objects together about the pivot point P=(xp,yp,zp) as shown in Fig. 1c. The angle of rotation indicated in the figure is on the xy-plane.
Step 5: Translate the whole model to some point S = (xs, ys, zs) in the scene (not shown in the figure).
Write a code segment containing OpenGL transformation functions and glPushMatrix-glPopMatrix blocks, for generating the model and transformations given in steps 1-5 above.
Question 2. [10 marks for the whole question] Illumination Model
A certain application uses the following values for the light and material properties:
Light’s properties: ambient = (0.2, 0.2, 0.2), diffuse = (1, 1, 1), specular = (1, 1, 1)
Material’s properties: ambient = (1, 0.5, 0.2), diffuse = (1, 0.5, 0.2), specular = (1, 1, 1).
(a) [2 Marks] Write the components of the colour seen at any vertex where n.l < 0 (n = normal
vector, l = light source vector).
(b) [4 Marks] Draw a figure showing a vertex of a surface, a light source vector, the normal vector, the reflection vector, the view vector and the half-way vector. Also mark the angles used in lighting calculations.
(c) [4 Marks] If the surface normal vector at a vertex is (0.707, 0.707, 0), and the light source vector is (0.8, 0.6, 0), write the colour value for diffuse reflection at the vertex.
Question 3. [10 marks for the whole question] Mathematical Aspects
C (1, 0, 1)
u
v
A
(7, 2, 8)
w
B
(4, 5, 3)
Consider the triangle given in Fig. 2 above, and answer the following questions:
(a) [3 Marks] Write the components of vectors u and v and show that the vectors are
perpendicular to each other.
(b) [5 Marks] Compute the normal vector of the plane of the triangle, and convert the vector to a unit vector.
(c) [2 Marks] Write the mathematical expression for computing the angle using the vectors shown in Fig.2. You are not required to compute the numerical value of .
Question 4. [10 marks for the whole question] Matrices
(a) [4 Marks] Describe the transformation represented by the following matrix product. Please give the parameters of each transformation (scale factors, angle, axis of rotation etc.) and also the order in which the transformations are applied to the point (x, y, z). You are not required to multiply the matrices.
(b) [4 Marks] An object is rotated about a pivot point (5, 3, 2) by an angle 30 with the axis of rotation parallel to the y-axis. Write the matrix expression (a product of matrices similar to that given in the previous question) for the transformation. You are not required to multiply the matrices. The matrices should contain only numerical values.
(c) [2 Marks] In the following equation, a vector is transformed by a matrix, but the result of the transformation is same as the original vector. Briefly explain why the vector is not changed by the transformation.
Question 5. [10 marks for the whole question] Texture Mapping
Four quadrilaterals are arranged as shown in Fig. 3a, to form one large square.
(a) [5 Marks] Write the texture coordinates for the vertices A..I that give a mapping shown in Fig. 3b, where only the upper left region of the texture (0 ≤ s ≤ 0.5, 0.5 ≤ t ≤ 1) is used.
(b) [5 Marks] Write the texture coordinates for the vertices A..I that give a mapping shown in Fig.
3c. Assume that the texture wrap mode is set to GL_REPEAT along both directions s and t.
100
80
0
Texture:
y
0 40 100
Figure 3a
Question 6. [10 marks for the whole question] Projections
A view frustum is specified using the following statement:
gluPerspective(60.0, 1, 20.0, 100.0);
(a) [4 Marks] Give a brief (one sentence) description for each parameter of the above function.
(b) [6 Marks] Use the equation h = 2N tan(fov/2) to compute the height h of the near plane. Then
compute the values of the parameters of the function glFrustum(L, R, B, T, N, F) that represents the same view frustum generated by the gluPerspective function given above.
Question 7. [10 marks for the whole question] Ray Tracing
(0, 0.8, 0.6)
Eye
(4, 2, 0)
(7, 5, 12)
(7, 2, 4)
View plane
Figure. 4
A primary ray is traced from the eye position (4, 2, 0) through the point (7, 2, 4), as shown in Fig. 4. The ray hits a plane that contains the point A = (7, 5, 12). The plane’s unit normal direction is (0, 0.8, 0.6).
(a) [2 Marks] What are the values ofp0 and d in the equation of the ray : p = p0 + td ?
(b) [5 Marks] Compute the value of the ray parameter t at the point Q where the ray meets the plane. What does this value of t represent?
(c) [3 Marks] Compute the coordinates of the point of intersection Q.
Question 8. [10 marks for the whole question] Bezier Curves.
(a) [7 Marks] Given three control points P0 = (2, 0, 2), P1 = (1, 4, 2), P2 = (0, 2, 1), write the
parametric equations for x(t) , y(t), z(t) for points on the Bezier curve.
(b) [3 Marks] Show that all points on the Bezier curve in the previous quesion satisfy the equation
x2 = y + 2z.
Question 9. [10 marks for the whole question] OpenGL-4 Shaders.
(a) [2 Marks] Briefly describe two important computations that are commonly performed inside a vertex shader.
(b) [8 Marks] Give a brief description for each of the following statements taken from the code of a vertex shader.
(i) layout (location = 0) in vec4 position;
(ii) uniform mat4 mvpMatrix;
(iii) gl_Position = mvpMatrix * position;
(iv) out vec4 theColour = ambient + diffuse + specular;
Question 10. [10 marks for the whole question] Tessellation Shaders.
(a) [5 Marks] Outline two uses of a tessellation control shader. Briefly describe one application where a tessellation control shader could be effectively used.
C
D
E
A
Figure. 5
(b) [5 Marks] A triangle domain is tessellated as shown in Fig. 5. The tessellation coordinates of two points A, B on the domain are also given.
(i). Write the tessellation coordinates of the points C, D and E.
(ii). Write the inner and outer tessellation levels used in generating the figure.
2022-06-08