CS559 Computer Graphics Fall 2015

Similar documents
CS559 Computer Graphics Fall 2015

CS559 Computer Graphics Fall 2015

CS 4620 Midterm, October 23, 2018 SOLUTION

CS 130 Final. Fall 2015

CS 381 Computer Graphics, Fall 2008 Midterm Exam Solutions. The Midterm Exam was given in class on Thursday, October 23, 2008.

CS 130 Exam I. Fall 2015

OPENGL RENDERING PIPELINE

C P S C 314 S H A D E R S, O P E N G L, & J S RENDERING PIPELINE. Mikhail Bessmeltsev

Lighting and Shading II. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

Computer Graphics Coursework 1

CS452/552; EE465/505. Lighting & Shading

GLSL Introduction. Fu-Chung Huang. Thanks for materials from many other people

Pipeline Operations. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2018 Lecture 11

CS452/552; EE465/505. Intro to Lighting

Pipeline Operations. CS 4620 Lecture 14

Lecture 17: Shading in OpenGL. CITS3003 Graphics & Animation

CS559 Computer Graphics Fall 2015

CS 381 Computer Graphics, Fall 2012 Midterm Exam Solutions. The Midterm Exam was given in class on Tuesday, October 16, 2012.

CS 130 Exam I. Fall 2015

CS 4620 Midterm, March 21, 2017

Shadows. Prof. George Wolberg Dept. of Computer Science City College of New York

For each question, indicate whether the statement is true or false by circling T or F, respectively.

Institutionen för systemteknik

Objectives Shading in OpenGL. Front and Back Faces. OpenGL shading. Introduce the OpenGL shading methods. Discuss polygonal shading

CS Exam 1 Review Problems Fall 2017

Virtual Cameras and The Transformation Pipeline

CS 4620 Program 3: Pipeline

Lecture 5 Vertex and Fragment Shaders-1. CITS3003 Graphics & Animation

CS 464 Review. Review of Computer Graphics for Final Exam

Module Contact: Dr Stephen Laycock, CMP Copyright of the University of East Anglia Version 1

Blue colour text questions Black colour text sample answers Red colour text further explanation or references for the sample answers

Shaders. Slide credit to Prof. Zwicker

WebGL and GLSL Basics. CS559 Fall 2015 Lecture 10 October 6, 2015

Lets assume each object has a defined colour. Hence our illumination model is looks unrealistic.

CHAPTER 1 Graphics Systems and Models 3

The Rasterization Pipeline

Computer Graphics with OpenGL ES (J. Han) Chapter 6 Fragment shader

Surface Graphics. 200 polys 1,000 polys 15,000 polys. an empty foot. - a mesh of spline patches:

Lecture 11 Shaders and WebGL. October 8, 2015

GPU Programming EE Midterm Examination

Computer Graphics. Lecture 02 Graphics Pipeline. Edirlei Soares de Lima.

C O M P U T E R G R A P H I C S. Computer Graphics. Three-Dimensional Graphics V. Guoying Zhao 1 / 65

Exercise Max. Points Total 90

[175 points] The purpose of this assignment is to give you practice with shaders in OpenGL.

Computergraphics Exercise 15/ Shading & Texturing

Objectives. Introduce the OpenGL shading Methods 1) Light and material functions on MV.js 2) per vertex vs per fragment shading 3) Where to carry out

CS602 Midterm Subjective Solved with Reference By WELL WISHER (Aqua Leo)

12.2 Programmable Graphics Hardware

CS452/552; EE465/505. Review & Examples

INFOGR Computer Graphics

Deferred Rendering Due: Wednesday November 15 at 10pm

3D Polygon Rendering. Many applications use rendering of 3D polygons with direct illumination

INFOGR Computer Graphics

Sign up for crits! Announcments

Pipeline Operations. CS 4620 Lecture 10

OpenGL shaders and programming models that provide object persistence

WebGL and GLSL Basics. CS559 Fall 2016 Lecture 14 October

Programmable Graphics Hardware

Computer Science 426 Midterm 3/11/04, 1:30PM-2:50PM

Shader Programs. Lecture 30 Subsections 2.8.2, Robb T. Koether. Hampden-Sydney College. Wed, Nov 16, 2011

Computer Graphics (CS 543) Lecture 10: Soft Shadows (Maps and Volumes), Normal and Bump Mapping

CSE 167: Lecture #8: GLSL. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

Drawing in 3D (viewing, projection, and the rest of the pipeline)

Midterm Exam CS 184: Foundations of Computer Graphics page 1 of 11

CS452/552; EE465/505. Models & Viewing

Computer graphics 2: Graduate seminar in computational aesthetics

Chapter 5. Projections and Rendering

Three Main Themes of Computer Graphics

CS 418: Interactive Computer Graphics. Basic Shading in WebGL. Eric Shaffer

CMSC427: Computer Graphics Lecture Notes Last update: November 21, 2014

Computer Graphics (CS 543) Lecture 8a: Per-Vertex lighting, Shading and Per-Fragment lighting

GLSL Introduction. Fu-Chung Huang. Thanks for materials from many other people

Homework 3: Programmable Shaders

Advanced Lighting Techniques Due: Monday November 2 at 10pm

Spring 2012 Final. CS184 - Foundations of Computer Graphics. University of California at Berkeley

Today s Agenda. Basic design of a graphics system. Introduction to OpenGL

Homework #2. Shading, Ray Tracing, and Texture Mapping

CS 4620 Midterm 1. Tuesday 22 October minutes

Recall: Indexing into Cube Map

CSE 690: GPGPU. Lecture 2: Understanding the Fabric - Intro to Graphics. Klaus Mueller Stony Brook University Computer Science Department

Lecture 3 Sections 2.2, 4.4. Mon, Aug 31, 2009

CSE Intro to Computer Graphics. ANSWER KEY: Midterm Examination. November 18, Instructor: Sam Buss, UC San Diego

Notes on Assignment. Notes on Assignment. Notes on Assignment. Notes on Assignment

Computer Graphics I Lecture 11

Drawing in 3D (viewing, projection, and the rest of the pipeline)

Introduction Rasterization Z-buffering Shading. Graphics 2012/2013, 4th quarter. Lecture 09: graphics pipeline (rasterization and shading)

CSE 167: Lecture #8: Lighting. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2011

Lecture 4. Viewing, Projection and Viewport Transformations

COMP environment mapping Mar. 12, r = 2n(n v) v

CV: 3D sensing and calibration

COMP371 COMPUTER GRAPHICS

3D GRAPHICS. design. animate. render

We assume that you are familiar with the following:

EDAF80 Introduction to Computer Graphics. Seminar 3. Shaders. Michael Doggett. Slides by Carl Johan Gribel,

Introduction to Computer Graphics with WebGL

Matrix Operations with Applications in Computer Graphics

Programming with OpenGL Part 3: Shaders. Ed Angel Professor of Emeritus of Computer Science University of New Mexico

CS230 : Computer Graphics Lecture 4. Tamar Shinar Computer Science & Engineering UC Riverside

TSBK03 Screen-Space Ambient Occlusion

Topics and things to know about them:

Transcription:

CS559 Computer Graphics Fall 2015 Practice Midterm Exam Time: 2 hrs 1. [XX Y Y % = ZZ%] MULTIPLE CHOICE SECTION. Circle or underline the correct answer (or answers). You do not need to provide a justification for your answer(s). (1) When combining transforms by multiplying the respective 4 4 matrices, the order of multiplication (i.e. the order of composition) typically matters. In which of the following cases can we, as an exception, swap the order between two sequentially applied transformations? (Circle or underline ALL correct answers) (a) A translational and a scaling transformation. (b) Two scaling transformations. (c) A translation and a perspective projection transformation. (d) Two rotation transformations in 3D. (2) Which of the following statements about homogeneous coordinates are accurate? (Circle or underline ALL correct answers) (a) Using homogeneous coordinates allows us to express more than just linear transformations as matrix multiplications. (b) With homogeneous coordiates the graphics pipeline can implement perspective transformations without requiring expensive division operations. (c) When combined with 4 4 transformation matrices, they allow us to compose affine transforms by simple matrix multiplication. (3) Will a perspective transformation preserve the angle between two intersecting lines in space (i.e. will the projected lines on the display have the same angle?) (Circle or underline the ONE most correct answer) (a) Yes. Other properties like relative distances can change, but angles are preserved under perspective projection. (b) The only thing that is preserved is that lines that are parallel in 3D space remain parallel (on the display) after perspective transformation. Angles, however, are not preserved. (c) No; in the general case angles between lines, and even the property of lines being parallel can change after a perspective transformation. 1

(4) Which of the following would be a good test for checking that points p, q, and r (in the 3-dimensional space) are co-linear? (Circle or underline the ONE most correct answer) (a) A dot product test : (p q) (q r) = 0 (b) A cross product test : (p q) (q r) = 0 (c) A cross product test : (p q) (p r) = (p q) (p r) (where x is the magnitude of the vector x) (5) Given that perspective projection is closer to how our human visual system works (as well as cameras, etc), why would we ever consider using orthographic projection? (Circle or underline the ONE most correct answer) (a) The cost of rendering images using orthographic projection is substantially lower. (b) In the absence of perspective projection, all transforms can simply be described as 4 4 matrices. (c) Orthographic projection keeps lines that are parallel in the world, parallel on the screen. This can be useful for, say, engineering and architectural applications. (6) If the normals given for the three vertices of a triangle are exactly equal, would we see any difference if we did per-vertex lighting vs. per-fragment lighting in a Phong model? (Circle or underline the ONE most correct answer) (a) No. In this case all the interpolated normals inside the triangle would be equal to the constant normal of every vertex. Thus, lighting computations would produce exactly the same result. (b) Yes. Diffuse reflection would still produce different results in this case if done on a per-fragment basis (assume just a directional light). (c) Yes. Specular reflection could produce different results if done on a per-fragment basis. (7) Which of the following statements is true, about the matrix that can be used to transform normal vectors? (Circle or underline ALL correct answers) (a) It is equal to the top 3 3 block of the 4 4 matrix used to transform positions. (b) It is always a rotational matrix. (c) If positions are transformed as T(x) = Mx + b, the inversetranspose matrix (M 1 ) T is the one that will transform the normals. 2

2. [XX Y Y % = ZZ%] SHORT ANSWER SECTION. Answer each of the following questions in no more than 1-3 sentences. (a) Write a mathematical expression for a vector that is perpendicular (or normal) to the plane in 3D that passes through the three noncollinear points p, q, and r. (b) Name 2 reasons why hierarchical modeling is particularly convenient when creating models of articulated objects made from rigid parts (e.g. a robot that can move its limbs). (c) The three vertices of a triangle P 1 P 2 P 3 have the texture coordinates (u1, v1) = (0.2, 0.2), (u2, v2) = (0.2, 0.4), and (u3, v3) = (0.6, 0.2) associated with them. Let P be an interior point of the triangle, whose location is given by the following expression: P = 0.25 P 1 + 0.25 P 2 + 0.5 P 3 What would be the texture coordinates associated with P? 3

(d) The OpenGL Shading Language supports uniform variables, vertex attributes and varying variables. Give two (2) examples of vertex attributes (at least one vector-valued), one example of a uniform variable (of any type) and what purpose it serves, and one example of a varying variable with an explanation of why we would need it. (e) In local illumination models (e.g. the Phong model we discussed in class) shading of a given point on a visible surface object is computed independently of how any other surface has been shaded. Describe two examples of scenes or phenomena that a local illumination model would not be able to realistically reproduce. (f) When rasterizing a triangle (in modern graphics hardware) barycentric coordinates are computed for an entire rectangular region of pixels surrounding the triangle in question the barycentric coordinates are then checked to indentify if the triangle overlaps with any given pixel. Inevitably, computation will be spent for a number of pixels that will ultimately be determined to be outside the triangle. Why would this approach be followed (instead of scanline rasterization) even when there is the possibility of wasted computation? 4

3. [XX%] A camera is positioned as follows (relative to the 3D world coordinate system): The center of projection (the eye position) is at : e = (3, 2, 2). The lookat location is at: l = (2, 1, 1). The up vector is: t = (0, 1, 0). Compute the three basis vectors (u, v, w) of the camera coordinate system. 5

4. [XX%] There are several errors in the following vertex/fragment shader pair, that would prevent it from compiling. Identify as many as you can. Vertex shader: precision highp float; attribute vec3 position; attribute vec3 normal; attribute vec3 color; uniform mat3 normalmatrix; uniform mat4 modelviewmatrix; uniform mat4 projectionmatrix; varying vec3 fnormal; varying vec3 fcolor; void main(){ fnormal = normalize(normalmatrix * normal); vec4 pos = modelviewmatrix * position; fcolor = color; gl_position = (projectionmatrix * pos).xyz; } Fragment shader: precision highp float; varying vec3 fnormal; const vec3 ambientcolor = vec3(1.0,0.5,0.5); const vec3 lightdir = vec3(1.0,0.0,0.0); const float ambientfactor = 0.3; const float diffusefactor = 1; void main(){ vec3 s = normalize(lightdir); vec3 n = normalize(fnormal); vec3 ambient = ambientcolor*ambientfactor; vec3 diffuse = fcolor*diffusefactor*max(0.0,dot(n,s)); gl_fragcolor = ambient+diffuse; } 6

5. [XX%] Imagine that we have implemented a routine draw() that draws the shape outlined with a thick black line on the left of the following figure (i.e., the outline of one quadrant of a circle). X X x units 100 units y units y/2 units x/4 units 100 units Centered at (75,75) Y Y We want to use this basic shape to build the fan-shaped design on the right, consisting of four such quadrants that have been scaled, rotated and translated as shown. Describe the sequence of transforms that would be needed to form each of the 4 blades of this fan. You can either (a) Write down the individual transforms, as products of fundamental transforms (you can use notation similar to the HTML5 Canvas transform methods such as scale(0.5,2.0), rotate(pi/4) and so on, to describe individual fundamental transforms), or (b) by writing pseudo-code that will use the draw() routine along with Canvas save()/restore() calls and the fundamental transforms above, to draw the desired shape. Be mindful of the order of transformations!! [Note: The exact value of the x and y dimensions in the illustration above is not so important the main point is that the x has been scaled by a factor of 1/4, and y has been scaled to 1/2 of the original length] 7

6. [XX%] Write the code of a simple vertex/fragment shader pair to produce the following appearance effect: Objects to be drawn should get flattened along the z-axis, i.e. a vertex with coordinates (x, y, z) should be flattened into (x, y, 0). This should cause 3-D objects to appear as if they have been compressed down to the plane z = 0. [Hint: Do this in the vertex shader]. The rendered color of the object should be a greyscale value, proportional to the z-value of the material point (that is, the z value that it had before it was collapsed down to the plane z = 0). [Hint: Do this in the fragment shader, with some help from the vertex shader]. The illustration to the right shows an example of the effect we seek to reproduce (the left image is a standard shader applied to the same model). Feel free to assume that the vposition vertex attribute is available and provides the vertex position in local coordinates, along with (uniform) matrix variables modelviewmatrix, projectionmatrix etc. Alternatively, feel free to define your own variables for any information you need to pass down to the shaders. 8