GPU Programming EE Midterm Examination

Similar documents
GPU Programming EE Midterm Examination

GPU Programming EE Final Examination

EE 4702 GPU Programming

Name. EE 4702 Final Exam. Friday, 7 December 2012, 12:30-14:30 CST. Exam Total. Alias. (100 pts) Good Luck!

GPU Programming EE Final Examination

GPU Programming EE Midterm Examination

GPU Programming EE Final Examination

GPU Programming EE Practice Midterm Examination

GPU Programming EE Final Examination

GPU Programming EE Final Examination

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

LSU EE Homework 5 Solution Due: 27 November 2017

Homework #2 and #3 Due Friday, October 12 th and Friday, October 19 th

Models and Architectures

CS559 Computer Graphics Fall 2015

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

Programmable Graphics Hardware

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

12.2 Programmable Graphics Hardware

OpenGL Programmable Shaders

Introduction to Computer Graphics with WebGL

CS 130 Final. Fall 2015

Introduction to the OpenGL Shading Language (GLSL)

Supplement to Lecture 22

CS 130 Exam I. Fall 2015

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

Shader Programming 1. Examples. Vertex displacement mapping. Daniel Wesslén 1. Post-processing, animated procedural textures

CS 498 VR. Lecture 19-4/9/18. go.illinois.edu/vrlect19

Shaders. Slide credit to Prof. Zwicker

Recall: Indexing into Cube Map

GPGPU: Parallel Reduction and Scan

Shader Programming. Daniel Wesslén, Stefan Seipel, Examples

Rasterization Overview

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

Programmable GPUs. Real Time Graphics 11/13/2013. Nalu 2004 (NVIDIA Corporation) GeForce 6. Virtua Fighter 1995 (SEGA Corporation) NV1

CS 130 Exam I. Fall 2015

Computer Graphics Coursework 1

Programmable GPUs Outline

OpenGL Rendering Pipeline and Programmable Shaders

The Graphics Pipeline and OpenGL III: OpenGL Shading Language (GLSL 1.10)!

CS GPU and GPGPU Programming Lecture 11: GPU Texturing 1. Markus Hadwiger, KAUST

Shaders. Introduction. OpenGL Grows via Extensions. OpenGL Extensions. OpenGL 2.0 Added Shaders. Shaders Enable Many New Effects

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

Lecture 17: Shading in OpenGL. CITS3003 Graphics & Animation

Advanced Lighting Techniques Due: Monday November 2 at 10pm

Programming Graphics Hardware

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

2.11 Particle Systems

General Purpose Computation (CAD/CAM/CAE) on the GPU (a.k.a. Topics in Manufacturing)

Introduction to Shaders.

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

Introduction to Shaders for Visualization. The Basic Computer Graphics Pipeline

SHADER PROGRAMMING. Based on Jian Huang s lecture on Shader Programming

The Basic Computer Graphics Pipeline, OpenGL-style. Introduction to the OpenGL Shading Language (GLSL)

The Application Stage. The Game Loop, Resource Management and Renderer Design

Cloth Simulation on the GPU. Cyril Zeller NVIDIA Corporation

Accelerating the Hyperbolic Display of Complex 2D Scenes Using the GPU

Deferred Rendering Due: Wednesday November 15 at 10pm

OUTLINE. Learn the basic design of a graphics system Introduce pipeline architecture Examine software components for a graphics system

CS GPU and GPGPU Programming Lecture 2: Introduction; GPU Architecture 1. Markus Hadwiger, KAUST

3 Meshes. Strips, Fans, Indexed Face Sets. Display Lists, Vertex Buffer Objects, Vertex Cache

Transformation Pipeline

Graphics Processing Unit Architecture (GPU Arch)

Pipeline Operations. CS 4620 Lecture 14

TDA361/DIT220 Computer Graphics, January 15 th 2016

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

Graphics Hardware and OpenGL

Graphics Programming

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

Practical Texturing (WebGL) CS559 Fall 2016 Lecture 20 November 7th 2016


Evolution of GPUs Chris Seitz

CS 4620 Midterm, October 23, 2018 SOLUTION

INF3320 Computer Graphics and Discrete Geometry

The Graphics Pipeline

Introduction to OpenGL

Sign up for crits! Announcments

The Transition from RenderMan to the OpenGL Shading Language (GLSL)

CS GPU and GPGPU Programming Lecture 12: GPU Texturing 1. Markus Hadwiger, KAUST

Lecture 4: Geometry Processing. Kayvon Fatahalian CMU : Graphics and Imaging Architectures (Fall 2011)

OpenGL. White Square Code 11/4/09. OpenGL. OpenGL. OpenGL

Blis: Better Language for Image Stuff Project Proposal Programming Languages and Translators, Spring 2017

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

LSU EE Homework 3 Solution Due: 16 November 2012

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

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

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

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

OpenGL shaders and programming models that provide object persistence

Texture Mapping. CS 537 Interactive Computer Graphics Prof. David E. Breen Department of Computer Science

Fog example. Fog is atmospheric effect. Better realism, helps determine distances

Rendering Objects. Need to transform all geometry then

Exercise Max. Points Total 90

Programming with OpenGL Shaders I. Adapted From: Ed Angel Professor of Emeritus of Computer Science University of New Mexico

The Graphics Pipeline

CS 432 Interactive Computer Graphics

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

Computer Graphics with OpenGL ES (J. Han) Chapter VII Rasterizer

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

To Do. Computer Graphics (Fall 2008) Course Outline. Course Outline. Methodology for Lecture. Demo: Surreal (HW 3)

Transcription:

Name GPU Programming EE 4702- Midterm Examination Wednesday, 2 November 204 9:30 0:20 CST Alias Problem Problem 2 Problem 3 Problem 4 Problem 5 Problem 6 Exam Total (8 pts) (2 pts) (24 pts) (2 pts) (4 pts) (20 pts) (00 pts) Good Luck!

Problem : [8 pts] Appearing below is a simplified version of the vertex shader vs_main from Homework 4. One way to reduce the amount of computation it must perform is by pre-computing values and making them available as vs_main inputs. For example, rather than compute radial_idx each time, it can instead be pre-computed and stored in the w component of gl_vertex or it can be stored in a user-defined vertex shader input named radial_idx. void vs_main() { int bidx = gl_vertex.x; int ti = gl_vertex.y; int radial_idx = bidx * opt_segments + ti; float theta = (.0/opt_segments) * radial_idx * omega; vec3 pos = balls_pos[bidx-].xyz; vec3 pos2 = balls_pos[bidx].xyz; vec3 v2 = pos2.xyz - pos.xyz; vec3 p = pos + float(ti) / opt_segments * v2; vec3 va = spiral_radius * normalize( vec3(0,v2.z,-v2.y) ); vec3 vb = spiral_radius * normalize( cross(v2,va) ); vec3 radial = va * cos(theta) + vb * sin(theta); vec3 p_outer = p + radial; vec3 p_inner = p + 0.5 * radial; Consider two candidates for new vertex shader inputs: va/vb (count these as one candidate) and theta. (a) Estimate the amount by which each candidate would reduce the amount of computation to be performed by the vertex shader. Computation reduction by making va/vb an input: Computation reduction by making theta an input: (b) One of the candidates would result in a large increase in CPU to GPU data transfer. Which one is it, and why? Candidate causing a big increase in CPU to GPU data transfer: Reason for big increase: (c) In the code above there is a much better candidate for a new vertex shader input other than va/vb or theta. It would reduce computation by a significant amount and would not have a big impact on data transfer. Hint: it s not a variable, but an expression, or several expressions. The much better candidate for an input attribute is: 2

Problem 2: [2 pts] Appearing below is the fragment shader from the solution to Homework 4. Recall that this shader does not render the spiral surface in places where the texture is dark, giving the appearance of holes. (a) Modify the shader code so that the texture itself is only applied to the front side of the spiral, and so that the holes still appear on both sides. Hint: Can be done with a line or two of code. Modify so holes are on both sides, but texture just on front. void fs_main() { vec4 color = is_edge? gl_frontmaterial.ambient : gl_frontfacing? gl_frontmaterial.diffuse : gl_backmaterial.diffuse; vec4 texel = is_edge? vec4(,,,) : texture(tex_unit_0,gl_texcoord[0].xy); bool hole = texel.r + texel.g + texel.b < 0.05; if ( hole ) discard; gl_color = texel * generic_lighting(vertex_e, color, normalize(normal_e)); } gl_depth = gl_coord.z; (b) The fragment shader code below, based on Homework 4, is supposed to use different colors for the front, back, and edge of the spiral. The code below has an error and the commented-out line shows the correct code. How will this error change the appearance of the spiral? With this error spiral will appear... void fs_main() { vec4 our_color = is_edge? gl_frontmaterial.ambient : gl_frontfacing? gl_frontmaterial.diffuse : gl_backmaterial.diffuse; vec4 texel = is_edge? vec4(,,,) : texture(tex_unit_0,gl_texcoord[0].xy); bool hole = texel.r + texel.g + texel.b < 0.05; if ( hole ) discard; // gl_color = texel * generic_lighting(vertex_e, our_color, normalize(normal_e)); gl_color = texel * our_color; } gl_depth = gl_coord.z; 3

Problem 3: [24 pts] Answer each question below. (a) An object at point P is moving at velocity v just before collision with a wall with normal ŵ. The collision is completely elastic, meaning the object s speed (the magnitude of velocity) will not change. Write an expression for the velocity after the collision? Expression showing velocity after collision: (b) An object at P is connected to an object at P 2 by an ideal spring having a relaxed distance of d and a spring constant h. Write an expression for the force on P due to this spring. Expression giving force on P due to spring: (c) Point P in 3D space has homogeneous coordinate (3, 4, 6, 0.5). What is the corresponding Cartesian (ordinary every day) coordinate? Cartesian coordinate is: (d) Homogeneous coordinates make it possible to express certain transformations using matrix multiplication that would not be possible with ordinary Cartesian coordinates. Name one such transformation. Transformation that s not possible using matrix multiplication with Cartesian coordinates: 4

Problem 4: [2 pts] Answer each question below. (a) Our user s eye is at location (x, y, z) in our coordinate system. How do we provide this information to OpenGL (using the compatibility profile)? Be specific. User s location given to OpenGL by... (b) The series of transformations performed by OpenGL (and shaders) maps 3D coordinates in our coordinate space to window space which are the 2D window coordinates corresponding to pixel locations. This transformation preserves coordinates z component. Why is the z component needed, and how is it used? The z component is used for... 5

Problem 5: [4 pts] The diagram below shows a simplified form of the OpenGL rendering pipeline. Vtx v Vertex Shader Vtx v Tri v Geometry Shader >= 0 Tri v v Tri v Rasterizer >> f ment Shader 0 or f f Frame Buffer Update (a) The diagram shows 6 f s at the output of the rasterizer stage, but that s not necessarily the actual number. What does the actual number of f s depend on? How could one increase the number of f s without changing the input, (V V 2 V 3 ). (b) The boxes with rounded corners are part of what s called the fixed functionality. What does that mean, and why are those stages part of it. Fixed functionality means... The Rasterizer and Frame Buffer Update are fixed functionality because... 6

Problem 6: [20 pts] Answer each question below. (a) The code below specifies vertices using a triangle strip. Modify the code so that it renders the same triangles using individual triangles. Modify code to use individual triangles without changing what s rendered. glbegin(gl_triangle_strip); for ( int i=0 ; i<num_v ; i++ ) { glvertex3fv( coord[i] ); } glend(); (b) There is an important difference between specifying a color using glcolor and glmaterial. One of them allows each vertex to have its own color, the other allows different properties to be set, such as ambient, diffuse, and specular but all vertices in a rendering pass must share these colors. Note: This question applies only to the compatibility profile. The command that allows each vertex to have its own color is: Why can t each vertex have its own set of color properties using either of these commands? (c) Describe how the GL_LINEAR_MIPMAP_LINEAR minification method computes a filtered texel. Indicate how many texels are read from texture images, which images are read, and how they are combined. Number of texture images read: Number of texels read: How they are combined: 7