76
1 MIT EECS 6.837 – Matusik MIT EECS 6.837 Computer Graphics Part 2 – Rendering NVIDIA Today: Intro to Rendering, Ray Casting © NVIDIA Inc. All rights reserved. This content is excluded from our Creative Commons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/.

MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

1 MIT EECS 6.837 – Matusik

MIT EECS 6.837 Computer Graphics Part 2 – Rendering

NVIDIA

Today: Intro to Rendering, Ray Casting

© NVIDIA Inc. All rights reserved. This content is excluded from our Creative Commonslicense. For more information, see http://ocw.mit.edu/help/faq-fair-use/.

Page 2: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

2

Cool Artifacts from Assignment 1

© source unknown. All rights reserved. This content is excluded from our CreativeCommons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/.

Page 3: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

3

Cool Artifacts from Assignment 1

© source unknown. All rights reserved. This content is excluded from our CreativeCommons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/.

Page 4: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

• Modeling – splines, hierarchies, transformations, meshes, etc.

• Animation

– skinning, ODEs, masses and springs

• Now we’ll to see how to generate

an image given a scene description!

4

The Story So Far

Page 5: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

• Ray Casting and Ray Tracing • Intro to Global Illumination

– Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping

– What makes materials look like they do? • Image-based Rendering • Sampling and antialiasing • Rasterization, z-buffering • Shadow techniques • Graphics Hardware

5

The Remainder of the Term

[Lehtinen et al. 2008] © ACM. All rights reserved. This content is excluded from our Creative Commonslicense. For more information, see http://ocw.mit.edu/help/faq-fair-use/.

Page 6: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

• What does rendering mean?

• Basics of ray casting

6

Today

Page 7: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

Scene 7

© source unknown. All rights reserved. This content is excluded from our CreativeCommons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/.

© Oscar Meruvia-Pastor, Daniel Rypl. All rights reserved. This content is excluded from our CreativeCommons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/.

Page 8: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

8

Scene Camera

This image is in the public domain.Source: openclipart

© source unknown. All rights reserved. This content is excluded from our CreativeCommons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/.

© Oscar Meruvia-Pastor, Daniel Rypl. All rights reserved. This content is excluded from our CreativeCommons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/.

Page 9: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

9

Scene

Camera Image plane

Pixels

© source unknown. All rights reserved. This content isexcluded from our Creative Commons license. For moreinformation, see http://ocw.mit.edu/help/faq-fair-use/.

© Oscar Meruvia-Pastor, Daniel Rypl. All rights reserved.

This content is excluded from our Creative Commons

license. For more information, seehttp://ocw.mit.edu/help/faq-fair-use/.

This image is in the public domain.Source: openclipart

Page 10: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

10

Scene

Camera Image plane

Image

Pixels

Rendering = Scene to Image

© source unknown. All rights reserved. Thiscontent is excluded from our Creative

Commons license. For more information, seehttp://ocw.mit.edu/help/faq-fair-use/.

© Oscar Meruvia-Pastor, Daniel Rypl. All rights reserved.

This content is excluded from our Creative Commons

license. For more information, seehttp://ocw.mit.edu/help/faq-fair-use/.

This image is in the public domain.Source: openclipart

Page 11: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

11

Scene

Image

Each pixel corresponds to

one ray. We need to figure

out which scene point each

one hits.

Pixels

Rendering – Pinhole Camera

© source unknown. All rights reserved. Thiscontent is excluded from our Creative Commons license. For more information,see http://ocw.mit.edu/help/faq-fair-use/.

© Oscar Meruvia-Pastor, Daniel Rypl. All rights reserved.This content is excluded from our Creative Commonslicense. For more information, see http://ocw.mit.edu/help/faq-fair-use/.

This image is in the public domain.Source: openclipart

Page 12: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

12

Scene

Image

Pixels

Rendering

What’s the

color you put

in each pixel?

© source unknown. All rights reserved. Thiscontent is excluded from our Creative Commons license. For more information,see http://ocw.mit.edu/help/faq-fair-use/.

© Oscar Meruvia-Pastor, Daniel Rypl. All rights reserved.This content is excluded from our Creative Commonslicense. For more information, see http://ocw.mit.edu/help/faq-fair-use/.

This image is in the public domain.Source: openclipart

Page 13: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

13

Scene

Image

Pixels

Rendering

Pixel Color

Determined by

Lighting/Shading

© source unknown. All rights reserved. Thiscontent is excluded from our Creative Commons license. For more information,see http://ocw.mit.edu/help/faq-fair-use/.

© Oscar Meruvia-Pastor, Daniel Rypl. All rights reserved.This content is excluded from our Creative Commonslicense. For more information, see http://ocw.mit.edu/help/faq-fair-use/.

This image is in the public domain.Source: openclipart

Page 14: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

• “Rendering” refers to the entire process that produces color values for pixels, given a 3D representation of the scene

• Pixels correspond to rays; need to figure out the visible scene point along each ray – Called “hidden surface problem” in older texts – “Visibility” is a more modern term – Also, we assume (for now) a single ray per pixel

14

Rendering

Page 15: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

• “Rendering” refers to the entire process that produces color values for pixels

• Pixels correspond to rays; need to figure out the visible scene point along each ray – Called “hidden surface problem” in older texts – “Visibility” is a more modern term – Also, we assume (for now) a single ray per pixel

• Major algorithms: Ray casting and rasterization

• Note: We are assuming a pinhole camera (for now) 15

Rendering

Page 16: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

16

Questions?

Page 17: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

• Ray Casting Basics

• Camera and Ray Generation

• Ray-Plane Intersection

• Ray-Sphere Intersection

17

Ray Casting

Page 18: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

For every pixel

Construct a ray from the eye

For every object in the scene

Find intersection with the ray

Keep if closest

18

Ray Casting

Page 19: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

For every pixel

Construct a ray from the eye

For every object in the scene

Find intersection with the ray

Keep if closest

Shade

19

Shading

Page 20: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

• Surface/Scene Properties – surface normal – direction to light – viewpoint

• Material Properties – Diffuse (matte) – Specular (shiny) – …

• Light properties – Position – Intensity, ...

• Much more! 20

Shading = What Surfaces Look Like

Diffuse sphere Specular spheres

N

L V

Page 21: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

• Let’s think about shadows...

21

Ray Casting vs. Ray Tracing

This image is in the public domain.Source: openclipart

Page 22: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

22

“camera rays” are rays from the

camera to the scene

?

Ray Casting vs. Ray Tracing

This image is in the public domain.Source: openclipart

Page 23: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

23

X

ray from light to hit point is blocked, i.e., point is in shadow

Ray Casting vs. Ray Tracing

This image is in the public domain.Source: openclipart

Page 24: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

• Ray casting = eye rays only, tracing = also secondary

24

X Secondary rays are used for

testing shadows, doing

reflections, refractions, etc.

We’ll do all this a little

later!

Ray Casting vs. Ray Tracing

This image is in the public domain.Source: openclipart

Page 25: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

Secondary Rays Indirect illumination

Shadows

Reflections Refractions

Caustics

Hen

rik W

ann

Jens

en

25 Courtesy of Henrik Wann Jensen. Used with permission.

Page 26: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

26

Ray Tracing

Reflections, refractions

Caustics

Reflections

© source unknown. All rights reserved. This content is excluded from our CreativeCommons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/.

Courtesy of Henrik Wann Jensen. Used with permission.

© Turner Whitted, Bell Laboratories. All rights reserved. This content isexcluded from our Creative Commons license. For more information,see http://ocw.mit.edu/help/faq-fair-use/.

Page 27: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

27

Questions?

Page 28: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

For every pixel

Construct a ray from the eye

For every object in the scene

Find intersection with the ray

Keep if closest

Shade depending on light and normal vector

28

Ray Casting

N Finding the

intersection point

and normal is the

central part of ray

casting

Page 29: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

• Origin – Point • Direction – Vector

– normalized is better • Parametric line

– P(t) = origin + t * direction

29

Ray Representation

origin direction

P(t)

How would you

represent a ray?

Page 30: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

• Origin – Point • Direction – Vector

– normalized is better • Parametric line

– P(t) = origin + t * direction

30

Ray Representation

origin direction

P(t)

Another way to put

the ray casting

problem statement:

Find smallest t > 0

such that P(t) lies

on a surface in the

scene

Page 31: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

• Albrecht Dürer, 16th century

31

Dürer’s Ray Casting Machine

© source unknown. All rights reserved. This content is excluded from our CreativeCommons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/.

Page 32: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

• Albrecht Dürer, 16th century

32

Dürer’s Ray Casting Machine

© source unknown. All rights reserved. This content is excluded from our CreativeCommons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/.

Page 33: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

• Ray Casting Basics

• Camera and Ray Generation

• Ray-Plane Intersection

• Ray-Sphere Intersection

33

Ray Casting

Page 34: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

For every pixel

Construct a ray from the eye

For every object in the scene

Find intersection with ray

Keep if closest

34

Cameras

© source unknown. All rights reserved. This content is excluded from our CreativeCommons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/.

Page 35: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

35

Pinhole Camera • Box with a tiny hole • Inverted image • Similar triangles

• Perfect image if hole infinitely small

• Pure geometric optics • No depth of field issue

(everything in focus)

Page 36: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

• From Gemma Frisius, 1545

36

Oldest Illustration

© source unknown. All rights reserved. This content is excluded from our CreativeCommons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/.

Page 37: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

37

Also Called “Camera Obscura”

Image courtesy of Wellcome Library, London. License: CC-BY-NC. This content is excluded fromour Creative Commons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/.

Page 38: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

38

Camera Obscura Today

Abelardo Morell www.abelardomorell.net

Images removed due to copyright restrictions -- please seehttp://www.abelardomorell.net/photography/cameraobsc_01/cameraobsc_17.htmlhttp://www.abelardomorell.net/posts/camera-obscura/http://www.abelardomorell.net/photography/cameraobsc_49/cameraobsc_63.html for further details.

Page 39: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

• Eye-image pyramid (view frustum) • Note that the distance/size of image are arbitrary

39

Simplified Pinhole Camera

same image

will result on

this image plane

Page 40: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

40

Camera Description?

Page 41: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

• Eye point e (center)

• Orthobasis u, v, w (horizontal, up, direction)

41

Camera Description?

Object coordinates World coordinates View

coordinates

Image coordinates

u w

v

Page 42: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

42

Camera Description?

Object coordinates World coordinates View

coordinates

Image coordinates

u w

v

• Eye point e (center)

• Orthobasis u, v, w (horizontal, up, direction)

• Field of view angle

• Image rectangle aspect ratio

Page 43: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

43

Camera

Image plane

Image Coordinates

-1 ≤ x ≤ 1

-1 ≤ y ≤ 1

Convenient to define “normalized image coordinates” such that the x, y

coordinates run

from -1 to 1

regardless of the

dimensions and

aspect ratio of the

image rectangle.

This image is in the public domain.Source: openclipart

Page 44: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

44

field of view α right u

view direction w

image plane -1 < x < 1

x

eye point e

p

p is point on image plane at coordinate x, we want to know the direction of the ray r

r?

Ray Generation in 2D

This image is in the public domain. Source: openclipart

Page 45: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

45

field of view α

image plane -1 < x < 1

1

right u

view direction w

Ray Generation in 2D

What is the distance D to the screen so that the normalized coordinates go to 1?

This image is in the public domain. Source: openclipart

Page 46: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

46

field of view α

image plane -1 < x < 1

D

1

right u

view direction w

Ray Generation in 2D

This image is in the public domain. Source: openclipart

Page 47: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

47

field of view α right u

view direction w

image plane -1 < x < 1

x

D

r = p-e = (x*u, D*w)

eye point e

r

p

Ray Generation in 2D

This image is in the public domain. Source: openclipart

Page 48: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

48

Ray Generation in 2D

field of view α right u

view direction w

image plane -1 < x < 1

x

D

eye point e

r

p

then we just normalize r to get the ray

r = p-e = (x*u, D*w)

This image is in the public domain. Source: openclipart

Page 49: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

• y coordinate is treated just like x, except accounting for aspect ratio – r = (x*u, aspect*y*v, D*w) – Again, u, v, w are the basis vectors

of the view coordinate system – Aspect ratio handles non-square viewports

• Think of your 16:9 widescreen TV

• The point of the exercise with computing D was to allow us to use the [-1,1] image coordinate system regardless of field of view.

49

That was 2D, 3D is just as simple

Page 50: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

50

Perspective vs. Orthographic

• Parallel projection • No foreshortening • No vanishing point

perspective orthographic

Page 51: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

• Ray Generation? – Origin = e + x*size*u + y*size*v – Direction is constant: w

51

Orthographic Camera

Page 52: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

• E.g. fish eye, omnimax, parabolic

52

Other Weird Cameras

CAVE Columbia University

© source unknown. All rights reserved. This content is excludedfrom our Creative Commons license. For more information, seehttp://ocw.mit.edu/help/faq-fair-use/.

© CAVE Lab, Columbia University. All rights reserved. Thiscontent is excluded from our Creative Commons license. Formore information, see http://ocw.mit.edu/help/faq-fair-use/.

Page 53: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

53

Questions? Even Funkier

Multiperspective Imaging

Courtesy of Paul Rademacher. Used with permission.

Page 54: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

• Ray Casting Basics

• Camera and Ray Generation

• Ray-Plane Intersection

• Ray-Sphere Intersection

54

Ray Casting

Page 55: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

For every pixel

Construct a ray from the eye

For every object in the scene

Find intersection with the ray

Keep if closest

First we will study ray-plane intersection

55

Ray Casting

Page 56: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

• Parametric line • P(t) = Ro + t * Rd

• Explicit representation

56

Recall: Ray Representation

Rd Ro

origin direction

P(t)

Page 57: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

• (Infinite) plane defined by – Po = (x0, y0, z0) – n = (A,B,C)

57

3D Plane Representation?

H Po

normal P

P' H(p) = d < 0

H(p) = d > 0

Page 58: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

• (Infinite) plane defined by – Po = (x0, y0, z0) – n = (A,B,C)

• Implicit plane equation – H(P) = Ax+By+Cz+D = 0

= n·P + D = 0

58

3D Plane Representation?

H Po

normal P

P' H(p) = d < 0

H(p) = d > 0

Page 59: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

• (Infinite) plane defined by – Po = (x0, y0, z0) – n = (A,B,C)

• Implicit plane equation – H(P) = Ax+By+Cz+D = 0

= n·P + D = 0 – What is D?

59

3D Plane Representation?

H Po

normal P

P' H(p) = d < 0

H(p) = d > 0

(Point P0 must lie on plane)

Page 60: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

• (Infinite) plane defined by – Po = (x0, y0, z0) – n = (A,B,C)

• Implicit plane equation – H(P) = Ax+By+Cz+D = 0

= n·P + D = 0 • Point-Plane distance?

– If n is normalized, distance to plane is H(P)

– it is a signed distance!

60

3D Plane Representation?

H Po

normal P

P' H(p) < 0

H(p) > 0

Page 61: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

• Ray equation is explicit P(t) = Ro + t * Rd – Parametric – Generates points – Hard to verify that a point is on the ray

• Plane equation is implicit H(P) = n·P + D = 0 – Solution of an equation – Does not generate points – Verifies that a point is on the plane

• Exercise: Explicit plane and implicit ray?

61

Explicit vs. Implicit?

Page 62: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

• Intersection means both are satisfied • So, insert explicit equation of ray into

implicit equation of plane & solve for t P(t) = Ro + t * Rd

H(P) = n·P + D = 0 n·(Ro + t * Rd) + D = 0 t = -(D + n·Ro) / n·Rd

62

Ray-Plane Intersection

P(t)

Done!

Page 63: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

• Intersection means both are satisfied • So, insert explicit equation of ray into

implicit equation of plane & solve for t P(t) = Ro + t * Rd

H(P) = n·P + D = 0 n·(Ro + t * Rd) + D = 0 t = -(D + n·Ro) / n·Rd

63

Ray-Plane Intersection

P(t)

Done!

What’s the deal when n·Rd = 0?

Page 64: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

• Verify that intersection is closer than previous

• Verify that it is not out of range (behind eye)

64

Additional Bookkeeping

t > tmin

t < tcurrent

P(t)

Page 65: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

• Also need surface normal for shading – (Diffuse: dot product between light

direction and normal, clamp to zero) • Normal is constant over the plane

65

Normal

normal

Page 66: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

Image by Henrik Wann Jensen 66

Questions?

Courtesy of Henrik Wann Jensen. Used with permission.

Page 67: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

• Ray Casting Basics

• Camera and Ray Generation

• Ray-Plane Intersection

• Ray-Sphere Intersection

67

Ray Casting

Page 68: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

• Implicit sphere equation – Assume centered at origin (easy to translate) – H(P) = ||P||2 - r2 = P·P - r2 = 0

68

Sphere Representation?

Rd Ro

Page 69: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

• Insert explicit equation of ray into implicit equation of sphere & solve for t

P(t) = Ro + t*Rd ; H(P) = P·P - r2 = 0 (Ro + tRd) · (Ro + tRd) - r2 = 0 Rd·Rdt2 + 2Rd·Rot + Ro·Ro - r2 = 0

69

Ray-Sphere Intersection

Rd Ro

Page 70: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

• Quadratic: at2 + bt + c = 0 – a = 1 (remember, ||Rd|| = 1) – b = 2Rd·Ro

– c = Ro·Ro – r2

• with discriminant

• and solutions

70

Ray-Sphere Intersection

Page 71: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

• 3 cases, depending on the sign of b2 – 4ac • What do these cases correspond to? • Which root (t+ or t-) should you choose?

– Closest positive!

71

Ray-Sphere Intersection

Page 72: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

72

Ray-Sphere Intersection • It's so easy

that all ray-tracing images have spheres!

:-)

Turn

er W

hitte

d

© source unknown. All rights reserved. This content is excluded from our CreativeCommons license. For more information, see http://ocw.mit.edu/help/faq-fair-use/.

Page 73: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

• Simply Q/||Q|| – Q = P(t), intersection point – (for spheres centered at origin)

73

Sphere Normal

Q normal

Ro

O

Rd

Page 74: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

74

Questions?

Courtesy of Henrik Wann Jensen. Used with permission.

Page 75: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

MIT EECS 6.837 – Durand

That’s All for Today

NVIDIA

• But before we talk about the quiz, let’s watch a cool

video! • Next time: Ray-triangle intersection, ray tracing

75

© NVIDIA Inc. All rights reserved. This content is excluded from our Creative Commonslicense. For more information, see http://ocw.mit.edu/help/faq-fair-use/.

Page 76: MIT EECS 6.837 Computer Graphics Part 2 – Rendering · –Monte Carlo techniques, photon mapping, etc. • Shading, texture mapping –What makes materials look like they do? •

MIT OpenCourseWarehttp://ocw.mit.edu

6.837 Computer GraphicsFall 2012

For information about citing these materials or our Terms of Use, visit: http://ocw.mit.edu/terms.