+ All Categories
Home > Documents > Overview: Ray Tracing & The Perspective Projection Pipelinecs410/yr2014fa/more_progress/L02... ·...

Overview: Ray Tracing & The Perspective Projection Pipelinecs410/yr2014fa/more_progress/L02... ·...

Date post: 26-Sep-2020
Category:
Upload: others
View: 1 times
Download: 0 times
Share this document with a friend
15
Overview: Ray Tracing & The Perspective Projection Pipeline Lecture #2 Thursday, August 28 2014 About this Lecture ! This is an overview. ! Think of it as a quick tour moving fast. ! Some parts, e.g. math, go by quickly. ! We will come back and spend more time. ! Why a quick tour ? ! Context is key and comes first! 8/28/14 © Ross Beveridge & Bruce A. Draper, 2014 2
Transcript
Page 1: Overview: Ray Tracing & The Perspective Projection Pipelinecs410/yr2014fa/more_progress/L02... · 28/08/2014  · Two Approaches to Graphics ! Common starting point: ! Create a scene

Overview: Ray Tracing & The Perspective Projection Pipeline

Lecture #2 Thursday, August 28 2014

About this Lecture

!  This is an overview.

!  Think of it as a quick tour moving fast. !  Some parts, e.g. math, go by quickly.

!  We will come back and spend more time.

!  Why a quick tour ?

!  Context is key and comes first!

8/28/14 © Ross Beveridge & Bruce A. Draper, 2014 2

Page 2: Overview: Ray Tracing & The Perspective Projection Pipelinecs410/yr2014fa/more_progress/L02... · 28/08/2014  · Two Approaches to Graphics ! Common starting point: ! Create a scene

Two Approaches to Graphics

!  Common starting point: ! Create a scene model in world coordinates. !  Place a synthetic camera in the scene. !  Typically made by combining local models.

!  Approach #1: Projective Pipeline

! Move model into camera coordinates. !  Project vertices onto the image plane. !  Fill in other pixels (fragment processing).

8/28/14 © Ross Beveridge & Bruce A. Draper, 2014 3

Approaches (II)

!  Approach #2: Ray Tracing ! Rays project from pixels into the world model. ! Rays intersect objects. !  Pass back appearance (illumination) to pixels.

!  More commonalities ! Calculate pixel values for images. !  Still have to map image onto screen/printer/etc.

! Sometimes called the “Workstation Transform”

8/28/14 © Ross Beveridge & Bruce A. Draper, 2014 4

Page 3: Overview: Ray Tracing & The Perspective Projection Pipelinecs410/yr2014fa/more_progress/L02... · 28/08/2014  · Two Approaches to Graphics ! Common starting point: ! Create a scene

The Projection Pipeline (in more detail, with cartoons)

Step #0: The starting point We start with a set of 3D object models. Most models are polygonal. Every model has its own coordinate frame.

Step #1: The model transform Puts every object into a single global coordinate system (frame). e.g. place the teapot on the TV set.

8/28/14 © Ross Beveridge & Bruce A. Draper, 2014 5

The Projection Pipeline (II)

Step #2: The Viewing Transform Converts data from the 3D world coordinate system to a camera-centered (and camera-oriented) 3D coordinate system

Note: at this point projection pipeline and ray tracing may start diverging.

8/28/14 © Ross Beveridge & Bruce A. Draper, 2014 6

Page 4: Overview: Ray Tracing & The Perspective Projection Pipelinecs410/yr2014fa/more_progress/L02... · 28/08/2014  · Two Approaches to Graphics ! Common starting point: ! Create a scene

The Projection Pipeline (III)

Field of View

Step #3: Clipping The step eliminates all vertices (data points) falling outside the field of view of your synthetic camera

8/28/14 © Ross Beveridge & Bruce A. Draper, 2014 7

The Projection Pipeline (IV)

Step #4: Projection This step projects 3D data points onto a 2D image plane, according to the camera parameters (e.g. focal length)

8/28/14 © Ross Beveridge & Bruce A. Draper, 2014 8

Page 5: Overview: Ray Tracing & The Perspective Projection Pipelinecs410/yr2014fa/more_progress/L02... · 28/08/2014  · Two Approaches to Graphics ! Common starting point: ! Create a scene

The Perspective Pipeline (V)

Step #5: Rasterization Play “connect the dots” (well, vertices) to form line segments and closed polygons (collectively, fragments)

8/28/14 © Ross Beveridge & Bruce A. Draper, 2014 9

The Perspective Pipeline (VI)

Step #6: Fragment Processing This is where surfaces are shaded and hidden surfaces are removed.

8/28/14 © Ross Beveridge & Bruce A. Draper, 2014 10

Page 6: Overview: Ray Tracing & The Perspective Projection Pipelinecs410/yr2014fa/more_progress/L02... · 28/08/2014  · Two Approaches to Graphics ! Common starting point: ! Create a scene

The Projection Pipeline (VII)

Step #7: Workstation Transform Moves the data from the 2D image plane coordinate system to the 2D coordinate system of your display device

Note: this is where the projective pipeline and ray tracing come back together.

8/28/14 © Ross Beveridge & Bruce A. Draper, 2014 11

Ray Tracing (the alternative)

Step #0: The starting point We start with a set of 3D object models. Most models are polygonal. Every model has its own coordinate frame.

Step #1: The model transform Puts every object into a single global coordinate system (frame). e.g. place the teapot on the TV set

8/28/14 © Ross Beveridge & Bruce A. Draper, 2014 12

Page 7: Overview: Ray Tracing & The Perspective Projection Pipelinecs410/yr2014fa/more_progress/L02... · 28/08/2014  · Two Approaches to Graphics ! Common starting point: ! Create a scene

Ray Tracing (II)

Step #2: 3D Camera model The image plane (representing film or a CCD/CMOS chip) is a plane located in the 3D world model.

This step calculates the 3D position of every pixel on that plane.

8/28/14 © Ross Beveridge & Bruce A. Draper, 2014 13

Ray Tracing (III)

Step #3: Ray Casting Send a ray through every pixel, intersect rays with objects in the world model.

8/28/14 © Ross Beveridge & Bruce A. Draper, 2014 14

Page 8: Overview: Ray Tracing & The Perspective Projection Pipelinecs410/yr2014fa/more_progress/L02... · 28/08/2014  · Two Approaches to Graphics ! Common starting point: ! Create a scene

Ray Tracing (IV)

Step #4: Diffuse Reflection Calculate rays from surface intersection points to light sources; calculate diffuse reflection and shadows.

Source: http://morawietz.me/

8/28/14 © Ross Beveridge & Bruce A. Draper, 2014 15

Ray Tracing (V)

Step #5: Specular & Translucent Reflections Calculate rays in the direction of specular and translucent reflections; recursively calculate appearance

L R N

θ

S S

θ

V C

Q

8/28/14 © Ross Beveridge & Bruce A. Draper, 2014 16

Page 9: Overview: Ray Tracing & The Perspective Projection Pipelinecs410/yr2014fa/more_progress/L02... · 28/08/2014  · Two Approaches to Graphics ! Common starting point: ! Create a scene

Ray Tracing (VI)

Step #6: Sum reflections, store in pixel Add together diffuse, specular and translucent reflections, store resulting (R,G,B) value in pixel

I = KIl N ⋅Ll( )+ kIl 2N N ⋅L( )− L( ) ⋅V( )n( )

l∑

Relax, we will come back to this properly later.

8/28/14 © Ross Beveridge & Bruce A. Draper, 2014 17

Ray Tracing (VII)

Step #7: Workstation Transform Moves the data from the 2D image plane coordinate system to the 2D coordinate system of your display device

Note: at this last step is where the projective pipeline and ray tracing approaches converge

8/28/14 © Ross Beveridge & Bruce A. Draper, 2014 18

Page 10: Overview: Ray Tracing & The Perspective Projection Pipelinecs410/yr2014fa/more_progress/L02... · 28/08/2014  · Two Approaches to Graphics ! Common starting point: ! Create a scene

Projection Pipeline vs Ray Tracing

!  Projection Pipeline: !  Fast (currently real-time) ! Current standard (e.g. video games) !  SOA: OpenGL 3.0

!  Ray Tracing: ! More realistic (e.g. inter-reflections) ! Getting faster (e.g. Pov-Ray) !  Future hardware will make it real-time

8/28/14 © Ross Beveridge & Bruce A. Draper, 2014 19

Recent Tour-de-Force

8/28/14 © Ross Beveridge & Bruce A. Draper, 2014 20

http://www.youtube.com/watch?v=h5mRRElXy-w

Page 11: Overview: Ray Tracing & The Perspective Projection Pipelinecs410/yr2014fa/more_progress/L02... · 28/08/2014  · Two Approaches to Graphics ! Common starting point: ! Create a scene

Course Plan

!  Objective: Understand image creation !  Assignment 1: Cast a ray

! Global coordinates emphasis on basics. ! Ray intersection calculations.

!  Assignment 2: Reference frames !  Add proper and distinct coordinate systems ! … and relate them to each other.

8/28/14 © Ross Beveridge & Bruce A. Draper, 2014 21

Course Plan (II)

!  Assignment #3: Better lighting and models !  Extend modeling to support complexity !  Add multi-bounce lighting !  Add richer material properties

!  Assignment #4: Motion and Transparency !  See through objects - refraction !  Put things in motion – short animations

Disclaimer: This is a plan, not a contract, the exact nature of the programming assignments will change.

8/28/14 © Ross Beveridge & Bruce A. Draper, 2014 22

Page 12: Overview: Ray Tracing & The Perspective Projection Pipelinecs410/yr2014fa/more_progress/L02... · 28/08/2014  · Two Approaches to Graphics ! Common starting point: ! Create a scene

A Quick Peak at Modeling Vertices, Polygons and setting up to start geometry in earnest.

The Ubiquitous Polygonal Mesh

!  A surface patch is often a polygon in 3D !  3 or more vertices !  Each vertex is an (x, y, z) triple !  Vertices are supplied in order

! Boundary of polygon goes from vertex #1 to vertex #2 to … vertex #N, and back to vertex #1

!  All vertices must be co-planar !  Polygon must be convex

8/28/14 © Ross Beveridge & Bruce A. Draper, 2014 24

Page 13: Overview: Ray Tracing & The Perspective Projection Pipelinecs410/yr2014fa/more_progress/L02... · 28/08/2014  · Two Approaches to Graphics ! Common starting point: ! Create a scene

For Example

!  A simple (4-vertex) polygon in 3D

8/28/14 © Ross Beveridge & Bruce A. Draper, 2014 Slide 25

(0,0,0) (1,0,0)

(1,1,0) (0,1,0)

Common Mistakes

8/28/14 © Ross Beveridge & Bruce A. Draper, 2014 Slide 26

!  Order of vertices:

The polygons above have the same vertices in a different order!

!  Non co-planar vertices:

The 4th vertex is not in the plane defined by the 1st three!

x

y

z

Page 14: Overview: Ray Tracing & The Perspective Projection Pipelinecs410/yr2014fa/more_progress/L02... · 28/08/2014  · Two Approaches to Graphics ! Common starting point: ! Create a scene

Surfaces: Connected Polygons

!  A mesh surface is then just a set of non-overlapping polygons that share vertices and edges

8/28/14 © Ross Beveridge & Bruce A. Draper, 2014 Slide 27

Triangle Strip Quad Mesh

http://groups.csail.mit.edu/graphics/classes/6.837/F98/TALecture/

Surfaces generally not planar

!  Although every polygon in the mesh must be.

!  Patches form a locally linear approximation to a curved surface.

Permission to use requested from Daniel Rypl at the Czech Technical University in Prague (8/22/12)

8/28/14 © Ross Beveridge & Bruce A. Draper, 2014 28

Page 15: Overview: Ray Tracing & The Perspective Projection Pipelinecs410/yr2014fa/more_progress/L02... · 28/08/2014  · Two Approaches to Graphics ! Common starting point: ! Create a scene

M =

x1 x2 x3 L xNy1 y2 y3 L yNz1 z2 z3 L zN

"

#

$ $ $

%

&

' ' '

Meshes as Matrices

!  A mesh is a set of N 3D vertices !  Represented as a 3×N matrix !  Each column is a vertex

!  With an index vector to show which vertices belong to which polygon !  E.g. ((1,2,3), (2,3,4), …)

8/28/14 © Ross Beveridge & Bruce A. Draper, 2014 Slide 29

A Touch of Reality ?

!  How many polygons? !  Why make them? !  Quote from Wired article:

!  Animating a Blockbuster: How Pixar Built Toy Story 3

8/28/14 © Ross Beveridge & Bruce A. Draper, 2014 30

Bobby Podesta, supervising animator of Toy Story 3, has been with Pixar since 1997 and, like most animators, considers himself an actor. “My job is to convince you that the stack of polygons on the screen is actually alive,” he says.

Link to Story: http://www.wired.com/magazine/2010/05/process_pixar/


Recommended