MIT%206.837%20-%20Ray%20Tracing - PowerPoint PPT Presentation

About This Presentation
Title:

MIT%206.837%20-%20Ray%20Tracing

Description:

MIT 6'837 Ray Tracing – PowerPoint PPT presentation

Number of Views:76
Avg rating:3.0/5.0
Slides: 67
Provided by: FredoD5
Category:
Tags: 20ray | 20tracing | mit | ho1

less

Transcript and Presenter's Notes

Title: MIT%206.837%20-%20Ray%20Tracing


1
MIT 6.837 - Ray Tracing
2
Ray Tracing
  • MIT EECS 6.837
  • Frédo Durand and Barb Cutler
  • Some slides courtesy of Leonard McMillan

3
Administrative
  • Assignment 2
  • Due tomorrow at 1159pm
  • Assignment 3
  • Online this evening
  • Due Wednesday October 1

4
Cool assignment 1 results
seantek
koi
emmav
dym
5
Review of last week?
6
Review of last week
  • Linear, affine and projective transforms
  • Homogeneous coordinates
  • Matrix notation
  • Transformation composition is not commutative
  • Orthonormal basis change

7
Review of last week
  • Transformation for ray tracing
  • Transforming the ray
  • For the direction, linear part of the transform
    only
  • Transforming t or not
  • Normal transformation
  • Constructive Solid Geometry (CSG)

nWS
nWST nOS (M-1)
vWS
8
Fun with transformations Relativity
  • Special relativity Lorentz transformation
  • 4 vector (t, x, y, z)
  • 4th coordinate can be ct or t
  • Lorentz transformation depends on object speed v

Digression
http//casa.colorado.edu/ajsh/sr/sr.shtml
9
Relativity
  • Transform ray by Lorentz transformation

Digression
0.65c
0.70c
0.90c
0.99c
See also http//www.cs.mu.oz.au/andrbh/raytrace/r
aytrace.html
10
Today Ray Tracing
Image by Turner Whitted

11
Overview of today
  • Shadows
  • Reflection
  • Refraction
  • Recursive Ray Tracing

12
Ray Casting (a.k.a. Ray Shooting)
  • For every pixel (x,y)Construct a ray from the
    eye colorx,ycastRay(ray)
  • Complexity?
  • O(n m)
  • n number of objects, m number of pixels

13
Ray Casting with diffuse shading
  • Color castRay(ray)Hit hit()
  • For every object ob
  • ob-gtintersect(ray, hit, tmin)
  • Color colambienthit-gtgetColor()
  • For every light L
  • colcolhit-gtgetColorL()L-gtgetColorL-gtgetDir()-
    gtDot3( hit-gtgetNormal() )
  • Return col

14
Encapsulating shading
  • Color castRay(ray)Hit hit()
  • For every object ob
  • ob-gtintersect(ray, hit, tmin)
  • Color colambienthit-gtgetMaterial()-gtgetDiffuse()
  • For every light L
  • colcolhit-gtgetMaterial()-gtshade (ray, hit,
    L-gtgetDir(), L-gtgetColor())
  • Return col

15
Questions?
  • Image computed using the RADIANCE system by Greg
    Ward

16
How can we add shadows?
  • Color castRay(ray)Hit hit()
  • For every object ob
  • ob-gtintersect(ray, hit, tmin)
  • Color colambienthit-gtgetMaterial()-gtgetDiffuse()
  • For every light L
  • colcolhit-gtgetMaterial()-gtshade (ray, hit,
    L-gtgetDir(), L-gtgetColor())
  • Return col

17
Shadows
  • Color castRay(ray)Hit hit()
  • For every object ob
  • ob-gtintersect(ray, hit, tmin)
  • Color colambienthit-gtgetMaterial()-gtgetDiffuse()
  • For every light L
  • Ray ray2(hitPoint, L-gtgetDir()) Hit
    hit2(L-gtgetDist(),,)
  • For every object ob
  • ob-gtintersect(ray2, hit2, 0)
  • If (hit-gtgetTgt L-gtgetDist())
  • colcolhit-gtgetMaterial()-gtshade (ray, hit,
    L-gtgetDir(), L-gtgetColor())
  • Return col

18
Shadows problem?
  • Color castRay(ray)Hit hit()
  • For every object ob
  • ob-gtintersect(ray, hit, tmin)
  • Color colambienthit-gtgetMaterial()-gtgetDiffuse()
  • For every light L
  • Ray ray2(hitPoint, L-gtgetDir()) Hit
    hit2(L-gtgetDist(),,)
  • For every object ob
  • ob-gtintersect(ray2, hit2, 0)
  • If (hit-gtgetTgt L-gtgetDist())
  • colcolhit-gtgetMaterial()-gtshade (ray, hit,
    L-gtgetDir(), L-gtgetColor())
  • Return col

19
Avoiding self shadowing
  • Color castRay(ray)Hit hit()
  • For every object ob
  • ob-gtintersect(ray, hit, tmin)
  • Color colambienthit-gtgetMaterial()-gtgetDiffuse()
  • For every light L
  • Ray ray2(hitPoint, L-gtgetDir()) Hit
    hit2(L-gtgetDist(),,)
  • For every object ob
  • ob-gtintersect(ray2, hit2, epsilon)
  • If (hit-gtgetTgt L-gtgetDist())
  • colcolhit-gtgetMaterial()-gtshade (ray, hit,
    L-gtgetDir(), L-gtgetColor())
  • Return col

20
Shadow optimization
  • Shadow rays are special
  • How can we accelerate our code?

21
Shadow optimization
  • We only want to know whether there is an
    intersection, not which one is closest
  • Special routine Object3DintersectShadowRay()
  • Stops at first intersection

22
Shadow ray casting history
  • Due to Appel 1968
  • First shadow method in graphics
  • Not really used until the 80s

23
Questions?
  • Image Henrik Wann Jensen

24
Overview of today
  • Shadows
  • Reflection
  • Refraction
  • Recursive Ray Tracing

25
Mirror Reflection
  • Compute mirror contribution
  • Cast ray
  • In direction symmetric wrt normal
  • Multiply by reflection coefficient (color)

26
Mirror Reflection
  • Cast ray
  • In direction symmetric wrt normal
  • Dont forget to add epsilon to the ray

Without epsilon
With epsilon
27
Reflection
  • Reflection angle view angle

N
R
V
q
q
R
V
28
Reflection
  • Reflection angle view angle

29
Amount of Reflection
  • Traditional (hacky) ray tracing
  • Constant coefficient reflectionColor
  • Component per component multiplication

30
Amount of Reflection
  • More realistic
  • Fresnel reflection term
  • More reflection at grazing angle
  • Schlicks approximation R(q)R0(1-R0)(1-cos q)5

metal
Dielectric (glass)
31
Fresnel reflectance demo
  • Lafortune et al., Siggraph 1997

32
Questions?
  • Image by Henrik Wann Jensen

33
Overview of today
  • Shadows
  • Reflection
  • Refraction
  • Recursive Ray Tracing

34
Transparency
  • Compute transmitted contribution
  • Cast ray
  • In refracted direction
  • Multiply by transparency coefficient (color)

35
Qualitative refraction
  • From Color and Light in Nature by Lynch and
    Livingston

36
Refraction
Snell-Descartes Law
Note that I is the negative of the incoming ray
37
Refraction
Snell-Descartes Law
Note that I is the negative of the incoming ray
38
Refraction
Snell-Descartes Law
Note that I is the negative of the incoming ray
39
Refraction
Snell-Descartes Law
Note that I is the negative of the incoming ray
40
Refraction
Snell-Descartes Law
Note that I is the negative of the incoming ray
41
Refraction
Snell-Descartes Law
Note that I is the negative of the incoming ray
Dont forget to normalize
Total internal reflection when the square root is
imaginary
42
Total internal reflection
  • From Color and Light in Nature by Lynch and
    Livingstone

43
Cool refraction demo
  • Enright, D., Marschner, S. and Fedkiw, R.,

44
Cool refraction demo
  • Enright, D., Marschner, S. and Fedkiw, R.,

45
Refraction and the lifeguard problem
  • Running is faster than swimming

Lifeguard
Beach
Water
Run
Person in trouble
Digression
Swim
46
Wavelength
  • Refraction is wavelength-dependent
  • Newtons experiment
  • Usually ignored in graphics

Pittoni, 1725, Allegory to Newton
Pink Floyd, The Dark Side of the Moon
47
Rainbow
  • From Color and Light in Nature by Lynch and
    Livingstone

Digression
48
Rainbow
  • Refraction depends on wavelength
  • Rainbow is caused by refractioninternal
    reflectionrefraction
  • Maximum for angle around 42 degrees

Digression
From Color and Light in Nature by Lynch and
Livingstone
49
Questions?
50
Overview of today
  • Shadows
  • Reflection
  • Refraction
  • Recursive Ray Tracing

51
Recap Ray Tracing
  • traceRay
  • Intersect all objects
  • Ambient shading
  • For every light
  • Shadow ray
  • shading
  • If mirror
  • Trace reflected ray
  • If transparent
  • Trace transmitted ray

52
Recap Ray Tracing
  • Color traceRay(ray)For every object ob
  • ob-gtintersect(ray, hit, tmin)
  • Color colambienthit-gtgetMaterial()-gtgetDiffuse()
  • For every light L
  • If ( not castShadowRay( hit-gtgetPoint(),
    L-gtgetDir())
  • colcolhit-gtgetMaterial()-gtshade (ray, hit,
    L-gtgetDir(), L-gtgetColor())
  • If (hit-gtgetMaterial()-gtisMirror())
  • Ray rayMirror (hit-gtgetPoint(),
    getMirrorDir(ray-gtgetDirection(),
    hit-gtgetNormal())
  • Colcolhit-gtgetMaterial-gtgetMirrorColor()traceR
    ay(rayMirror, hit2)
  • If (hit-gtgetMaterial()-gtisTransparent()
  • Ray rayTransmitted(hit-gtgetPoint(),
    getRefracDir(ray, hit-gtgetNormal(),
    curentRefractionIndex, hit-gtMaterial-gtgetRefractio
    nIndex())
  • Colcolhit-gtgetMaterial-gtgetTransmittedColor()t
    raceRay(rayTransmitted, hit3)
  • Return col

53
Does it end?
  • Color traceRay(ray)For every object ob
  • ob-gtintersect(ray, hit, tmin)
  • Color colambienthit-gtgetMaterial()-gtgetDiffuse()
  • For every light L
  • If ( not castShadowRay( hit-gtgetPoint(),
    L-gtgetDir())
  • colcolhit-gtgetMaterial()-gtshade (ray, hit,
    L-gtgetDir(), L-gtgetColor())
  • If (hit-gtgetMaterial()-gtisMirror())
  • Ray rayMirror (hit-gtgetPoint(),
    getMirrorDir(ray-gtgetDirection(),
    hit-gtgetNormal())
  • Colcolhit-gtgetMaterial-gtgetMirrorColor()traceR
    ay(rayMirror, hit2)
  • If (hit-gtgetMaterial()-gtisTransparent()
  • Ray rayTransmitted(hit-gtgetPoint(),
    getRefracDir(ray, hit-gtgetNormal(),
    curentRefractionIndex, hit-gtMaterial-gtgetRefractio
    nIndex())
  • Colcolhit-gtgetMaterial-gtgetTransmittedColor()t
    raceRay(rayTransmitted, hit3)
  • Return col

54
Avoiding infinite recursion
  • Stopping criteria
  • Recursion depth
  • Stop after a number of bounces
  • Ray contribution
  • Stop if transparency/transmitted attenuation
    becomes too small
  • Usually do both

Color traceRay(ray)For every object
ob ob-gtintersect(ray, hit, tmin) Color
colambienthit-gtgetMaterial()-gtgetDiffuse() For
every light L If ( not castShadowRay(
hit-gtgetPoint(), L-gtgetDir()) colcolhit-gtgetMate
rial()-gtshade (ray, hit, L-gtgetDir(),
L-gtgetColor()) If (hit-gtgetMaterial()-gtisMirror()
) Ray rayMirror (hit-gtgetPoint(),
getMirrorDir(ray-gtgetDirection(),
hit-gtgetNormal()) Colcolhit-gtgetMaterial-gtgetMi
rrorColor()traceRay(rayMirror) If
(hit-gtgetMaterial()-gtisTransparent() Ray
rayTransmitted(hit-gtgetPoint(),
getRefracDir(ray, hit-gtgetNormal(),
curentRefractionIndex, hit-gtMaterial-gtgetRefractio
nIndex()) Colcolhit-gtgetMaterial-gtgetTransmitte
dColor()traceRay(rayTransmitted) Return col
55
Recursion for reflection
1 recursion
0 recursion
2 recursions
56
The Ray Tree
T3
Eye
R2
N2
T1
R3
R1
N3
L1
L2
L3
N1
L1
T1
R1
L3
L2
Ni surface normal Ri reflected ray Li shadow
ray Ti transmitted (refracted) ray
Eye
T3
R3
R2
57
Kewl visualization
  • Ben Garlicks SGI demo flyray
  • On an Athena SGI O2
  • add 6.837
  • cd /mit/6.837/demos/flyray/data
  • ../flyray

58
Real-time ray tracing
  • Steve Parker et al. (U. of Utah)

59
Ray Tracing History
  • Ray Casting Appel, 1968
  • CSG and quadrics Goldstein Nagel 1971
  • Recursive ray tracing Whitted, 1980

60
Does Ray Tracing simulate physics?
  • Photons go from the light to the eye, not the
    other way
  • What we do is backward ray tracing

61
Forward ray tracing
  • Start from the light source
  • But low probability to reach the eye
  • What can we do about it?

62
Forward ray tracing
  • Start from the light source
  • But low probability to reach the eye
  • What can we do about it?
  • Always send a ray to the eye
  • Still not efficient

63
Does Ray Tracing simulate physics?
  • Ray Tracing is full of dirty tricks
  • e.g. shadows of transparent objects
  • Dirtiest opaque
  • Still dirty multiply by transparency color
  • But then no refraction

64
Correct transparent shadow
  • Animation by Henrik Wann Jensen
  • Using advanced refraction technique (refraction
    for illumination is usually not handled that well)

Digression
65
The Rendering equation
  • Clean mathematical framework for light-transport
    simulation
  • Well see that in November
  • At each point, outgoing light in one directionis
    the integral of incoming light in all directions
    multiplied by reflectance property

66
Thursday
  • Reflectance properties, shading and BRDF
  • Guest lecture by Wojciech Matusik
Write a Comment
User Comments (0)
About PowerShow.com