Hank Childs, University of Oregon

Slides:



Advertisements
Similar presentations
Computer Graphics- SCC 342
Advertisements

CS 450: COMPUTER GRAPHICS FILLING POLYGONS SPRING 2015 DR. MICHAEL J. REALE.
Ray tracing. New Concepts The recursive ray tracing algorithm Generating eye rays Non Real-time rendering.
Hank Childs, University of Oregon Oct. 22 nd, 2014 CIS 441/541: Introduction to Computer Graphics Lecture 7: Arbitrary Camera Positions.
3D Graphics Rendering and Terrain Modeling
Hank Childs, University of Oregon November 15 th, 2013 Volume Rendering, Part 2.
X86 and 3D graphics. Quick Intro to 3D Graphics Glossary: –Vertex – point in 3D space –Triangle – 3 connected vertices –Object – list of triangles that.
Cornell CS465 Fall 2004 Lecture 3© 2004 Steve Marschner 1 Ray Tracing CS 465 Lecture 3.
Computer Graphics Inf4/MSc Computer Graphics Lecture 9 Antialiasing, Texture Mapping.
CS 445 / 645 Introduction to Computer Graphics Lecture 18 Shading Shading.
Basics of Rendering Pipeline Based Rendering –Objects in the scene are rendered in a sequence of steps that form the Rendering Pipeline. Ray-Tracing –A.
COMP 175: Computer Graphics March 24, 2015
1/1/20001 Topic >>>> Scan Conversion CSE Computer Graphics.
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
COMP 261 Lecture 16 3D Rendering. input: set of polygons viewing direction direction of light source(s) size of window. output: an image Actions rotate.
Hank Childs, University of Oregon October 3, 2014 CIS 441/541: Intro to Computer Graphics Lecture 2: The Scanline Algorithm.
CS-378: Game Technology Lecture #4: Texture and Other Maps Prof. Okan Arikan University of Texas, Austin V Lecture #4: Texture and Other Maps.
Advanced Computer Graphics Advanced Shaders CO2409 Computer Graphics Week 16.
Hank Childs, University of Oregon Oct. 10, 2014 CIS 441/541: Introduction to Computer Graphics Lecture 4: Interpolating Colors and the Z-buffer.
Hank Childs, University of Oregon Lecture #6 CIS 410/510: Advection (Part 1)
Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive.
Computer Graphics Basic 3D Geometry CO2409 Computer Graphics Week 5-1.
Hank Childs, University of Oregon Lecture #4 Fields, Meshes, and Interpolation (Part 3)
Hank Childs, University of Oregon Lecture #3 Fields, Meshes, and Interpolation (Part 2)
Computer Graphics Rendering 2D Geometry CO2409 Computer Graphics Week 2.
CS 325 Introduction to Computer Graphics 03 / 29 / 2010 Instructor: Michael Eckmann.
Hank Childs, University of Oregon Lecture #10 CIS 410/510: Isosurfacing.
CS 445 / 645 Introduction to Computer Graphics Lecture 15 Shading Shading.
10/15/02 (c) 2002 University of Wisconsin, CS559 Who Am I? Prof Stephen Chenney These notes will be online after the lecture – in fact they’re online already.
Hank Childs, University of Oregon Lecture #2 Fields, Meshes, and Interpolation (Part 1)
Hank Childs, University of Oregon Isosurfacing (Part 3)
Hank Childs, University of Oregon Unstructured Grids.
Hank Childs, University of Oregon Volume Rendering, pt 1.
Local Illumination and Shading
Introduction to Meshes Lecture 22 Mon, Oct 20, 2003.
2 3D Viewing Process  3D viewing process MC Model Space Model Transformation Model Transformation WC World Space Viewing Transformation Viewing Transformation.
Computer Graphics (Fall 2006) COMS 4160, Lecture 16: Illumination and Shading 1
Hank Childs, University of Oregon Oct. 28th, 2016 CIS 441/541: Introduction to Computer Graphics Lecture 16: textures.
Model Optimization Wed Nov 16th 2016 Garrett Morrison.
Hank Childs, University of Oregon
Rendering Pipeline Fall, 2015.
Hank Childs, University of Oregon
Photorealistic Rendering vs. Interactive 3D Graphics
Week 2 - Friday CS361.
CIS 410/510: Isosurfacing (pt 2)
(c) 2002 University of Wisconsin, CS559
Hank Childs, University of Oregon
CSCE 441 Computer Graphics 3-D Viewing
3D Transformations Source & Courtesy: University of Wisconsin,
Modeling 101 For the moment assume that all geometry consists of points, lines and faces Line: A segment between two endpoints Face: A planar area bounded.
3D Graphics Rendering PPT By Ricardo Veguilla.
Hank Childs, University of Oregon
The Graphics Rendering Pipeline
CS451Real-time Rendering Pipeline
Chapter 14 Shading Models.
Common Classification Tasks
Hank Childs, University of Oregon
Hank Childs, University of Oregon
Rasterizing Lines 1 Lecture 32 Mon, Nov 12, 2007.
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
Computer Graphics One of the central components of three-dimensional graphics has been a basic system that renders objects represented by a set of polygons.
Chapter V Vertex Processing
Lecture 13 Clipping & Scan Conversion
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
Introduction to Meshes
CS5500 Computer Graphics May 29, 2006
CS-378: Game Technology Lecture #4: Texture and Other Maps
Chapter 14 Shading Models.
CIS 441/541: Introduction to Computer Graphics Lecture 15: shaders
Introduction to Meshes
Presentation transcript:

Hank Childs, University of Oregon CIS 441/541: Intro to Computer Graphics Lecture 4: Interpolation October 3, 2016 Hank Childs, University of Oregon

Announcements

Trying to Add the Class? Let’s talk after class…

Canvas is Operational Are you getting emails? Submit 1A to Canvas…

Questions About Final Projects

Windows vs Mac vs Linux

VTK 6 vs VTK 7…

Review

What Are We Rendering? Models made up of polygons Usually triangles Lighting tricks make surfaces look non-faceted More on this later…

Reminder: ray-tracing vs rasterization Two basic ideas for rendering: rasterization and ray-tracing Ray-tracing: cast a ray for every pixel and see what geometry it intersects. O(nPixels) (actually, additional computational complexity for geometry searches) Allows for beautiful rendering effects (reflections, etc) Will discuss at the end of the quarter

Reminder: ray-tracing vs rasterization Two basic ideas for rendering: rasterization and ray-tracing Rasterization: examine every triangle and see what pixels it covers. O(nTriangles) (actually, additional computational complexity for painting in pixels) GPUs do rasterization very quickly Our focus for the next 5 weeks

What color should we choose for each of these four pixels?

What color should we choose for each of these four pixels? Most dominant triangle

What color should we choose for each of these four pixels? Average

What color should we choose for each of these four pixels? Pixel center

What color should we choose for each of these four pixels? Lower left of pixel

We will use the lower-left convention for the projects. The middle and lower-left variants are half-pixel translations of the other Pixel center We will use the lower-left convention for the projects. Lower left of pixel

Where we are… We haven’t talked about how to get triangles in position. Arbitrary camera positions through linear algebra We haven’t talked about shading On Wednesday, we tackled this problem: How to deposit triangle colors onto an image?

Problem: how to deposit triangle colors onto an image? Let’s take an example: 12x12 image Red triangle Vertex 1: (2.5, 1.5) Vertex 2: (2.5, 10.5) Vertex 3: (10.5, 1.5) Vertex coordinates are with respect to pixel locations

(0,12) (12,12) (2.5,10.5) (2.5,1.5) (10.8,1.5) (0,0) (12,0)

How do we make this output? Efficiently? Our desired output How do we make this output? Efficiently?

Don’t need to consider any Pixels outside these lines

Scanline algorithm: consider all rows that can possibly overlap Don’t need to consider any Pixels outside these lines

Scanline algorithm: consider all rows that can possibly overlap We will extract a “scanline”, i.e. calculate the intersections for one row of pixels Don’t need to consider any Pixels outside these lines X X X X X Y=5

Red triangle Vertex 1: (2.5, 1.5) Vertex 2: (2.5, 10.5)

Red triangle Vertex 1: (2.5, 1.5) Vertex 2: (2.5, 10.5) Y=5

Red triangle Vertex 1: (2.5, 1.5) Vertex 2: (2.5, 10.5) Y=5 What are the end points?

Red triangle Vertex 1: (2.5, 1.5) Vertex 2: (2.5, 10.5) Y=5 (2.5, 5) What are the end points?

Red triangle Vertex 1: (2.5, 1.5) Vertex 2: (2.5, 10.5) Algebra! Y=5 (2.5, 5) What are the end points?

Red triangle Y = mx+b 10.5=m*2.5+b 1.5 = m*10.5+b  9 = -8m m = -1.125 Vertex 1: (2.5, 1.5) Vertex 2: (2.5, 10.5) Vertex 3: (10.5, 1.5) Y = mx+b 10.5=m*2.5+b 1.5 = m*10.5+b  9 = -8m m = -1.125 b = 13.3125 5 = -1.125*x + 13.3125 x = 7.3888 Algebra! Y=5 (2.5, 5) What are the end points?

Scanline algorithm: consider all rows that can possibly overlap Don’t need to consider any Pixels outside these lines 2.5 7.3888 X X X X X Y=5

Scanline algorithm: consider all rows that can possibly overlap Don’t need to consider any Pixels outside these lines 2.5 7.3888 X X X X X Y=5 Color is deposited at (3,5), (4,5), (5,5), (6,5), (7,5)

Scanline algorithm Determine rows of pixels triangles can possibly intersect Call them rowMin to rowMax rowMin: ceiling of smallest Y value rowMax: floor of biggest Y value For r in [rowMin  rowMax] ; do Find end points of r intersected with triangle Call them leftEnd and rightEnd For c in [ceiling(leftEnd)  floor(rightEnd) ] ; do ImageColor(r, c)  triangle color

Scanline algorithm Determine rows of pixels triangles can possibly intersect For r in [rowMin  rowMax] ; do Find end points of r intersected with triangle Call them leftEnd and rightEnd For c in [ceiling(leftEnd)  floor(rightEnd) ] ; do ImageColor(r, c)  triangle color Y values from 1.5 to 10.5 mean rows 2 through 10 For r = 5, leftEnd = 2.5, rightEnd = 7.3888 For r = 5, we call ImageColor with (5,3), (5,4), (5,5), (5,6), (5,7)

Arbitrary Triangles The description of the scanline algorithm in the preceding slides is general. But the implementation for these three triangles vary:

Supersamping: use the scanline algorithm a bunch of times to converge on the “average” picture.

Project #1B Goal: apply the scanline algorithm to “flat bottom” triangles and output an image. File “project1B.cxx” has triangles defined in it. Due: Weds, Oct. 5th % of grade: 6%

Project 1B Cout/cerr can be misleading:

Project 1B The limited accuracy of cerr/cout can cause other functions to be appear to be wrong:

Project 1B Floating point precision is an approximation of the problem you are trying to solve Tiny errors are introduced in nearly every operation you perform Exceptions for integers and denominators that are a power of two Fundamental problem: Changing the sequence of these operations leads to *different* errors. Example: (A+B)+C ≠ A+(B+C)

Project 1B For project 1B, we are making a binary decision for each pixel: should it be colored or not? Consider when a triangle vertex coincides with the bottom left of a pixel: We all do different variations on how to solve for the endpoints of a line, so we all get slightly different errors.

Project 1B Our algorithm incorporates floor and ceiling functions. This is the right place to bypass the precision problem. I have included “floor441” and “ceil441” in project prompt. You need to use them, or you will get one pixel differences.

Project 1B: other thoughts You will be building on this project … think about magic numbers (e.g. screen size of 1000) add safeguards against cases that haven’t shown up yet Assume nothing!

Where we are… We haven’t talked about how to get triangles into position. Arbitrary camera positions through linear algebra We haven’t talked about shading On Friday, we tackled this problem: How to deposit triangle colors onto an image? Still don’t know how to: Vary colors (easy) Deal with triangles that overlap Today’s lecture will go over the key operation to do these two. Friday’s lecture will tell us how to do it.

What is a field? Example field (2D): temperature over the United States

How much data is needed to make this picture? Example field (2D): temperature over the United States

Linear Interpolation for Scalar Field F F(A) F(X) F(B) A X B

Linear Interpolation for Scalar Field F General equation to interpolate: F(X) = F(A) + t*(F(B)-F(A)) t is proportion of X between A and B t = (X-A)/(B-A) F(A) F(X) F(B) A X B

Quiz Time #4 = 5 + (4-3)/(6-3)*(11-5) = 7 F(3) = 5, F(6) = 11 What is F(4)? = 5 + (4-3)/(6-3)*(11-5) = 7 General equation to interpolate: F(X) = F(A) + t*(F(B)-F(A)) t is proportion of X between A and B t = (X-A)/(B-A)

Consider a single scalar field defined on a triangle. Y-axis Y=1 Y=0.5 X-axis Y=0 X=0 X=0.5 X=1 X=1.5 X=2

Consider a single scalar field defined on a triangle. Y-axis V2 Y=1 F(V2) = 2 Y=0.5 V1 V3 F(V1) = 10 F(V3) = -2 X-axis Y=0 X=0 X=0.5 X=1 X=1.5 X=2

What is F(V4)? Y-axis V2 Y=1 F(V2) = 2 Y=0.5 V4, at (0.5, 0.25) V1 V3 X-axis Y=0 X=0 X=0.5 X=1 X=1.5 X=2

What is F(V4)? Y-axis V2 Y=1 F(V2) = 2 Y=0.5 V5 V6 V4, at (0.5, 0.25) X-axis Y=0 X=0 X=0.5 X=1 X=1.5 X=2

Steps to follow: Calculate V5, the left intercept for Y=0.25 Calculate V6, the right intercept for Y=0.25 Calculate V4, which is between V5 and V6

What is the X-location of V5? Y-axis V2 Y=1 F(V2) = 2 F(v1) = A  F(0) = 0 F(v2) = B  F(1) = 1 F(v) = A + ((v-v1)/(v2-v1))*(B-A): F(v) = 0.25, find v 0.25 = 0 + ((v-0)/(1-0)*(1-0) v = 0.25 Y=0.5 V5 V6 V4, at (0.5, 0.25) V1 V3 F(V1) = 10 F(V3) = -2 X-axis Y=0 X=0 X=0.5 X=1 X=1.5 X=2

What is the F-value of V5? Y-axis V2 Y=1 F(V2) = 2 F(v1) = A  F(0) = 10 F(v2) = B  F(1) = 2 F(v) = A + ((v-v1)/(v2-v1))*(B-A): v = 0.25, find F(v) F(v) = 10 + ((0.25-0)/(1-0))*(2-10) = 10 + 0.25*-8 = 10 -2 = 8 Y=0.5 V5 V6 V4, at (0.5, 0.25) V1 V3 F(V1) = 10 F(V3) = -2 X-axis Y=0 X=0 X=0.5 X=1 X=1.5 X=2

What is the X-location of V6? Y-axis V2 Y=1 F(V2) = 2 F(v1) = A  F(1) = 1 F(v2) = B  F(2) = 0 F(v) = A + ((v-v1)/(v2-v1))*(B-A): F(v) = 0.25, find v 0.25 = 1 + ((v-1)/(2-1)*(0-1) = 1 + (v-1)*(-1) 0.25 = 2 - v v = 1.75 Y=0.5 V5 V6 V4, at (0.5, 0.25) V1 V3 F(V1) = 10 F(V3) = -2 X-axis Y=0 X=0 X=0.5 X=1 X=1.5 X=2

What is the F-value of V6? Y-axis V2 Y=1 F(V2) = 2 F(v1) = A  F(1) = 2 F(v2) = B  F(2) = -2 F(v) = A + ((v-v1)/(v2-v1))*(B-A): v = 1.75, find F(v) F(v) = 2 + ((1.75-1)/(2-1)*(-2 - +2) = 2 + (.75)*(-4) = 2 - 3 = -1 Y=0.5 V5 V6 V4, at (0.5, 0.25) V1 V3 F(V1) = 10 F(V3) = -2 X-axis Y=0 X=0 X=0.5 X=1 X=1.5 X=2

What is the F-value of V5? Y-axis V2 Y=1 L(V6) = (1.75, 0.25) V4, at (0.5, 0.25) V1 V3 F(V1) = 10 F(V3) = -2 X-axis Y=0 X=0 X=0.5 X=1 X=1.5 X=2

What is the F-value of V5? F(v1) = A  F(0.25) = 8 F(v2) = B  F(1.75) = -1 F(v) = A + ((v-v1)/(v2-v1))*(B-A): v = 0.5, find F(v) F(v) = 8 + ((0.5-0.25)/(1.75-0.25))*(-1-8) = 8 + (0.25/1.5)*9 = 8-1.5 = 6.5 Y-axis V2 Y=1 L(V6) = (1.75, 0.25) F(V6) = -1 Y=0.5 L(V5) = (0.25, 0.25) F(V5) = 8 V5 V6 V4, at (0.5, 0.25) V1 V3 F(V1) = 10 F(V3) = -2 X-axis Y=0 X=0 X=0.5 X=1 X=1.5 X=2

How do you think this picture was made? Visualization of F F=10 F=-2 Not defined How do you think this picture was made?

Outline Project 1B Scanline review Interpolation along a triangle Project 1C

How do we handle arbitrary triangles? The description of the scanline algorithm from Lecture 2 is general. But the implementation for these three triangles vary:

How do we handle arbitrary triangles? The description of the scanline algorithm from Lecture 2 is general. But the implementation for these three triangles vary: Solve for location of this point and then solve two “base cases”.

Arbitrary Triangles Project #1B: implement the scanline algorithm for triangles with “flat bottoms” Project #1C: arbitrary triangles

Project #1C (3%), Due (soon) Goal: apply the scanline algorithm to arbitrary triangles and output an image. Extend your project1B code File proj1c_geometry.vtk available on web (80MB) File “reader.cxx” has code to read triangles from file. No Cmake, project1c.cxx