Computer Graphics Provmoment: Ladokkod: Tentamen ges för: Tentamen NDG011 Systemarkitektprogrammet 7,5 högskolepoäng Namn: (Ifylles av student) Personnummer: (Ifylles av student) Tentamensdatum: 2010-03-02 Tid: 09:00 14.00 Hjälpmedel: Inga hjälpmedel Totalt antal poäng på tentamen: För att få respektive betyg krävs: G=21 VG=34 42 poäng Allmänna anvisningar: Skriv dina svar på separata blad Spara alla filer på F: om inte annat specifikt anges Se till att lösningarna inte har bindningar till filer på C: i andra mappar än specifikt angivna Stäng ner samtliga applikationer och logga ut (via ikon) när du är klar med tentamen. Vid olösliga problem med datorkonto, ta ett nytt och lämna in även detta i tentamensmappen. Rättningstiden är som längst tre veckor Viktigt! Glöm inte att skriva namn på alla blad du lämnar in. Lycka till! Ansvarig lärare: Rikard König Telefonnummer: 033 435 5945
Answers (swe. svarsblankett) Namn: (Ifylles av student) Personnummer: (Ifylles av student) Question 1: A B C D a) b) c) d) e) f) g) Question 2: A B C D a) b) c) d) e) f) g) Question 3: A B C D a) b) c) d) e) f) g) Important note: The minimum result on questions 1 to 3 is 10 points. If this is not reached, question 4 to 6 will not be considered and automatically given 0 points. 2
1. Answer with any of the given answers for the following questions. (a) Which of the following statements are true? A. Interlaced mode means that the screen is drawn with alternating vertical and horizontal lines which can result in flicker at close range. B. Plasma screens uses high voltage to energize gases embedded between glass panels. C. In an LED, the electrical field controls the polarization of the liquid crystals in the middle panel, thus turning on and off the light passing through the panel. D. A Cathode-Ray Tube uses phosphor to emit light. (b) Which is the correct order of the four major tasks in the XNA-rendering pipeline? E. Geometry Processing, Vertex Processing, Pixel Processing, Pixel Rendering. F. Pixel Processing, Vertex Processing, Geometry Processing, Pixel Rendering. G. Vertex Processing, Geometry Processing, Pixel Processing, Pixel Rendering. H. Vertex Processing, Pixel Processing, Geometry Processing, Pixel Rendering. (c) Which are the general equations for projecting (using simple perspective) a 3D point (x,y,z) into a 2D point (x p,y p ) at the plane where z=d? (Hint, the figures below can be used to derive both equations) A. x p =x/(d/z), y p =y/(d/z). B. x p =x/(z/d), y p =y/(z/d). C. x p =x/(z/d), y p =y/(d/z). D. x p =x/(d/z), y p =y/(z/d). (d) Which of the following matrices (when applied to row vectors) will increase the size along the z-axis and move it in the positive direction of the y-axis? A B C D 1 0 0 0 1 0 0 2 1 0 0 1 1 0 0 0 0 1 0 2 0 1 0 0,9 0 1,2 0 2 0 1 0 1,1 0 0 1,8 0 0 0 1,2 0 0 0 1 2 0 0 1,1 1,8 0 0 0 1 0 1,2 0 1 0 0 3 1 0 0 0 0,3 3
(e) Why is homogeneous coordinate system used in computer graphics? A. Rotation cannot be calculated using multiplication without homogeneous coordinates. B. Without homogeneous coordinates translation cannot be calculated the same way as scaling. C. Only orthogonal projection can be represented using normal coordinates. D. Homogeneous coordinates increases the number of perspective divisions which is favorable for modern GPUs. (f) What is the result of multiplying the Matrices X and Y? X Y 2 1 2 2 2 1 0 2 1 1 1 2 * 1 0 1 2 3 3 1 3 3 0 1 0 0 2 1 2 0 2 1 2 A B C D 11 6 5 10 11 6 5 10 11 5 6 10 11 6 5 10 6 5 4 8 6 5 4 8 6 5 4 8 6 5 4 8 12 9 7 18 12 9 8 18 12 3 7 8 12 9 7 18 5 4 5 9 7 4 5 8 5 4 5 8 5 4 5 8 (g). Why is normalization of projections important? A. Normalization is crucial since Pythagoras theorem is used when the final projection is calculated. B. Normalization lets us clip against a simple cube that is parallel to the axes, regardless of type of projection C. Normalization delays the final projection until end which is Important for hiddensurface removal since the depth information is preserved as long as possible D. Normalization removes all negative values which ensure the completeness of perspective division. 4
2. Answer with any of the given answers for the following questions. (a) The Object-space and Image-space approaches are suitable for solving the? A. Aliasing problem. B. Hidden-surface-removal problem. C. Scan-line problem. D. Clipping and visibility problem. (b) Two hard cases when applying depth-sort for use with painters algorithm are? A. Cyclic overlap of three or more objects, and when one object penetrates the surface of another object. B. Cyclic overlap of three or more objects, and when two object overlaps in the z- coordinate but not in the others. C. All z-coordinates of an object are behind the corresponding coordinates of all other objects, and when two object overlaps in the z-coordinate but not in the others. D. All z-coordinates of an object are behind the corresponding coordinates of all other objects, and when one object penetrates the surface of another object. (c) Applying polygons on the z-buffer algorithm can be done? A. Inefficient as polygons can overlap in a cyclic overlap. B. Efficient if observing the constants of the plane equation in respect to pixels. C. Inefficient as polygons then need to be rasterized. D. Efficient if first performing a depth-sort of the polygons. (d) The main three mapping methods that are considered are? A. Texture, Polygon and Bump mapping. B. Texture, Environment and Bump mapping. C. Texture, Bilinear and Reflection mapping. D. Texture, Image and Pixel mapping. 5
(e) Two-part mapping works by? A. First mapping to an intermediate shape as a box, sphere or cylinder and then to the actual shape. B. First performing a pass with calculating the vectors and then performing a second pass with calculating the actual pixels. C. Allowing complex objects that consists of two or more shapes to be drawn by finding the inverse s() and t() functions. D. First mapping the 2D image to a 3D surface and then mapping the surface to the screen window.. (f) Bresenham s algorithm is efficient for drawing lines as it? A. Requires only integer arithmetic. B. Requires only one floating-point operation per pixel. C. Does not need any additional solution for solving the problem with steep lines. D. Only have three candidate pixels in the y-axis for each x pixel. (g) From an high overview, a non-hierarchical model is basically made up of? A. Bones and Meshes. B. Meshes and Transformations. C. Symbols and Instances. D. Graphs and Edges. 6
3. Consider the modified Blinn-Phong shading equation at a fragment with normal n and the material parameters c d, c s (colors) and m (shininess). The direction towards the directional light source is l and the direction to the viewer is v. There are three terms contributing to the final fragment color: ambient, diffuse and specular. For each term mark the subset of the parameters that is needed to compute that term: (a) specular (b) ambient (c) diffuse A c d B c s C m D n E L F v Do not forget to fill in your answers on the first page too! Answer with any of the given answers for the following questions. (d) To draw a scene with both opaque and translucent meshes without artifacts? A. Draw the translucent meshes the Z-buffer write enabled, and then the opaque meshes in back-to-front order with the Z-buffer readonly. B. Draw the translucent meshes in back-to-front order with the Z-buffer readonly, and then the opaque meshes with the Z-buffer write enabled. C. Enable blending and draw the meshes in any order. D. Draw the opaque meshes with the Z-buffer write enabled, and then the translucent meshes in back-to-front order with the Z-buffer readonly. (e) The required minimal output of a fragment/pixel shader is? A. The fragment position in clip coordinates. B. The fragment color in RGBA. C. The fragment normal and texture coordinates. D. The index of the fragment in the vertex buffer. 7
(f) Environment mapping is the name of a set of techniques that produce the appearance of? A. Small surface details by perturbing the normal used by the shading equation at each fragment. B. Reflections of the surrounding environment on the object surface. C. The distant surrounding environment in the scene by mapping images on a sky dome or sky box. D. A terrain surface by creating a mesh of vertices from a height map image. (g) In a bump mapping shader effect the output from a vertex shader program is sent to the pixel shader program(s)? A. As one copy for each fragment created by the rasterizer. B. Directly by reference. C. Interpolated over each object by the vertex processor(s). D. Interpolated for each fragment of a primitive by the rasterizer. 8
4. Create a program that displays two pyramids close to each other in the middle of the screen. One of the pyramids should be rotating around the y- axis and the other around the x axis. The pyramid should be defined in a separate class and should be drawn using indexed vertices that are uploaded to the GPU using vertex buffers. Drawing the pyramid without indexing and uploading the vertices to the GPU can result in maximum 4p. 5. Create a program using XNA that displays a long road, with a moving snowplow placed on it. The road should be dynamically created by tiling a given texture ( roadtile.jpg ) together as a long mesh, consisting of at least 100 tiles. The snowplow should be loaded as a model ( snowplow.fbx ) and while moving along the road the snowplow should relatively move at least one part (bone) in some pattern. The necessary binary contents are provided in the directory ContentQuestion5 on your account. As a helping reminder, the basic algorithm for drawing a model is outlined as follows: foreach(modelmesh mesh in model.meshes) { foreach(basiceffect effect in mesh.effects) { // fix effect } mesh.draw(); } 6. Create a program using XNA that displays the tractor model with the camera rotating around it or movable so the tractor can be inspected from different directions. Create a. An effect that shades all fragments of a mesh part bright green (i.e. the RGB values (0.0, 1.0, 0.0)) regardless of lighting. Apply it to all parts of the mesh named box.003 in the tractor. b. An effect that colors each fragment of a mesh according to the world space normal at that fragment using the encoding color.rgb = 0.5*normal.xyz + 0.5. Apply it to all parts of the meshes named cylinder, box.001 and box.002 in the tractor. (To convince yourself that the world space normals turn out ok it is useful to try setting the color from just one of the normal s x, y and z components at a time.) If you wish you may use a copy of your solution to question 5 as a starting point. 9
10