TDA361/DIT220 Computer Graphics, January 15 th 2016 EXAM (Same exam for both CTH- and GU students) Friday January 15 th, 2016, 8.30 12.30 Examiner Ulf Assarsson, tel. 0701-738535 Permitted Technical Aids None, except English dictionary General Information Numbers within parentheses states the maximum given credit points for the task. Solutions shall be clear and readable. Too complex solutions can cause reductions in the provided number of points Questions to examiner during exam will be possible approximately one hour after the start of the exam. If anything is unclear remember what has been mentioned on the lectures, in the slides and course book and do your best. Grades In order to pass the course, passed exam + exercises (or exam + project) are required. The final grade is calculated from the exam grade. The exam is graded as follows CTH: 24p grade 3 < 36p grade 4 < 48p grade 5 GU: 24p G < 45p VG Max 60p Grades are announced by the LADOK system ~3 weeks after the exam Solutions will be announced on the course home page. Review Opportunity to review the correction of your exam is provided on Wednesday February 10 th at 12.00, room 4117 (next to my office room), 4 th floor (west corridor), EDITbuilding.
Question 1 a) [1p] Assume you have implemented a DDA algorithm for line drawing that only can draw lines with a low slope correctly, but has problems with steep lines (see image below). How can you in a simple way make it plot steep lines as well? Answer: Swap roles of x and y. I.e., loop over y, instead of x, to plot the (x,y)- value. b) [1p] What does the geometry shader do? Answer: takes one primitive as input and outputs 0 or more new primitives - possibly other primitives. E.g. triangles, lines, points. c) [2p] To draw transparent objects using for instance OpenGL, you typically divide the triangles in two groups: the transparent ones and the opaque ones. 1) Which of these two groups needs to be sorted, 2) why, 3) and in which order? Answer: 1) the transparent triangles, 2) for correct blending, 3) back-to-front. d) [1p] What is the z-buffer for? Answer: to resolve visibility / avoid depth sorting. e) [2p] Why do we want to use double buffering? Explain what can happen without it. Answer: 1p: to avoid screen tearing. 1p: if explanation of screen tearing is given f) [3p] State the 4x4 shear matrix that shear x along y, as in the figure below. Answer: 1 a 0 0 0 1 0 0 0 0 1 0 0 0 0 1 where a is non-zero (e.g. ~0.3).
Question 2 a) [5p] Emission is one of the terms in the standard real-time shading model. Which are the 3 other terms? Also, describe how each of the 3 parts are computed (give the formulas and draw picture when needed). State both Blinn s and Phong s model for the corresponding term. Answer: specular, diffuse, ambient, (1p if this is given) 4m (1.5p) spec: = Blinn: max 0, n h shininess m s (also ok without the factor 4) (1.5p) spec: = Phong: (1p) diff: = (1p) amb: = m ( ( ) ) spec spec m max( 0, ( r v) shininess ) m spec s spec ( n l) m diff s diff amb s amb (No reduction in points if the max() are excluded) b) [1p] What is the difference between supersampling and multisampling? Answer: multisampling only runs the fragment shader once per fragment (not once per sample-inside-each-pixel). I.e., multisampling shares computations e.g. executes fragment shader for only one sample, but takes several depth samples. c) [2p] Describe how jittering works and also tell me what is the main advantage compared to other sampling schemes? Answer: replaces undersampling artifacts with noise. Take a random sample position per subcell. d) [2p] Which matrices are involved in the transformation of a vertex from model space to screen space? I.e., give the names for these matrices. Answer: modelviewmatrix (or model-to-world and world-to-view/camera matrix), projection matrix, (viewport matrix). Question 3 a) [3p] Describe the shadow map algorithm. Answer: 1. Render a shadow (depth) map from the light source. 2. Render image from the eye. For each generated pixel, transform/warp the
x,y,z coordinate to light space and compare the depth with the stored depth value in the shadow map (at the pixel position (x,y)). If greater point is in shadow Else point is not in shadow (Bias/offset is necessary due to disretization and precision problems.) b) [1p] Why do you need to use a bias in the shadow map algorithm? What is the cause of the problem? Answer: 1p We compare two different discretizations one from the eye and one from the camera. (1p to avoid z-fighting (incorrect self shadowing) and light leaking, 1p the view sample can lie further from the light than the shadow map sample (due to discrete sampling) ) c) [2p] How many texels needs to be accessed/read (by e.g. the hardware) to compute a tri-linear filtered mipmap value? Explain. Answer: 8 (i.e., 4 per mipmap layer, two layers). d) [4p] Draw a simple scene and visually divide it into 1) an Axis Aligned Bounding Box hierarchy, 2) an Octree or Quadtree, 3) an Axis Aligned Binary Space Partitioning Tree, 4) and a recursive or hierarchical grid You can do all your drawings in 2D for simplicity and you may use different scenes for the different hierarchies. (You don t need to show the corresponding tree structures). The differences in the spatial divisions between all the types of data structures should be clear from your examples, for any score. Question 4 a) [3p] This is the rendering equation. Explain the equation and all of its components. You can include a figure in your answer. L o = Le + Ω f r ( x, ω, ω') L ( x, ω')( ω' n) dω' Answer: f r is the BRDF, w is incoming direction, n is normal at point x, Ω is hemisphere around x and n, L i is incoming radiance, x is position on surface, w is outgoing direction vector. L o (x,w)=l e (x, w)+l r (x, w) (slightly different terminology than Kajiya) I.e., outgoing radiance =emitted + reflected radiance. Integral represents reflected radiance. i
b) [3p] Path tracing: Draw and explain, using the example below, how the color of one of the pixels is computed with path tracing. Observe that it is an area light source. Illustrate using a suitable number of ray paths and recursion depth. c) [2p] Photon mapping: Why do we use a separate global map and caustics map, instead of just having one combined map? Answer: global map represents correct, but sparsely sampled, light distribution. However, the caustics map needs very high sampling (high-frequency phenomenon) to be captured correctly. Instead of shooting a huge amount of photons in all directions, photons are mostly shot in directions of specular objects. Thus, its distribution is biased. d) [2p] Describe the Fresnell effect for dielectric materials and metals, respectively. (You may draw graphs or describe with words.) Answer: dielectrics: High transmittance/low reflectivity for low angles. Low transmittance/high reflectivity for high angles. Metals: high reflectivity for all angles (there can be a slight dip e.g. around 85 degrees) Question 5 a) [1p] Draw the Quincunx pattern and state the weights per sample. Answer: 1 sample in each of the four pixel corners (with weight=1/8) and 1 sample in the pixel center (with weight=0.5) b) [3p] Euler rotations can be used to describe the rotation of an object. The rotation is often defined by head, pitch and roll, which each is a rotation around one of the world space axes. E.g., the combined rotation is M = R z (r) R x (p) R y (h), where R i rotates around the world space axis i. Question: Is M dependent on the multiplication order of R x, R y, and R z? Motivate your answer well.
Answer: Yes. E.g., simply use an example with a 90-degree rotation for the first rotation (head) and then it can be seen that the meaning of the pitch and roll are now flipped. a) [3p] Describe an efficient and conservative method for course pruning of noncolliding objects. Answer: see sweep-and-prune: Collision detection for x,y,z-axes, sort start and end of AABBs, active interval list, update sort using bubble sort, flip bits of matrices. a) [3p] Show how to compute the intersection between a ray and a sphere (in 3D). Answer: See slides from lecture 6. Sphere center: c, and radius r Ray: r(t)=o+td Sphere formula: p-c =r Replace p by r(t): r(t)-c =r and solve for t. Return r(t) Question 6 Miscellaneous a) [2p] In which ways are NURBS more general than B-Splines? Answer: control points can be set at non-uniform intervals and they can have different weights. b) [1p] Assume p=(7,4,1,5). Perform the homogenization step on p. c) [1p] Manually normalize the vector x=(2,3,1).
d) [2p] Describe how to do a simple intersection test between a tetrahedron and a plane. Answer: If all points lie on the same side of the plane, then no intersection. Else, intersection. Insert points into the plane equation and check signs. Hardware e) [4] Draw the logical layout of a modern graphics card. You can use the major functional blocks that we have mentioned in the course. (Hint: preferably I want the layout as described in the hardware lecture, e.g. with the different parallel shader units and the other functional units).