Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Mid-year Examinations, 2021

COSC363-21S1 (C) Computer Graphics

Question 1.  [14 marks for the whole question]  Transformations

For each of the questions (a)-(c) given below, write a small code segment containing the functions mentioned  in  the  question  along  with  OpenGL  transformation  functions,    glPushMatrix(),    and glPopMatrix() functions for generating the required transformation.

(a).  (4 Marks)  Refer to Fig. 1a.  The model consists of two parts A (arrow), and B (base). The base is positioned at the origin, and the arrow can rotate about  the pivot point P = (-5, 10, 0). In its initial configuration, the arrow makes an angle of 45 from the horizontal on the xy-plane.  The following two functions are used to draw the model:

drawArrow();

drawBase();

Write a code segment that performs the following transformation:  The arrow is rotated about P so that it is horizontal, pointing in the direction of x axis. Both the arrow and the base are then rotated about the y-axis, so that the arrow points towards z axis.

(b). (6 Marks)  Refer to Fig. 1b. The top figure (i) is produced by calling a  function drawBeetle(). Write the code segment that creates two copies of the object and transforms them as shown in the bottom figure (ii).

(c).  (4  Marks)  Refer  to  Fig.   1c.     The  top  figure  (i)  is  produced  by  calling  a     function drawTriangle ().   The triangle’s base is 2 units and height 1 unit. Write the code segment that transforms the triangle as shown in the bottom figure (ii).

 

 

 

 

 

 

 

 

 

 

Fig. 1a

 

 

 

 

 

Fig. 1b

 

 

Fig. 1c

Question 2.  [8 marks for the whole question]

n

v

20

40

Fig. 2.                              P

Fig. 2 shows the normal vector n, light source vector l, and the view vector v at a vertex P.  All vectors are unit vectors on the xy-plane.

(a). (2 Marks) Redraw this diagram in your answer booklet, and show the reflection vector r and the half-way vector h.

(b). (2 Marks)  Using the angles given in the diagram, find the angles between n and h  and also the angle between r and v.

(c).  (4 Marks)  Compute the colour at the vertex P using the above angles in the formula: Pcolour = Lamb Mamb + Ldif Mdif   (nl)  + Lspe Mspe   (nh)f  .

where,

Lamb = (0.2, 0.2, 0.2),  Ldif    = (1, 1, 1),

Mamb= (1, 0, 1),           Mdif  = (1, 0, 1),


Lspe    = (1, 1, 1)

Mspe  = (1, 1, 1),      f  = 1.

Question 3.  [5 marks for the whole question]  Object Modelling,  Texture Mapping

A triangle fan is generated as shown in Fig. 3a,  with p as the central vertex and v0, … v6    as the edge vertices.   The image given in Fig. 3b is used for producing a texture mapped output of the triangle fan as shown in Fig. 3c.

 

Write a code segment containing a glBegin()-glEnd() block,  defining the texture mapped model of the triangle fan.  In the code segment, use  (px, py, pz) as coordinates of the central vertex, and  (vx[i], vy[i], vz[i]) the coordinates of the vertex vi,  i = 0..6.  Also, please specify the texture coordinates at each vertex. You are not required to include any other vertex attributes such a colour or normal vector in your code.

Question 4.  [8 marks for the whole question]  Viewing and Projection

(a).   (4 Marks)   Draw  a  sketch of the canonical view volume, including the axes of the clip

coordinate reference frame.

(b).  (2 Marks) On the canonical view volume, mark a point on the near plane and another point on the far plane, and write their clip coordinates.

(c).  (2 Marks)  What is meant by pseudo-depth of a point?  What is the pseudo-depth of a point on the near plane?

Question 5.  [6 marks for the whole question] Ray Tracing

A primary ray in a ray tracing algorithm meets an object at a point P = (0, 0, -40)  (Fig. 4).  The scene contains only one light  source located  at the point L =  (0, 40,  - 10).   A  shadow ray is generated at P to determine if the point P is in shadow.

Fig. 4.

(a).  (3 Marks)  Write the components of the unit vector along the shadow ray at P.

(b).  (3 Marks) The shadow ray returns a value 52 for the ray parameter t at the closest point of intersection.

(i)      What does this value of t represent?

(ii)     Is the point P in shadow?  If yes, why; if not, why not?

Question 6.  [9 marks for the whole question]  Tessellation Shaders

(a).  (2 Marks)  Briefly outline two main operations performed in a tessellation control shader.

(b).  (3 Marks) A primitive of type GL_PATCHES is not directly renderable. Briefly explain how a primitive of this type is used and a renderable object is produced in an OpenGL-4 application.

(c).  (4 Marks)  A quad domain is tessellated as shown in Fig. 5  below.  Write the inner  and outer tessellation levels used in generating the figure,  and give the tessellation coordinates of the points C, D  and E.