CS-184: Computer Graphics Lecture #6: Raytracing Prof. James - - PowerPoint PPT Presentation

cs 184 computer graphics
SMART_READER_LITE
LIVE PREVIEW

CS-184: Computer Graphics Lecture #6: Raytracing Prof. James - - PowerPoint PPT Presentation

CS-184: Computer Graphics Lecture #6: Raytracing Prof. James OBrien University of California, Berkeley V2013-S-06-1.0 1 Today Raytracing Shadows and direct lighting Reflection and refraction Antialiasing, motion blur, soft


slide-1
SLIDE 1

CS-184: Computer Graphics

Lecture #6: Raytracing

  • Prof. James O’Brien

University of California, Berkeley

V2013-S-06-1.0

2

Today

  • Raytracing
  • Shadows and direct lighting
  • Reflection and refraction
  • Antialiasing, motion blur, soft shadows, and depth of field
  • Intersection Tests
  • Ray-primitive

1 2 Saturday, February 9, 13

slide-2
SLIDE 2

Raytracing Assignment

3 4

Light in an Environment

Lady writing a Letter with her Maid National Gallery of Ireland, Dublin Johannes Vermeer, 1670

3 4 Saturday, February 9, 13

slide-3
SLIDE 3

5

Global Illumination Effects

PCKTWTCH Kevin Odhner POV-Ray

6

Global Illumination Effects

A Philco 6Z4 Vacuum Tube Steve Anger POV-Ray

5 6 Saturday, February 9, 13

slide-4
SLIDE 4

7

Global Illumination Effects

Caustic Sphere Henrik Jensen (refraction caustic)

8

Global Illumination Effects

Caustic Ring Henrik Jensen (reflection caustic)

7 8 Saturday, February 9, 13

slide-5
SLIDE 5

9

Global Illumination Effects

Sphere Flake Henrik Jensen

10

Early Raytracing

Turner Whitted

9 10 Saturday, February 9, 13

slide-6
SLIDE 6

11

Raytracing

  • Scan conversion
  • 3D → 2D → Image
  • Based on transforming geometry
  • Raytracing
  • 3D → Image
  • Geometric reasoning about light rays

12

Raytracing

Eye, view plane section, and scene

11 12 Saturday, February 9, 13

slide-7
SLIDE 7

13

Raytracing

Launch ray from eye through pixel, see what it hits

14

Raytracing

Compute color and fill-in the pixel

13 14 Saturday, February 9, 13

slide-8
SLIDE 8

15

Raytracing

  • Basic tasks
  • Build a ray
  • Figure out what a ray hits
  • Compute shading

16

Building Eye Rays

  • Rectilinear image plane build from four points

LL LR UR UL E P u v

P = u (vLL+(1−v)UL)+ (1−u)(vLR+(1−v)UR)

15 16 Saturday, February 9, 13

slide-9
SLIDE 9

17

Building Eye Rays

  • Nonlinear projections
  • Non-planar projection surface
  • Variable eye location

18

Examples

Multiple-Center-of-Projection Images P . Rademacher and G. Bishop SIGGRAPH 1998

17 18 Saturday, February 9, 13

slide-10
SLIDE 10

19

Examples

Spherical and Cylindrical Projections Ben Kreunen From Big Ben's Panorama Tutorials

20

Building Eye Rays

  • Ray equation
  • Through eye at
  • At pixel center at

R(t) = E+t(P−E) E P t ∈ [1...+∞] t = 0 t = 1

19 20 Saturday, February 9, 13

slide-11
SLIDE 11

21

Shadow Rays

  • Detect shadow by rays to light source

Incoming (eye) ray Shadow ray - no shadow Shadow ray - shadow Lights Occluder

R(t) = S+t(L−S) t ∈ [ε...1)

22

Shadow Rays

  • Test for occluder
  • No occluder, shade normally ( e.g. Phong model )
  • Yes occluder, skip light ( don’t skip ambient )
  • Self shadowing
  • Add shadow bias
  • Test object ID

Self-shadowing Correct

21 22 Saturday, February 9, 13

slide-12
SLIDE 12

23

Reflection Rays

  • Recursive shading
  • Ray bounces off object
  • Treat bounce rays (mostly) like eye rays
  • Shade bounce ray and return color
  • Shadow rays
  • Recursive reflections
  • Add color to shading at original point
  • Specular or separate reflection coefficient

t ∈ [ε...+∞) ˆ n R(t) = S+t B

24

Reflection Rays

  • Recursion Depth
  • Truncate at fixed number of bounces
  • Multiplier less than J.N.D.

23 24 Saturday, February 9, 13

slide-13
SLIDE 13

25

Refracted Rays

  • Transparent materials bend light
  • Snell’s Law ( see clever formula in text... )

ni nt = sinθt sinθi θi ni I T nt θt R sinθt > 1

Total (internal) reflection

26

Refracted Rays

  • Coefficient on transmitted ray depends on
  • Schlick approximation to Fresnel Equations
  • Attenuation
  • Wavelength (color) dependant
  • Exponential with distance

θ

kt(θi) = k0 +(1−k0)(1−cosθi)5 k0 = ✓nt −1 nt +1 ◆2

25 26 Saturday, February 9, 13

slide-14
SLIDE 14

27

Refracted Rays

O’Brien and Hodgins, SIGGRAPH 1999

28

  • Boolean on/off for pixels causes problems
  • Consider scan conversion algorithm:
  • Compare to casting a ray through each pixel center
  • Recall Nyquist Theorem
  • Sampling rate ≥ twice highest frequency

Anti-Aliasing

27 28 Saturday, February 9, 13

slide-15
SLIDE 15

29

Anti-Aliasing

  • Desired solution of an integral over pixel

30

“Distributed” Raytracing

  • Send multiple rays through each pixel
  • Average results together
  • Jittering trades aliasing for noise

One Sample 5x5 Grid 5x5 Jittered Grid

29 30 Saturday, February 9, 13

slide-16
SLIDE 16

“Distributed” Raytracing

31

Beverly Chiu and Max Delgadillo CS 184 2007

31 32 Saturday, February 9, 13

slide-17
SLIDE 17

33

“Distributed” Raytracing

  • Use multiple rays for reflection and refraction
  • At each bounce send out many extra rays
  • Quasi-random directions
  • Use BRDF (or Phong approximation) for weights
  • How many rays?

1

33 34 Saturday, February 9, 13

slide-18
SLIDE 18

16 256

35 36 Saturday, February 9, 13

slide-19
SLIDE 19

37

Soft Shadows

Umbra Penumbra Penumbra

Figure from S. Chenney

38

  • Distribute shadow rays over light surface

Soft Shadows

Figure from S. Chenney

All shadow rays go through No shadow rays go through Some shadow rays go through

37 38 Saturday, February 9, 13

slide-20
SLIDE 20

16

40

  • Distribute rays over time
  • More when we talk about animation...

Motion Blur

Pool Balls Tom Porter RenderMan

39 40 Saturday, February 9, 13

slide-21
SLIDE 21

41

Depth of Field

Kolb, Mitchell, and Hanrahan SIGGRAPH 1995

42

Depth of Field

No DoF Multiple images for DoF Jittered rays for DoF More rays Even more rays

41 42 Saturday, February 9, 13

slide-22
SLIDE 22

43

Other Lens Effects

Kolb, Mitchell, and Hanrahan SIGGRAPH 1995

44

Ray -vs- Sphere Test

  • Ray equation:
  • Implicit equation for sphere:
  • Combine:
  • Quadratic equation in t

R(t) = A+t D |X−C|2−r2 = 0 |R(t)−C|2−r2 = 0 |A+t D−C|2−r2 = 0

D A C

r

43 44 Saturday, February 9, 13

slide-23
SLIDE 23

45

Ray -vs- Sphere Test

Two solutions One solution Imaginary

46

Ray -vs- Triangle

  • Ray equation:
  • Triangle in barycentric coordinates:
  • Combine:
  • Solve for β, γ, and t
  • 3 equations 3 unknowns
  • Beware divide by near-zero
  • Check ranges

R(t) = A+t D X(β,γ) = V1 +β(V2 −V1)+γ(V3 −V1) V1+β(V2−V1)+γ(V3−V1) = A+t D

45 46 Saturday, February 9, 13