Welcome! Todays Agenda: Reflections Refraction Recursion - - PowerPoint PPT Presentation

welcome today s agenda
SMART_READER_LITE
LIVE PREVIEW

Welcome! Todays Agenda: Reflections Refraction Recursion - - PowerPoint PPT Presentation

INFOGR Computer Graphics Jacco Bikker - April-July 2016 - Lecture 5: Ray Tracing (3) Welcome! Todays Agenda: Reflections Refraction Recursion Shading models TODO INFOGR Lecture 5 Ray Tracing


slide-1
SLIDE 1

INFOGR – Computer Graphics

Jacco Bikker - April-July 2016 - Lecture 5: “Ray Tracing (3)”

Welcome!

slide-2
SLIDE 2

Today’s Agenda:

  • Reflections
  • Refraction
  • Recursion
  • Shading models
  • TODO
slide-3
SLIDE 3

Reflections

INFOGR – Lecture 5 – “Ray Tracing (3)” 3

slide-4
SLIDE 4

Reflections

Light Transport

We introduce a pure specular object in the scene. Based on the normal at the primary intersection point, we calculate a new direction. We follow the path using a secondary ray. At the primary intersection point, we ‘see’ what the secondary ray ‘sees’; i.e. the secondary ray behaves like a primary ray. We still need a shadow ray at the new intersection point to establish light transport. INFOGR – Lecture 5 – “Ray Tracing (3)” 4

slide-5
SLIDE 5

Reflected Vector

Reflection: angle of incidence equals angle of reflection. Using normalized vector 𝐸: 𝐵 = 𝐸 ∙ 𝑂 𝑂 𝐶 = 𝐸 − 𝐵 𝑆 = 𝐶 + (− 𝐵) 𝑆 = 𝐸 − 𝑂 𝐸 ∙ 𝑂 − 𝑂(𝐸 ∙ 𝑂) 𝑺 = 𝑬 − 𝟑(𝑬 ∙ 𝑶)𝑶

Reflections

INFOGR – Lecture 5 – “Ray Tracing (3)” 5 𝑶 𝛽𝑗 𝛽𝑝 𝐸 𝑆

slide-6
SLIDE 6

Reflections

Light Transport

For a pure specular reflection, the energy from a single direction is reflected into a single outgoing direction.

  • We do not apply 𝑂 ∙ 𝑀
  • We do apply absorption

Since the reflection ray requires the same functionality as a primary ray, it helps to implement this recursively.

vec3 Trace( Ray ray ) { I, N, material = scene.GetIntersection( ray ); if (material.isMirror) return material.color * Trace( … ); return DirectIllumination() * material.color; }

INFOGR – Lecture 5 – “Ray Tracing (3)” 6

slide-7
SLIDE 7

Reflections

What is the color of a bathroom mirror?

(In a ray tracer, it’s white.)

INFOGR – Lecture 5 – “Ray Tracing (3)” 7

slide-8
SLIDE 8

Reflections

Light Transport

For pure specular reflections we do not cast a shadow ray. Reason: Light arriving from that direction cannot leave in the direction

  • f the camera.

INFOGR – Lecture 5 – “Ray Tracing (3)” 8

slide-9
SLIDE 9

Reflections

INFOGR – Lecture 5 – “Ray Tracing (3)” 9

slide-10
SLIDE 10

Reflections

INFOGR – Lecture 5 – “Ray Tracing (3)” 10

Partially Reflective Surfaces

We can combine pure specularity and diffuse properties. Situation: our material is only 50% reflective. In this case, we send out the reflected ray, and multiply its yield by 0.5. We also send out a shadow ray to get direct illumination, and multiply the received light by 0.5.

slide-11
SLIDE 11

Reflections

INFOGR – Lecture 5 – “Ray Tracing (3)” 11

Reflecting a HDR Sky

A dark object can be quite bright when reflecting something bright. E.g., a bowling ball, pure specular, color = (0.01, 0.01, 0.01); reflecting a ‘sun’ stored in a HDR skydome, color = (100, 100, 100). For a collection of HDR probes, visit Paul Debevec’s page: http://www.pauldebevec.com/Probes

slide-12
SLIDE 12

Today’s Agenda:

  • Reflections
  • Refraction
  • Recursion
  • Shading models
  • TODO
slide-13
SLIDE 13

Refraction

Dielectrics

Materials such as water and glass require two types

  • f light transport:
  • 1. Transmission
  • 2. Reflection

Both of these happen at each medium boundary. INFOGR – Lecture 5 – “Ray Tracing (3)” 13

slide-14
SLIDE 14

Refraction

INFOGR – Lecture 5 – “Ray Tracing (3)” 14 𝑈 𝐸 𝑶 𝑜1 𝑜2 𝜄2 𝜄1

Dielectrics

The direction of the transmitted vector 𝑈 depends on the refraction indices 𝑜1, 𝑜2 of the media separated by the surface. According to Snell’s Law: 𝑜1𝑡𝑗𝑜𝜄1 = 𝑜2𝑡𝑗𝑜𝜄2

  • r

𝑜1 𝑜2 𝑡𝑗𝑜𝜄1 = 𝑡𝑗𝑜𝜄2 Note: left term may exceed 1, in which case 𝜄2 cannot be computed. Therefore:

𝑜1 𝑜2 𝑡𝑗𝑜𝜄1 = 𝑡𝑗𝑜𝜄2 ⟺ 𝑡𝑗𝑜𝜄1 ≤ 𝑜2 𝑜1  𝜄𝑑𝑠𝑗𝑢𝑗𝑑𝑏𝑚 = arcsin 𝑜2 𝑜1 sin 𝜄2

slide-15
SLIDE 15

Refraction

INFOGR – Lecture 5 – “Ray Tracing (3)” 15 𝑈 𝐸 𝑶 𝑜1 𝑜2 𝜄2 𝜄1

Dielectrics

𝑜1 𝑜2 𝑡𝑗𝑜𝜄1 = 𝑡𝑗𝑜𝜄2 ⟺ 𝑡𝑗𝑜𝜄1 ≤ 𝑜2 𝑜1

𝑙 = 1 − 𝑜1 𝑜2

2

1 − 𝑑𝑝𝑡𝜄1

2

𝑈 = 𝑈𝐽𝑆, 𝑔𝑝𝑠 𝑙 < 0 𝑜1 𝑜2 𝐸 + 𝑂 𝑜1 𝑜2 𝑑𝑝𝑡𝜄1 − 𝑙 , 𝑔𝑝𝑠 𝑙 ≥ 0 Note: 𝑑𝑝𝑡𝜄1 = 𝑂 ∙ −𝐸, and

𝑜1 𝑜2 should be calculated only once.

* For a full derivation, see http://www.flipcode.com/archives/reflection_transmission.pdf

slide-16
SLIDE 16

Refraction

INFOGR – Lecture 5 – “Ray Tracing (3)” 16 𝑈 𝐸 𝑶 𝑆

Dielectrics

A typical dielectric transmits and reflects light.

slide-17
SLIDE 17

Refraction

INFOGR – Lecture 5 – “Ray Tracing (3)” 17

Dielectrics

A typical dielectric transmits and reflects light. Based on the Fresnel equations, the reflectivity of the surface for non-polarized light is formulated as: 𝐺

𝑠 = 1

2 𝑜1𝑑𝑝𝑡𝜄𝑗 − 𝑜2 1 − 𝑜1 𝑜2 𝑡𝑗𝑜𝜄𝑗

2

𝑜1𝑑𝑝𝑡𝜄𝑗 + 𝑜2 1 − 𝑜1 𝑜2 𝑡𝑗𝑜𝜄𝑗

2

+ 𝑜1𝑑𝑝𝑡𝜄𝑗 − 𝑜2 1 − 𝑜1 𝑜2 𝑡𝑗𝑜𝜄𝑗

2

𝑜1𝑑𝑝𝑡𝜄𝑗 + 𝑜2 1 − 𝑜1 𝑜2 𝑡𝑗𝑜𝜄𝑗

2

slide-18
SLIDE 18

Refraction

INFOGR – Lecture 5 – “Ray Tracing (3)” 18 𝑈 𝐸 𝑶 𝑆

Dielectrics

In practice, we use Schlick’s approximation: 𝐺

𝑠 = 𝑆0 + (1 − 𝑆0)(1 − 𝑑𝑝𝑡𝜄)5, where 𝑆0 = 𝑜1−𝑜2 𝑜1+𝑜2 2

. Based on the law of conservation of energy: 𝐺𝑢 = 1 − 𝐺

𝑠

slide-19
SLIDE 19

Today’s Agenda:

  • Reflections
  • Refraction
  • Recursion
  • Shading models
  • TODO
slide-20
SLIDE 20

Recursion

INFOGR – Lecture 5 – “Ray Tracing (3)” 20 Whitted-style Ray Tracing, Pseudocode

Color Trace( vec3 O, vec3 D ) { I, N, mat = IntersectScene( O, D ); if (!I) return BLACK; return DirectIllumination( I, N ) * mat.diffuseColor; } Color DirectIllumination( vec3 I, vec3 N ) { vec3 L = lightPos – I; float dist = length( L ); L *= (1.0f / dist); if (!IsVisibile( I, L, dist )) return BLACK; float attenuation = 1 / (dist * dist); return lightColor * dot( N, L ) * attenuation; }

Todo:

  • Implement IntersectScene
  • Implement IsVisible
slide-21
SLIDE 21

Recursion

INFOGR – Lecture 5 – “Ray Tracing (3)” 21 Whitted-style Ray Tracing, Pseudocode

Color Trace( vec3 O, vec3 D ) { I, N, mat = IntersectScene( O, D ); if (!I) return BLACK; if (mat.isMirror()) { return Trace( I, reflect( D, N ) ) * mat.diffuseColor; } else { return DirectIllumination( I, N ) * mat.diffuseColor; } }

Todo: Handle partially reflective surfaces.

slide-22
SLIDE 22

Recursion

INFOGR – Lecture 5 – “Ray Tracing (3)” 22 Whitted-style Ray Tracing, Pseudocode

Color Trace( vec3 O, vec3 D ) { I, N, mat = IntersectScene( O, D ); if (!I) return BLACK; if (mat.isMirror()) { return Trace( I, reflect( D, N ) ) * mat.diffuseColor; } else if (mat.IsDielectric()) { f = Fresnel( … ); return (f * Trace( I, reflect( D, N ) ) + (1-f) * Trace( I, refract( D, N, … ) ) ) * mat.DiffuseColor; } else { return DirectIllumination( I, N ) * mat.diffuseColor; } }

Todo:

  • Implement reflect
  • Implement refract
  • Implement Fresnel
  • Cap recursion
slide-23
SLIDE 23

Recursion

INFOGR – Lecture 5 – “Ray Tracing (3)” 23 Spheres: pure specular

slide-24
SLIDE 24

Recursion

INFOGR – Lecture 5 – “Ray Tracing (3)” 24 Spheres: 50% specular

slide-25
SLIDE 25

Recursion

INFOGR – Lecture 5 – “Ray Tracing (3)” 25 Spheres: one 50% specular, one glass sphere

slide-26
SLIDE 26

Recursion

INFOGR – Lecture 5 – “Ray Tracing (3)” 26

slide-27
SLIDE 27

Recursion

INFOGR – Lecture 5 – “Ray Tracing (3)” 27

Ray Tree

Recursion, multiple light sampling and path splitting in a Whitted-style ray tracer leads to a structure that we refer to as the ray tree. All energy is ultimately transported by a single primary ray. Since the energy does not increase deeper in the tree (on the contrary), the average amount of energy transported by rays decreases with depth.

slide-28
SLIDE 28

Today’s Agenda:

  • Reflections
  • Refraction
  • Recursion
  • Shading models
  • TODO
slide-29
SLIDE 29

Shading

Diffuse Material

A diffuse material scatters incoming light in all directions. Incoming: 𝐹𝑚𝑗𝑕ℎ𝑢 ∗

1 𝑒𝑗𝑡𝑢2 ∗ 𝑂 ∙ 𝑀

Absorption: 𝐷𝑛𝑏𝑢𝑓𝑠𝑗𝑏𝑚 Reflection: (𝑊 ∙ 𝑂) Eye sees:

1 (𝑊∙𝑂)

INFOGR – Lecture 5 – “Ray Tracing (3)” 29

𝑜 terms cancel out.

A diffuse material appears the same regardless of eye position.

slide-30
SLIDE 30

Shading

Specular Material

A specular material reflects light from a particular direction in a single outgoing direction. INFOGR – Lecture 5 – “Ray Tracing (3)” 30

𝑂

slide-31
SLIDE 31

Shading

INFOGR – Lecture 5 – “Ray Tracing (3)” 31

slide-32
SLIDE 32

𝑂

Shading

Glossy Material

A glossy material reflects most light along the reflected vector. For other directions, the amount of energy is: 𝑊 ∙ 𝑆

𝛽 , where exponent 𝛽 determines

the specularity of the surface. INFOGR – Lecture 5 – “Ray Tracing (3)” 32 𝑆 𝑀 𝑺 = 𝑴 − 𝟑(𝑴 ∙ 𝑶)𝑶 𝑾

slide-33
SLIDE 33

Shading

Phong Shading

Complex materials can be obtained by blending diffuse and glossy. 𝐽 = 𝐷𝑛𝑏𝑢𝑓𝑠𝑗𝑏𝑚 ∗ 1 − 𝑔

𝑡𝑞𝑓𝑑

𝑂 ∙ 𝑀 + 𝑔

𝑡𝑞𝑓𝑑 𝑊 ∙ 𝑆 𝛽

where 𝛽 is the specularity of the glossy reflection; 𝑔

𝑡𝑞𝑓𝑑

is the glossy part of the reflection; 1 − 𝑔

𝑡𝑞𝑓𝑑 is the diffuse part of the reflection.

Note that the glossy reflection only reflects light sources. INFOGR – Lecture 5 – “Ray Tracing (3)” 33

slide-34
SLIDE 34

Today’s Agenda:

  • Reflections
  • Refraction
  • Recursion
  • Shading models
  • TODO
slide-35
SLIDE 35

TODO

Limitations of Whitted-style

INFOGR – Lecture 5 – “Ray Tracing (3)” 35

slide-36
SLIDE 36

TODO

Limitations of Whitted-style

INFOGR – Lecture 5 – “Ray Tracing (3)” 36

slide-37
SLIDE 37

TODO

Limitations of Whitted-style

INFOGR – Lecture 5 – “Ray Tracing (3)” 37

slide-38
SLIDE 38

TODO

Limitations of Whitted-style

INFOGR – Lecture 5 – “Ray Tracing (3)” 38

slide-39
SLIDE 39

TODO

Limitations of Whitted-style

INFOGR – Lecture 5 – “Ray Tracing (3)” 39

slide-40
SLIDE 40
slide-41
SLIDE 41

INFOGR – Computer Graphics

Jacco Bikker - April-July 2016 - Lecture 5: “Ray Tracing (3)”

END of “Ray Tracing (3)”

next lecture: “Boxes”