Transparency CS 6965 Fall 2011 Transparency Light is an - - PowerPoint PPT Presentation

transparency
SMART_READER_LITE
LIVE PREVIEW

Transparency CS 6965 Fall 2011 Transparency Light is an - - PowerPoint PPT Presentation

Transparency CS 6965 Fall 2011 Transparency Light is an electromagnetic wave Some materials conduct energy at visible frequencies CS 6965 Fall 2011 2 Transmitted rays plane of incidence i n r 1 1 1 boundary 2 t


slide-1
SLIDE 1

Transparency

CS 6965 Fall 2011

slide-2
SLIDE 2

Fall 2011 CS 6965

  • Light is an electromagnetic wave
  • Some materials conduct energy

at visible frequencies

2

Transparency

slide-3
SLIDE 3

Fall 2011 CS 6965

Transmitted rays

3

n r i t boundary η1 η2 plane of incidence θ2 θ1 θ1

slide-4
SLIDE 4

Fall 2011 CS 6965

Maxwell’s equations

  • Maxwell’s equations relate electricity and magnetism (light) as

waves in space

  • They predict the speed of light in a vacuum:

c = 1 µ0ε0 µ0 : Electric permittivity of free space ε0:Magnetic permeability of free space

4

slide-5
SLIDE 5

Fall 2011 CS 6965

Speed of light

  • Speed of light changes (slows) in other materials

v = 1 µε µ : Electrical permittivity of material ε:Magnetic permeability of material v ≤ c

5

slide-6
SLIDE 6

Fall 2011 CS 6965

Fermat’s principle (1657)

  • Light takes the fastest path between two points:

A B C

tAB = tAC + tBC = C − A va + B − C vb Simplify: By = 0 tAB = Cx − Ax

( )

2 + Ay 2

va + Bx − Cx

( )

2 + By 2

vb

6 2.00 2.25 2.50 2.75 3.00

  • 1
  • 0.8 -0.6 -0.4 -0.2

0.2 0.4 0.6 0.8 1 t

slide-7
SLIDE 7

Fall 2011 CS 6965

Refraction

tAB = Cx − Ax

( )

2 + Ay 2

va + Bx − Cx

( )

2 + By 2

vb d dCx tAB = 0 = Cx − Ax va Cx − Ax

( )

2 + Ay 2 +

Cx − Bx vb Bx − Cx

( )

2 + By 2

0 = sinθa va + −sinθb vb vb sinθa = va sinθb sinθa sinθb = va vb

7

A B C θA θB

slide-8
SLIDE 8

Fall 2011 CS 6965

Index of refraction

ηabs = where c = 2.99 x 108 m/s. Note: v ≤ c for all transparent materials, so η ≥ 1. Relative index of refraction: Absolute index of refraction: η = η2 η1 c v

8

slide-9
SLIDE 9

Fall 2011 CS 6965

Common values

9

Medium Index of refraction Perfect vacuum 1.0 Air (1 atm, 20° C) 1.0003 Water 1.33 Acrylic 1.49 Crown glass 1.52 Diamond 2.42

slide-10
SLIDE 10

Fall 2011 CS 6965

Snell’s Law

sinθ1 sinθ2 = v1 v2 = η2 η1 = η = η12

10

n r i t boundary η1 η2 plane of incidence θ2 θ1 θ1

slide-11
SLIDE 11

Fall 2011 CS 6965

Transmission

sinθ1 sinθ2 = η2 η1 = η = S1 S2 ,S2η = S1 cosθ1 = C1 = −N  ⋅V   cosθ2 = C2 = −N  ⋅T   Square both sides of S1η = S2 : S2

2η2 = S1 2

And use S2 + C 2 = 1 to get cosine forms : 1− C2

2

( )η2 = 1− C1

2

C2

2 = 1+

C1

2 −1

( )

η2 C2 = 1+ C1

2 −1

( )

η2

11

N V

  • N’

V’ T θ2 θ1

slide-12
SLIDE 12

Fall 2011 CS 6965

Transmission

T   = − ʹ″ N    + k ʹ″ V   + ʹ″ N   

( ) = k ʹ″

V   + (k −1) ʹ″ N    T   = 1 ʹ″ N    = C2 N  ʹ″ V   C1 = − ʹ″ N    , ʹ″ V   = − ʹ″ N    C1 , ʹ″ V   = C2 C1 ʹ″ V   = C2 C1 V   k = S2 S1 T   ʹ″ V   = S2 S1 1 C2 C1 = S2C1 C2S1

12

N V

  • N’

V’ T θ2 θ1 V’+N’ k

slide-13
SLIDE 13

Fall 2011 CS 6965

Transmission

T   = − ʹ″ N    + k ʹ″ V   + ʹ″ N   

( ) = k ʹ″

V   + (k −1) ʹ″ N    k = S2 S1 T   ʹ″ V   = S2 S1 1 C2 C1 = S2C1 C2S1 C2 = 1+ C1

2 −1

( )

η2 T   = S2C1 C2S1 C2 C1 V   + S2C1 C2S1 −1 ⎛ ⎝ ⎜ ⎞ ⎠ ⎟ C2 N  = S2 S1 V   + S2 S1 C1 − C2 ⎛ ⎝ ⎜ ⎞ ⎠ ⎟ N  = 1 ηV   + 1 η C1 − C2 ⎛ ⎝ ⎜ ⎞ ⎠ ⎟ N  = 1 ηV   + C1 η − 1+ C1

2 −1

( )

η2 ⎛ ⎝ ⎜ ⎜ ⎞ ⎠ ⎟ ⎟ N 

13

N V

  • N’

V’ T θ2 θ1 V’+N’ k

slide-14
SLIDE 14

Fall 2011 CS 6965

Transmitted ray direction, t (cont’d.)

When η1 < η2, t bends toward the normal direction at the hit point

14

η2 η1 n r i t θ2 θ1 θ1

slide-15
SLIDE 15

Fall 2011 CS 6965

Transmitted ray direction, t (cont’d.)

When η1 > η2, t bends away from the normal direction at the hit point

15

η2 η1 n r i t θ2 θ1 θ1

slide-16
SLIDE 16

Fall 2011 CS 6965

Total internal reflection

There exists a critical angle, θc, when the transmitted ray direction t is parallel to the boundary and θ2 = π/2

16

η2 η1 n r i t θ1 θ2 = π/2 θ1

slide-17
SLIDE 17

Fall 2011 CS 6965

θ1 approaches θc

As θ1 increases, t bends toward the boundary

17

η2 η1 n r i t θ1 θ2 θ1 η2 η1 n r i t θ1 θ2 θ1

θ1 << θc θ1 < θc

slide-18
SLIDE 18

Fall 2011 CS 6965

θ1 is greater than or equal to θc

When θ1 ≥ θc, t is parallel to the boundary and it carries no energy (total internal reflection occurs)

18

η2 η1 n r i t θ1 θ2 = π/2 θ1

θ1 = θc

η2 η1 n r i θ1 θ1

θ1 > θc

slide-19
SLIDE 19

Fall 2011 CS 6965

Checking for TIR

cos θ2 = [1 - 1 η2 (1 - cos2 θ1)]1/2 Recall that the angle of refraction θ2 is given by:

19

slide-20
SLIDE 20

Fall 2011 CS 6965

TIR occurs when θ1 = θc

1 - 1 η2 (1 - cos2 θ1) When θ1 = θc, the expression: becomes zero. When θ1 > θc, this expression is negative, so θ2 is imaginary and t is a complex number.

20

slide-21
SLIDE 21

Fall 2011 CS 6965

TIR condition

1 - 1 η2 (1 - cos2 θ1) < 0 Thus, TIR occurs when:

21

slide-22
SLIDE 22

Fall 2011 CS 6965

Spawning secondary rays

c(p) = clocal(p) + kr(p)*cr(pr) + kt(p)*ct(pt)

22

i r1 t1

slide-23
SLIDE 23

Fall 2011 CS 6965

Dielectric shading

result = normal lambertian (or other) shading Ray rray = reflect_ray(ray, …); if (tir(ray)) { // kr = 1, kt = 0 result += traceRay(rray, depth + 1, …); } else { result += kr*traceRay(rray, depth + 1, …); Ray tray = transmit_ray(ray, …); result += kt*traceRay(tray, depth + 1, …); }

23

slide-24
SLIDE 24

Fall 2011 CS 6965

Pseudocode (cont’d.)

bool tir(const Ray& ray) { float cosTheta = -ray.direction()*normal; float eta; if(cosTheta > 0) eta = ior_from/ior_to; else eta = ior_to/ior_from; return ((1. - (1. - cosTheta*cosTheta)/ (eta*eta)) < 0.); }

24

slide-25
SLIDE 25

Fall 2011 CS 6965

Pseudocode (cont’d.)

bool Dielectric::transmit_ray(const Ray& ray, …) { compute eta and cosTheta the same as in tir flip normal, eta, cosTheta if cosTheta < 0 tmp = 1.f - (1. - cosTheta1*cosTheta1)/(eta*eta); cosTheta2 = sqrt(tmp); Ray tray(hit_point, ray.direction()/(cosTheta2 - cosTheta1/eta)*normal; return tray; }

25

slide-26
SLIDE 26

Fall 2011 CS 6965

Implementation notes

  • There are more efficient ways of doing it than the above

pseudocode

  • If you want to do nested refraction, or if you want the eyepoint

in something beside a vacuum, you must track current index of refraction

  • Directions of the normal matter!

26

slide-27
SLIDE 27

Fall 2011 CS 6965

Light transport

  • There are 4 primary ways that light interacts with a surface:
  • Bounces off (perfect specular reflection)
  • Absorbed and retransmitted in an arbitrary direction (perfect

diffuse reflection)

  • Travels through surface (perfect specular transmission)
  • Absorbed and retransmitted on other side (perfect diffuse

transmission)

27

slide-28
SLIDE 28

Fall 2011 CS 6965

Imperfect materials

  • Most surfaces are not perfectly smooth:

28

slide-29
SLIDE 29

Fall 2011 CS 6965

Material models

29

Two choices:

  • 1. Simulate microfacets (intractable)
  • 2. Approximate models
slide-30
SLIDE 30

Fall 2011 CS 6965

BRDF

Source: surfaceoptics.com

30

slide-31
SLIDE 31

Fall 2011 CS 6965

BRDF info

  • http://graphics.stanford.edu/~smr/brdf/bv/
  • http://www.cs.utah.edu/~shirley/classes/brdf/
  • http://www.cs.princeton.edu/~smr/cs348c-97/surveypaper.html

31

slide-32
SLIDE 32

Fall 2011 CS 6965

Questions?

32

slide-33
SLIDE 33

Texturing

CS 6965 Fall 2011

slide-34
SLIDE 34

Fall 2011 CS 6965

Texture mapping

  • Most real objects do not have

uniform color

  • Texture: color and other material

properties as a function of space

34

slide-35
SLIDE 35

Fall 2011 CS 6965

Texture mapping topics

  • Image textures
  • Texture coordinates
  • Linear, cylindrical, spherical mappings
  • Barycentric coordinates for triangles
  • Software architecture
  • Procedural textures
  • Simple: checkerboards, tiles, etc.
  • Fractal noise based: marble, granite,

wood, etc.

  • Bump mapping

Ken Perlin, NYU

35

slide-36
SLIDE 36

Fall 2011 CS 6965

Lambertian Shading

Compute hit position (P   = O   + tV   ) Call primitive to get normal (N  ) (normalized) costheta = −N  ⋅V   if (costheta < 0) normal =-normal Color light = scene.ambient*Ka foreach light source get CL and L   dist= L   ,Ln   = L   L   cosphi = N  ⋅ Ln   if(cosphi > 0) if(!intersect with 0 < t < dist) light += CL *(Kd *cosphi) result=light*surface color

36

slide-37
SLIDE 37

Fall 2011 CS 6965

Simple image texture

Use hit position to determine image location P   : hit position C   : lower left corner of image U  : image X axis in world space V   : image Y axis in world space x, y: normalized image coordinates (0-1) P   = C   + xU   + yV   if U  ⋅V   = 0 : x = P   − C  

( )⋅U

  U   y = P   − C  

( )⋅V

  V  

37

World

P C x y U V Image

slide-38
SLIDE 38

Fall 2011 CS 6965

Simple image texture

x = P   − C  

( )⋅U

  U   y = P   − C  

( )⋅V

  V   ix = (int) x xres −1

( )

( ), fx = ix − x xres −1

( )

iy = (int) y yres −1

( )

( ), fy = iy − y yres −1

( )

Bilinear interpolation of image(ix,iy) - image(ix+1,iy+1) using fx,fy as interpolation factors Use interpolated color in lambertian shading

38

World

P C x y U V Image