THE AUSTRALIAN NATIONAL UNIVERSITY Final Examinations (Semester 2) 2015 COMP4610/COMP6461 (Computer Graphics) Final Exam Writing Period: 3 hours duration Study Period: 15 minutes duration. During this time you may read text files and pdfs but you are not permitted to start answering questions, although, you are permitted to make notes on your scribble sheet. Permitted Materials: A4 page (one sheet) with notes on both sides Note the standard lab tools are available including: Java, eclipse, gedit, kate, dia, gcc,... The Java API is available at: file:///usr/share/doc/openjdk-7-jre-headless/api/index.html Please Read The Following Instructions Carefully. This exam will be marked out of 100 and consists of 5 questions. Questions are of unequal value. The value of each question is shown in square brackets. Questions that are partitioned into parts show the number of marks given to each part within square brackets. Students should attempt all questions. Answers must be saved into the question's directory (Q1, Q2, Q3, Q4, Q5) using the file(s) or software described in the question statement. If you do use eclipse then use the created projects for Q3, Q4, and Q5, as these have been set up to run the programs and access the correct files for saving your answers. Marks may be lost for giving information that is irrelevant. Q2 is different for students doing COMP4610 and COMP6461, only do the version of this question that corresponds to the course you are enrolled in. Network traffic may be monitored for inappropriate communications between students, or attempts to gain access to the Internet. 1/6
Question 1 Multiple Choice [40 marks] The multiple choice questions are available via a program in the 'Q1' directory. This program is also used for entering your answers. To run the multiple choice program either start it by double clicking the icon on the desktop or by starting it in a terminal. This is done by: opening a Terminal, from the command line change directory (cd) into the Q1 directory, and run the java MultipleChoice program. % cd ~/Q1 % java -jar MultiChoice.jar Your answers are automatically saved every time you press a button. Hence once you have completed your answers you can simply exit from the program (either by pressing the window closing x or by selecting the exit menu item). Note at any time you can restart the program and it will continue on from where you left off. Do not edit files in this directory. Also you can only have one instance of the MultiChoice program running at any one time. There are 20 questions. Each answer you get correct gains you 2 marks, each incorrect answer loses 0.5 marks. Questions left unanswered neither loses nor gains marks. If the question statement contains an underline, that is, then the selected answer should correctly complete the question statement. Some question statements may contain two underline sections, in which case the answer has two parts separated by a comma. The first part corresponds to the first underline section and the second part corresponds to the second underline section. 2/6
Question 2 Short Answer [10 marks] Highest marks are gained by providing clear, concise, and short answers. Save your answers in the file 'Q2Answers.txt' in the Q2 directory. Please make certain that this file is saved both as you progress through the exam and before the exam ends. COMP4610 Students Only i. [4 marks] Explain what Hierarchical Modeling is. Illustrate your explanation with an example. ii. [3 marks] When creating a 3D scene in OpenGL the standard fixed pipeline makes use of the modelview matrix and projection matrix. What purpose do these two matrices serve? How should these matrices be used to set up a scene? iii. [3 marks] Would it be possible to just set the GL_PROJECTION matrix to the identity matrix and then do all your transformations (including the projection transformations) in the GL_MODELVIEW matrix? Explain. COMP6461 Students Only i. [4 marks] Define and describe the following terms: raycasting, raytracing, global illumination, and photon mapping. ii. [3 marks] What are some differences you would observe in a scene between one rendered using raycasting compared to one rendered using raytracing? What are some observable differences if the rendering makes use of photon mapping. iii. [3 marks] Modern GPU hardware has become very efficient at rendering a huge number of triangles enabling it to create realistic scenes in real time. Also the computational power of GPUs has started to make some approaches, such as raytracing and photon mapping, viable for the real time rendering of scenes. Are these approaches suited to modern GPU hardware? Will approaches such as raytracing and photon mapping dominate real time rendering in the future? Explain and justify your answer. 3/6
Question 3 Lab [20 marks] The Q3 directory contains DrawIt.java, ToolBar.java, and DrawArea.java. These form a simple drawing program. Compile and run them ("javac *.java; java DrawIt"). When you drag the mouse around the window single pixels will be marked by the dragging action. Modify the code such that it draws a continuous line as you drag the mouse around. Add selection radio buttons (like the colour radio buttons) that enables you to change the thickness of the lines drawn. 4/6
Question 4 Lab [20 marks] The Q4 directory contains the code for the ray-tracing lab. Modify the 'raytrace' method in 'Scene.java' such that it's illumination model includes ambient, diffuse and specular lighting. The diffuse and specular lighting must be from a directional light source. You should adjust lighting parameters such that ambient, diffuse and specular effects are viewable. Add a comment to each statement you add to the code to explain what that statement does (place these comments in Scene.java above the added statement). Hints: The equation for the Phong reflection model is: I p =k a i a + lights (k d ( L.N )i d + k s (R.V ) α i s ) where L is the unit vector pointing at the light source, N is the unit vector normal to the surface, V is the unit vector pointing at the viewer, R is the reflection on the surface from the light source (also a unit vector), alpha is the shininess, k a, k d, and k s are reflection constants, i a, i d, and i s are light intensities. You would normally calculate each colour channel separately. k a and k d would normally come from the surface's colour and be the same, k s can just be set to white. Get each lighting aspect working separately and then combine them. Clamp the colour values. 5/6
Question 5 Lab [10 marks] Note: part marks in these questions may be gained for partial working solutions or just a viable description of how you would approach such a problem. These questions relate to question Q3 and Q4 respectively, you may copy code from your previous answers however you must have your answer to this question completely in the Q5 directory (similarly the answer to Q3 and Q4 must be complete within their respective directories). Do only ONE of the following two options: A) When drawing curved lines with the DrawIt program you don't end up with particularly smooth lines, this is especially the case when you drag the mouse quickly around the screen. Extend the DrawIt application such that the lines are drawn more smoothly. In your extension you must use the blending approach described below and you must address the problem that you need to be able see the curve as it is drawn (you don't want a gap between the pen and the 'ink' flowing from it) yet you don't know the shape of the curved line as it is drawn (this is because the blending function uses the next point after the current point to determine the shape of the line between the current and previous point). This problem can be addressed by using an image buffer to draw a temporary line onto, this image buffer can be shown to the user as the line is drawn. Once the line is complete it can be smoothed out and drawn onto the main image buffer. The blending function simply takes a weighted average of the surrounding points. So if we assume dragging the mouse creates a sequence of points p 0, p 1, p 2,. p n. Then the curve between point p i and p i+1 can be inscribed by the blending function: p(u)=( 1 u 4 ) p i 1+( 2 u 4 ) p i+( 1+u 4 ) p i+1+( u 4 ) p i+2 where we varying u for 0 to 1. Note this curve will not necessarily pass through the control points. Generally we want the lines to start at the first point in the sequence and end at the last point, so rather than have different blending functions for the first and last sections of the curve, simply duplicate the first and last points in the sequence a few times. B) The ray-tracer currently only renders spheres. Your task is to add to it the ability to render textured rectangles. The raytracing code is available in the Q5 directory. Note your solution for question 5 must be placed completely within this Q5 directory. You don't need to add the lighting model from the previous question into this extension. The basic raytracing code has been enhanced to include the Surface interface, the Intersect class, the Texture class, and the Rectangle class. Read over the code for these so that you can understand what they are doing. The only method you should need to modify is the intersect method in the Rectangle class. Currently this always returns null, as if rays never hit the rectangle. Add to this function such that when a ray does hit the rectangle an Intersect object is returned. This object contains the distance the ray traveled and the color of the surface that the ray hits. In this case the colour needs to be looked up from the texture. Don't modify the fields or constructor of the Rectangle code, once your intersect method is working correctly you should see the computer graphics logo spinning on its top edge. An example of one frame is given in the diagram to the right. To make this task a little simpler the cross product has been added to the P3D class. 6/6