indirect illuminationmisha/fall20/09.pdf · 2020. 9. 22. · summary. • ray casting (direct...

60
Indirect Illumination Michael Kazhdan (601.457/657) HB Ch. 14.1, 14.2 FvDFH 16.1, 16.2

Upload: others

Post on 07-Mar-2021

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Indirect Illumination

Michael Kazhdan

(601.457/657)

HB Ch. 14.1, 14.2

FvDFH 16.1, 16.2

Page 2: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Surface Illumination Calculation• Multiple light source:

𝑁𝑁

𝐿𝐿1

𝐿𝐿2

𝑉𝑉

Viewer

𝐼𝐼 = 𝐼𝐼𝐸𝐸 + �𝐿𝐿

𝐾𝐾𝐴𝐴 ⋅ 𝐼𝐼𝐿𝐿𝐴𝐴 + 𝐾𝐾𝐷𝐷 ⋅ 𝑁𝑁, 𝐿𝐿 + 𝐾𝐾𝑆𝑆 ⋅ 𝑉𝑉,𝑅𝑅 𝑛𝑛 ⋅ 𝐼𝐼𝐿𝐿

Page 3: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Overview• Direct Illumination

Emission at light sources Direct light at surface points

• Global illumination Shadows Transmissions Inter-object reflections

Page 4: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Shadows• Shadow term tells if light sources are blocked

Cast ray towards each light source 𝐿𝐿𝑖𝑖 If the ray is blocked, do not consider the contribution of

the light.

Page 5: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Shadows• Shadow term tells if light sources are blocked

Cast ray towards each light source 𝐿𝐿𝑖𝑖 𝑆𝑆𝑖𝑖 = 0 if ray is blocked, 𝑆𝑆𝑖𝑖 = 1 otherwise

𝐿𝐿1

𝐿𝐿0

𝐼𝐼 = 𝐼𝐼𝐸𝐸 + �𝐿𝐿

𝐾𝐾𝐴𝐴 ⋅ 𝐼𝐼𝐿𝐿𝐴𝐴 + 𝐾𝐾𝐷𝐷 ⋅ 𝑁𝑁, 𝐿𝐿 + 𝐾𝐾𝑆𝑆 ⋅ 𝑉𝑉,𝑅𝑅 𝑛𝑛 ⋅ 𝐼𝐼𝐿𝐿 ⋅ 𝑆𝑆𝐿𝐿

ShadowTerm

Page 6: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

• Shadow term tells if light sources are blocked Cast ray towards each light source 𝐿𝐿𝑖𝑖 𝑆𝑆𝑖𝑖 = 0 if ray is blocked, 𝑆𝑆𝑖𝑖 = 1 otherwise

Shadows

𝑆𝑆0 = 1:𝐿𝐿0 contributes

𝐼𝐼 = 𝐼𝐼𝐸𝐸 + �𝐿𝐿

𝐾𝐾𝐴𝐴 ⋅ 𝐼𝐼𝐿𝐿𝐴𝐴 + 𝐾𝐾𝐷𝐷 ⋅ 𝑁𝑁, 𝐿𝐿 + 𝐾𝐾𝑆𝑆 ⋅ 𝑉𝑉,𝑅𝑅 𝑛𝑛 ⋅ 𝐼𝐼𝐿𝐿 ⋅ 𝑆𝑆𝐿𝐿

ShadowTerm

𝐿𝐿1

𝐿𝐿0

Page 7: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

• Shadow term tells if light sources are blocked Cast ray towards each light source 𝐿𝐿𝑖𝑖 𝑆𝑆𝑖𝑖 = 0 if ray is blocked, 𝑆𝑆𝑖𝑖 = 1 otherwise

Shadows

𝐼𝐼 = 𝐼𝐼𝐸𝐸 + �𝐿𝐿

𝐾𝐾𝐴𝐴 ⋅ 𝐼𝐼𝐿𝐿𝐴𝐴 + 𝐾𝐾𝐷𝐷 ⋅ 𝑁𝑁, 𝐿𝐿 + 𝐾𝐾𝑆𝑆 ⋅ 𝑉𝑉,𝑅𝑅 𝑛𝑛 ⋅ 𝐼𝐼𝐿𝐿 ⋅ 𝑆𝑆𝐿𝐿

ShadowTerm

𝐿𝐿1

𝐿𝐿0

𝑆𝑆0 = 1:𝐿𝐿0 contributes

𝑆𝑆1 = 0:𝐿𝐿1 doesn’t contribute

Page 8: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Ray Casting• Trace primary rays from camera

Direct illumination from unblocked lights only

Page 9: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Recursive Ray Tracing• Also trace secondary rays from hit surfaces

Consider contributions from:1. Reflected Rays2. Refracted Rays

Page 10: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

• Also trace secondary rays from hit surfaces Consider contributions from:

1. Reflected Rays2. Refracted Rays

Mirror Reflections

𝐿𝐿1

Recall:The specularity of a surface, 𝐾𝐾𝑆𝑆, measures how mirror-like it is.

𝐼𝐼 = 𝐼𝐼𝐸𝐸 + �𝐿𝐿

𝐾𝐾𝐴𝐴 ⋅ 𝐼𝐼𝐿𝐿𝐴𝐴 + 𝐾𝐾𝐷𝐷 ⋅ 𝑁𝑁, 𝐿𝐿 + 𝐾𝐾𝑆𝑆 ⋅ 𝑉𝑉,𝑅𝑅 𝑛𝑛 ⋅ 𝐼𝐼𝐿𝐿 ⋅ 𝑆𝑆𝐿𝐿

𝐿𝐿0

Page 11: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

• Also trace secondary rays from hit surfaces Consider contributions from:

1. Reflected Rays2. Refracted Rays

Mirror Reflections

𝐿𝐿1

𝐿𝐿0

𝐼𝐼 = 𝐼𝐼𝐸𝐸 + �𝐿𝐿

𝐾𝐾𝐴𝐴 ⋅ 𝐼𝐼𝐿𝐿𝐴𝐴 + 𝐾𝐾𝐷𝐷 ⋅ 𝑁𝑁, 𝐿𝐿 + 𝐾𝐾𝑆𝑆 ⋅ 𝑉𝑉,𝑅𝑅 𝑛𝑛 ⋅ 𝐼𝐼𝐿𝐿 ⋅ 𝑆𝑆𝐿𝐿 + 𝐾𝐾𝑠𝑠 ⋅ 𝐼𝐼𝑅𝑅

Radiance for mirror

reflection ray

Page 12: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

• Also trace secondary rays from hit surfaces Consider contributions from:

1. Reflected Rays2. Refracted Rays

Mirror Reflections

𝐿𝐿1

𝐿𝐿0

𝐼𝐼 = 𝐼𝐼𝐸𝐸 + �𝐿𝐿

𝐾𝐾𝐴𝐴 ⋅ 𝐼𝐼𝐿𝐿𝐴𝐴 + 𝐾𝐾𝐷𝐷 ⋅ 𝑁𝑁, 𝐿𝐿 + 𝐾𝐾𝑆𝑆 ⋅ 𝑉𝑉,𝑅𝑅 𝑛𝑛 ⋅ 𝐼𝐼𝐿𝐿 ⋅ 𝑆𝑆𝐿𝐿 + 𝐾𝐾𝑠𝑠 ⋅ 𝐼𝐼𝑅𝑅

Radiance for mirror

reflection ray

Page 13: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

• Also trace secondary rays from hit surfaces Consider contributions from:

1. Reflected Rays2. Refracted Rays

Mirror Reflections

𝐿𝐿1

𝐿𝐿0

𝐼𝐼 = 𝐼𝐼𝐸𝐸 + �𝐿𝐿

𝐾𝐾𝐴𝐴 ⋅ 𝐼𝐼𝐿𝐿𝐴𝐴 + 𝐾𝐾𝐷𝐷 ⋅ 𝑁𝑁, 𝐿𝐿 + 𝐾𝐾𝑆𝑆 ⋅ 𝑉𝑉,𝑅𝑅 𝑛𝑛 ⋅ 𝐼𝐼𝐿𝐿 ⋅ 𝑆𝑆𝐿𝐿 + 𝐾𝐾𝑠𝑠 ⋅ 𝐼𝐼𝑅𝑅

Radiance for mirror

reflection ray

Page 14: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Mirror Reflections• Also trace secondary rays from hit surfaces

Consider contributions from:1. Reflected Rays2. Refracted Rays

Page 15: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Transparent Refraction• Also trace secondary rays from hit surfaces

Consider contributions from:1. Reflected Rays2. Refracted Rays

Radiance for refraction ray

𝐼𝐼 = 𝐼𝐼𝐸𝐸 + �𝐿𝐿

𝐾𝐾𝐴𝐴 ⋅ 𝐼𝐼𝐿𝐿𝐴𝐴 + 𝐾𝐾𝐷𝐷 ⋅ 𝑁𝑁, 𝐿𝐿 + 𝐾𝐾𝑆𝑆 ⋅ 𝑉𝑉,𝑅𝑅 𝑛𝑛 ⋅ 𝐼𝐼𝐿𝐿 ⋅ 𝑆𝑆𝐿𝐿 + 𝐾𝐾𝑠𝑠 ⋅ 𝐼𝐼𝑅𝑅 + 𝐾𝐾𝑇𝑇 ⋅ 𝐼𝐼𝑇𝑇

𝐿𝐿1

𝐿𝐿0

Page 16: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Transparent Refraction• Also trace secondary rays from hit surfaces

Consider contributions from:1. Reflected Rays2. Refracted Rays

𝐿𝐿1

𝐿𝐿0

Radiance for refraction ray

𝐼𝐼 = 𝐼𝐼𝐸𝐸 + �𝐿𝐿

𝐾𝐾𝐴𝐴 ⋅ 𝐼𝐼𝐿𝐿𝐴𝐴 + 𝐾𝐾𝐷𝐷 ⋅ 𝑁𝑁, 𝐿𝐿 + 𝐾𝐾𝑆𝑆 ⋅ 𝑉𝑉,𝑅𝑅 𝑛𝑛 ⋅ 𝐼𝐼𝐿𝐿 ⋅ 𝑆𝑆𝐿𝐿 + 𝐾𝐾𝑠𝑠 ⋅ 𝐼𝐼𝑅𝑅 + 𝐾𝐾𝑇𝑇 ⋅ 𝐼𝐼𝑇𝑇

Page 17: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Transparent Refraction• Also trace secondary rays from hit surfaces

Consider contributions from:1. Reflected Rays2. Refracted Rays

𝐿𝐿1

𝐿𝐿0

Radiance for refraction ray

𝐼𝐼 = 𝐼𝐼𝐸𝐸 + �𝐿𝐿

𝐾𝐾𝐴𝐴 ⋅ 𝐼𝐼𝐿𝐿𝐴𝐴 + 𝐾𝐾𝐷𝐷 ⋅ 𝑁𝑁, 𝐿𝐿 + 𝐾𝐾𝑆𝑆 ⋅ 𝑉𝑉,𝑅𝑅 𝑛𝑛 ⋅ 𝐼𝐼𝐿𝐿 ⋅ 𝑆𝑆𝐿𝐿 + 𝐾𝐾𝑠𝑠 ⋅ 𝐼𝐼𝑅𝑅 + 𝐾𝐾𝑇𝑇 ⋅ 𝐼𝐼𝑇𝑇

Page 18: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Transparent Refraction• Also trace secondary rays from hit surfaces

Consider contributions from:1. Reflected Rays2. Refracted Rays

𝐿𝐿1

𝐿𝐿0

Radiance for refraction ray

𝐼𝐼 = 𝐼𝐼𝐸𝐸 + �𝐿𝐿

𝐾𝐾𝐴𝐴 ⋅ 𝐼𝐼𝐿𝐿𝐴𝐴 + 𝐾𝐾𝐷𝐷 ⋅ 𝑁𝑁, 𝐿𝐿 + 𝐾𝐾𝑆𝑆 ⋅ 𝑉𝑉,𝑅𝑅 𝑛𝑛 ⋅ 𝐼𝐼𝐿𝐿 ⋅ 𝑆𝑆𝐿𝐿 + 𝐾𝐾𝑠𝑠 ⋅ 𝐼𝐼𝑅𝑅 + 𝐾𝐾𝑇𝑇 ⋅ 𝐼𝐼𝑇𝑇

Page 19: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Transparent Refraction• Also trace secondary rays from hit surfaces

Consider contributions from:1. Reflected Rays2. Refracted Rays

𝐿𝐿1

𝐿𝐿0

Radiance for refraction ray

𝐼𝐼 = 𝐼𝐼𝐸𝐸 + �𝐿𝐿

𝐾𝐾𝐴𝐴 ⋅ 𝐼𝐼𝐿𝐿𝐴𝐴 + 𝐾𝐾𝐷𝐷 ⋅ 𝑁𝑁, 𝐿𝐿 + 𝐾𝐾𝑆𝑆 ⋅ 𝑉𝑉,𝑅𝑅 𝑛𝑛 ⋅ 𝐼𝐼𝐿𝐿 ⋅ 𝑆𝑆𝐿𝐿 + 𝐾𝐾𝑠𝑠 ⋅ 𝐼𝐼𝑅𝑅 + 𝐾𝐾𝑇𝑇 ⋅ 𝐼𝐼𝑇𝑇

Page 20: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Transparent Refraction• Also trace secondary rays from hit surfaces

Consider contributions from:1. Reflected Rays2. Refracted Rays

Page 21: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Transparency and Shadow• Problem:

If a surface is transparent, then rays to the light source may pass through the object

Over-shadowing

Page 22: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Transparency and Shadow• Problem:

If a surface is transparent, then rays to the light source may pass through the object

Need to modify the shadow term so that instead of representing a binary (0/1) value, it gives the fraction of light passing through.

⇒ Accumulate transparency values as the ray travels to the light source.

𝐼𝐼 = 𝐼𝐼𝐸𝐸 + �𝐿𝐿

𝐾𝐾𝐴𝐴 ⋅ 𝐼𝐼𝐿𝐿𝐴𝐴 + 𝐾𝐾𝐷𝐷 ⋅ 𝑁𝑁, 𝐿𝐿 + 𝐾𝐾𝑆𝑆 ⋅ 𝑉𝑉,𝑅𝑅 𝑛𝑛 ⋅ 𝐼𝐼𝐿𝐿 ⋅ 𝑆𝑆𝐿𝐿 + 𝐾𝐾𝑠𝑠 ⋅ 𝐼𝐼𝑅𝑅 + 𝐾𝐾𝑇𝑇 ⋅ 𝐼𝐼𝑇𝑇

Page 23: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Transparency and Shadow• Accumulate transparency values as the ray

travels to the light source.

𝑆𝑆0 = 1:𝐿𝐿0 contributes fully

𝐼𝐼 = 𝐼𝐼𝐸𝐸 + �𝐿𝐿

𝐾𝐾𝐴𝐴 ⋅ 𝐼𝐼𝐿𝐿𝐴𝐴 + 𝐾𝐾𝐷𝐷 ⋅ 𝑁𝑁, 𝐿𝐿 + 𝐾𝐾𝑆𝑆 ⋅ 𝑉𝑉,𝑅𝑅 𝑛𝑛 ⋅ 𝐼𝐼𝐿𝐿 ⋅ 𝑆𝑆𝐿𝐿 + 𝐾𝐾𝑠𝑠 ⋅ 𝐼𝐼𝑅𝑅 + 𝐾𝐾𝑇𝑇 ⋅ 𝐼𝐼𝑇𝑇

𝐿𝐿1

𝐿𝐿0

Page 24: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Transparency and Shadow• Accumulate transparency values as the ray

travels to the light source.

𝐿𝐿1

𝐿𝐿0

𝑆𝑆0 = 1:𝐿𝐿0 contributes fully

𝑆𝑆1 =?:

𝐼𝐼 = 𝐼𝐼𝐸𝐸 + �𝐿𝐿

𝐾𝐾𝐴𝐴 ⋅ 𝐼𝐼𝐿𝐿𝐴𝐴 + 𝐾𝐾𝐷𝐷 ⋅ 𝑁𝑁, 𝐿𝐿 + 𝐾𝐾𝑆𝑆 ⋅ 𝑉𝑉,𝑅𝑅 𝑛𝑛 ⋅ 𝐼𝐼𝐿𝐿 ⋅ 𝑆𝑆𝐿𝐿 + 𝐾𝐾𝑠𝑠 ⋅ 𝐼𝐼𝑅𝑅 + 𝐾𝐾𝑇𝑇 ⋅ 𝐼𝐼𝑇𝑇

Page 25: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Transparency and Shadow• Accumulate transparency values as the ray

travels to the light source.

𝐾𝐾𝑇𝑇

𝐿𝐿1

𝐿𝐿0

𝑆𝑆0 = 1:𝐿𝐿0 contributes fully

𝑆𝑆1 = 1 ⋅ 𝐾𝐾𝑇𝑇 ⋅?:

𝐼𝐼 = 𝐼𝐼𝐸𝐸 + �𝐿𝐿

𝐾𝐾𝐴𝐴 ⋅ 𝐼𝐼𝐿𝐿𝐴𝐴 + 𝐾𝐾𝐷𝐷 ⋅ 𝑁𝑁, 𝐿𝐿 + 𝐾𝐾𝑆𝑆 ⋅ 𝑉𝑉,𝑅𝑅 𝑛𝑛 ⋅ 𝐼𝐼𝐿𝐿 ⋅ 𝑆𝑆𝐿𝐿 + 𝐾𝐾𝑠𝑠 ⋅ 𝐼𝐼𝑅𝑅 + 𝐾𝐾𝑇𝑇 ⋅ 𝐼𝐼𝑇𝑇

Page 26: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Transparency and Shadow• Accumulate transparency values as the ray

travels to the light source.

𝐾𝐾𝑇𝑇

𝐿𝐿1

𝐿𝐿0

𝑆𝑆0 = 1:𝐿𝐿0 contributes fully

𝑆𝑆1 = 1 ⋅ 𝐾𝐾𝑇𝑇 ⋅ 𝐾𝐾𝑇𝑇 ⋅?:

𝐼𝐼 = 𝐼𝐼𝐸𝐸 + �𝐿𝐿

𝐾𝐾𝐴𝐴 ⋅ 𝐼𝐼𝐿𝐿𝐴𝐴 + 𝐾𝐾𝐷𝐷 ⋅ 𝑁𝑁, 𝐿𝐿 + 𝐾𝐾𝑆𝑆 ⋅ 𝑉𝑉,𝑅𝑅 𝑛𝑛 ⋅ 𝐼𝐼𝐿𝐿 ⋅ 𝑆𝑆𝐿𝐿 + 𝐾𝐾𝑠𝑠 ⋅ 𝐼𝐼𝑅𝑅 + 𝐾𝐾𝑇𝑇 ⋅ 𝐼𝐼𝑇𝑇

Page 27: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Transparency and Shadow• Accumulate transparency values as the ray

travels to the light source.

𝐾𝐾𝑇𝑇

𝐿𝐿1

𝐿𝐿0

𝑆𝑆0 = 1:𝐿𝐿0 contributes fully

𝑆𝑆1 = 1 ⋅ 𝐾𝐾𝑇𝑇 ⋅ 𝐾𝐾𝑇𝑇:𝐿𝐿1 contributes partially

𝐼𝐼 = 𝐼𝐼𝐸𝐸 + �𝐿𝐿

𝐾𝐾𝐴𝐴 ⋅ 𝐼𝐼𝐿𝐿𝐴𝐴 + 𝐾𝐾𝐷𝐷 ⋅ 𝑁𝑁, 𝐿𝐿 + 𝐾𝐾𝑆𝑆 ⋅ 𝑉𝑉,𝑅𝑅 𝑛𝑛 ⋅ 𝐼𝐼𝐿𝐿 ⋅ 𝑆𝑆𝐿𝐿 + 𝐾𝐾𝑠𝑠 ⋅ 𝐼𝐼𝑅𝑅 + 𝐾𝐾𝑇𝑇 ⋅ 𝐼𝐼𝑇𝑇

Page 28: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Transparency and Shadow• Accumulate transparency values as the ray

travels to the light source.

KT

𝐿𝐿1

𝐿𝐿0

For solid models we can use the distance, 𝑑𝑑, travelled through the

surface instead: 𝑆𝑆 = 𝑒𝑒−𝑑𝑑⋅𝐾𝐾𝑇𝑇

𝑆𝑆0 = 1:𝐿𝐿0 contributes fully

𝑆𝑆1 = 1 ⋅ 𝐾𝐾𝑇𝑇 ⋅ 𝐾𝐾𝑇𝑇:𝐿𝐿1 contributes partially

𝐼𝐼 = 𝐼𝐼𝐸𝐸 + �𝐿𝐿

𝐾𝐾𝐴𝐴 ⋅ 𝐼𝐼𝐿𝐿𝐴𝐴 + 𝐾𝐾𝐷𝐷 ⋅ 𝑁𝑁, 𝐿𝐿 + 𝐾𝐾𝑆𝑆 ⋅ 𝑉𝑉,𝑅𝑅 𝑛𝑛 ⋅ 𝐼𝐼𝐿𝐿 ⋅ 𝑆𝑆𝐿𝐿 + 𝐾𝐾𝑠𝑠 ⋅ 𝐼𝐼𝑅𝑅 + 𝐾𝐾𝑇𝑇 ⋅ 𝐼𝐼𝑇𝑇

Page 29: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Transparency and Shadow• Accumulate transparency values as the ray

travels to the light source.

Page 30: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Transparent Refraction• When a light of light passes through a transparent

object, the ray of light can bend, (𝜃𝜃𝑖𝑖 ≠ 𝜃𝜃𝑟𝑟).

𝑁𝑁

𝐿𝐿

𝑇𝑇

𝜃𝜃𝑖𝑖

𝜃𝜃𝑟𝑟

Page 31: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Snell’s Law• The way that light bends is determined by the

indices of refraction of the internal and external materials 𝜂𝜂𝑖𝑖 and 𝜂𝜂𝑟𝑟:

The index of refraction of air is 𝜂𝜂 = 1.

𝑁𝑁

𝐿𝐿

𝑇𝑇

𝜃𝜃𝑖𝑖

𝜃𝜃𝑟𝑟

𝜂𝜂𝑟𝑟 ⋅ sin𝜃𝜃𝑟𝑟 = 𝜂𝜂𝑖𝑖 ⋅ sin𝜃𝜃𝑖𝑖

Page 32: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Snell’s Law• The way that light bends is determined by the

indices of refraction of the internal and external materials 𝜂𝜂𝑖𝑖 and 𝜂𝜂𝑟𝑟: 𝑁𝑁

𝐿𝐿

𝑇𝑇

𝜃𝜃𝑖𝑖

𝜃𝜃𝑟𝑟

𝜂𝜂𝑟𝑟 ⋅ sin𝜃𝜃𝑟𝑟 = 𝜂𝜂𝑖𝑖 ⋅ sin𝜃𝜃𝑖𝑖

Note (Critical Angle):

If 𝜂𝜂𝑖𝑖 > 𝜂𝜂𝑟𝑟 it is possible that 𝜂𝜂𝑖𝑖𝜂𝜂𝑟𝑟⋅ sin𝜃𝜃𝑖𝑖 > 1.

In this case:• There is no value of 𝜃𝜃𝑟𝑟 such that 𝜂𝜂𝑟𝑟 ⋅ sin𝜃𝜃𝑟𝑟 = 𝜂𝜂𝑖𝑖 ⋅ sin𝜃𝜃𝑖𝑖.• The light reflects off the surface and does not pass through.

Page 33: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Snell’s Law• The way that light bends is determined by the

indices of refraction of the internal and external materials 𝜂𝜂𝑖𝑖 and 𝜂𝜂𝑟𝑟: 𝑁𝑁

𝐿𝐿

𝑇𝑇

𝜃𝜃𝑖𝑖

𝜃𝜃𝑟𝑟

𝑇𝑇 =𝜂𝜂𝑖𝑖𝜂𝜂𝑟𝑟⋅ cos𝜃𝜃𝑖𝑖 − cos𝜃𝜃𝑟𝑟 ⋅ 𝑁𝑁 −

𝜂𝜂𝑖𝑖𝜂𝜂𝑟𝑟⋅ 𝐿𝐿

𝜂𝜂𝑟𝑟 ⋅ sin𝜃𝜃𝑟𝑟 = 𝜂𝜂𝑖𝑖 ⋅ sin𝜃𝜃𝑖𝑖

Page 34: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Snell’s Law• The way that light bends is determined by the

indices of refraction of the internal and external materials 𝜂𝜂𝑖𝑖 and 𝜂𝜂𝑟𝑟:

𝐿𝐿1

𝐿𝐿0

𝜂𝜂𝑟𝑟 ⋅ sin𝜃𝜃𝑟𝑟 = 𝜂𝜂𝑖𝑖 ⋅ sin𝜃𝜃𝑖𝑖

Page 35: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Snell’s Law• The way that light bends is determined by the

indices of refraction of the internal and external materials 𝜂𝜂𝑖𝑖 and 𝜂𝜂𝑟𝑟:

Page 36: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Snell’s Law and Caustics• Challenge:

If a surface is transparent, then rays to the light source may not travel along straight paths

⇒ For a given point of intersection, there may be multiple directions/paths a ray can travel to get to the light

⇒ Summing the intensity contribution from all of theses directions/paths we get bright caustics

This is difficult to address with ray-tracing

https://en.wikipedia.org/wiki/Caustic_(optics)

Page 37: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

(Rough) Complexity Analysis• Simulating reflection and refraction in the ray

tracer, a ray splits into two at each bounce

𝐿𝐿1

𝐿𝐿0

CastReflectedRefracted

Page 38: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

(Rough) Complexity Analysis• Simulating reflection and refraction in the ray

tracer, a ray splits into two at each bounce

𝐿𝐿1

𝐿𝐿0

CastReflectedRefracted

Page 39: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

(Rough) Complexity Analysis• Simulating reflection and refraction in the ray

tracer, a ray splits into two at each bounce

𝐿𝐿1

𝐿𝐿0

CastReflectedRefracted

Page 40: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

(Rough) Complexity Analysis• Simulating reflection and refraction in the ray

tracer, a ray splits into two at each bounce

𝐿𝐿1

𝐿𝐿0

CastReflectedRefracted

Page 41: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

(Rough) Complexity Analysis• Simulating reflection and refraction in the ray

tracer, a ray splits into two at each bounce

𝐿𝐿1

𝐿𝐿0

CastReflectedRefracted

Page 42: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

(Rough) Complexity Analysis• Simulating reflection and refraction in the ray

tracer, a ray splits into two at each bounce

𝐿𝐿1

𝐿𝐿0

CastReflectedRefracted

Page 43: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

(Rough) Complexity Analysis• Simulating reflection and refraction in the ray

tracer, a ray splits into two at each bounce

⇒ Exponential growth in the number of rays as a function of the number of bounces

𝐿𝐿1

𝐿𝐿0

Note that we do not cast reflected rays from the interior of a shape.That is, if the dot-product of the surface normal

with the ray direction is positive

CastReflectedRefracted

Page 44: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Termination Criteria• How do we determine when to stop recursing?

If the ray bounces around too much If the contribution will be too small

Page 45: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Termination CriteriaPixel GetColor( scene , ray , ir , depth , cutOff ){

Pixel p(0,0,0)Ray reflect, refractIntersection hit = FindIntersection( ray , scene )if ( hit ){

p += GetSurfaceColor( hit.position )

reflect.direction = Reflect( ray.direction , hit.normal )reflect.position = hit.position + reflect.direction*εif( depth >0 && hit.kSpec>cutOff )

p += GetColor( scene , reflect , ir , depth-1 , cutOff/hit.kSpec )*hit.kSpec

refract.direction = Refract( ray.direction , hit.normal , ir , hit.ir )refract.position = hit.position + refract.direction*εif( depth >0 && hit.kTran>cutOff )

p += GetColor( scene , refract , hit.ir , depth-1 , cutOff/hit.kTran )*hit.kTran}return p

}

Page 46: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Pixel GetColor( scene , ray , ir , depth , cutOff ){

Pixel p(0,0,0)Ray reflect, refractIntersection hit = FindIntersection( ray , scene )if ( hit ){

p += GetSurfaceColor( hit.position )

reflect.direction = Reflect( ray.direction , hit.normal )reflect.position = hit.position + reflect.direction*εif( depth >0 && hit.kSpec>cutOff )

p += GetColor( scene , reflect , ir , depth-1 , cutOff/hit.kSpec )*hit.kSpec

refract.direction = Refract( ray.direction , hit.normal , ir , hit.ir )refract.position = hit.position + refract.direction*εif( depth >0 && hit.kTran>cutOff )

p += GetColor( scene , refract , hit.ir , depth-1 , cutOff/hit.kTran ) *hit.kTran}return p

}

Termination Criteria

𝐼𝐼 = 𝐼𝐼𝐸𝐸 + �𝐿𝐿

𝐾𝐾𝐴𝐴 ⋅ 𝐼𝐼𝐿𝐿𝐴𝐴 + 𝐾𝐾𝐷𝐷 ⋅ 𝑁𝑁, 𝐿𝐿 + 𝐾𝐾𝑆𝑆 ⋅ 𝑉𝑉,𝑅𝑅 𝑛𝑛 ⋅ 𝐼𝐼𝐿𝐿 ⋅ 𝑆𝑆𝐿𝐿 + 𝐾𝐾𝑠𝑠 ⋅ 𝐼𝐼𝑅𝑅 + 𝐾𝐾𝑇𝑇 ⋅ 𝐼𝐼𝑇𝑇

Page 47: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Pixel GetColor( scene , ray , ir , depth , cutOff ){

Pixel p(0,0,0)Ray reflect, refractIntersection hit = FindIntersection( ray , scene )if ( hit ){

p += GetSurfaceColor( hit.position )

reflect.direction = Reflect( ray.direction , hit.normal )reflect.position = hit.position + reflect.direction*εif( depth>0 && hit.kSpec>cutOff )

p += GetColor( scene , reflect , ir , depth-1 , cutOff/hit.kSpec )*hit.kSpec

refract.direction = Refract( ray.direction , hit.normal , ir , hit.ir )refract.position = hit.position + refract.direction*εif( depth >0 && hit.kTran>cutOff )

p += GetColor( scene , refract , hit.ir , depth-1 , cutOff/hit.kTran ) *hit.kTran}return p

}

Termination Criteria

𝐼𝐼 = 𝐼𝐼𝐸𝐸 + �𝐿𝐿

𝐾𝐾𝐴𝐴 ⋅ 𝐼𝐼𝐿𝐿𝐴𝐴 + 𝐾𝐾𝐷𝐷 ⋅ 𝑁𝑁, 𝐿𝐿 + 𝐾𝐾𝑆𝑆 ⋅ 𝑉𝑉,𝑅𝑅 𝑛𝑛 ⋅ 𝐼𝐼𝐿𝐿 ⋅ 𝑆𝑆𝐿𝐿 + 𝐾𝐾𝑠𝑠 ⋅ 𝐼𝐼𝑅𝑅 + 𝐾𝐾𝑇𝑇 ⋅ 𝐼𝐼𝑇𝑇

Page 48: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

if( depth>0 && hit.kSpec>cutOff )

p += GetColor( scene , reflect , ir , depth-1 , cutOff/hit.kSpec )*hit.kSpec;

The first reflected ray should be cast if it cancontribute an intensity greater than the cut-off.

⇒ 𝐾𝐾𝑆𝑆1 > cut-off

Termination Criteria

𝐿𝐿1

𝐿𝐿0

𝐾𝐾𝑆𝑆1

Page 49: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

if( depth>0 && hit.kSpec>cutOff )

p += GetColor( scene , reflect , ir , depth-1 , cutOff/hit.kSpec )*hit.kSpec;

The second reflected ray should be cast if it cancontribute an intensity greater than the cut-off.

⇒ 𝐾𝐾𝑆𝑆2 ⋅ 𝐾𝐾𝑆𝑆1 > cut-off

⇔ 𝐾𝐾𝑆𝑆2 > cut-off𝐾𝐾𝑆𝑆1

Termination Criteria

𝐿𝐿1

𝐿𝐿0

𝐾𝐾𝑆𝑆1

𝐾𝐾𝑆𝑆2

Page 50: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

if( depth>0 && hit.kSpec>cutOff )

p += GetColor( scene , reflect , ir , depth-1 , cutOff/hit.kSpec )*hit.kSpec;

The second reflected ray should be cast if it cancontribute an intensity greater than the cut-off.

⇒ 𝐾𝐾𝑆𝑆2 ⋅ 𝐾𝐾𝑆𝑆1 > cut-off

⇔ 𝐾𝐾𝑆𝑆2 > cut-off𝐾𝐾𝑆𝑆1

⇒ The second reflected rayshould be cast if it can reflectat least cut-off

𝐾𝐾𝑆𝑆1 of the local intensity

Termination Criteria

𝐿𝐿1

𝐿𝐿0

𝐾𝐾𝑆𝑆1

𝐾𝐾𝑆𝑆2

Page 51: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Pixel GetColor( scene , ray , ir , depth , cutOff ){

Pixel p(0,0,0)Ray reflect, refractIntersection hit = FindIntersection( ray , scene )if ( hit ){

p += GetSurfaceColor( hit.position )

reflect.direction = Reflect( ray.direction , hit.normal )reflect.position = hit.position + reflect.direction*εif( depth>0 && hit.kSpec>cutOff )

p += GetColor( scene , reflect , ir , depth-1 , cutOff/hit.kSpec )*hit.kSpec

refract.direction = Refract( ray.direction , hit.normal , ir , hit.ir )refract.position = hit.position + refract.direction*εif( depth>0 && hit.kTran>cutOff )

p += GetColor( scene , refract , hit.ir , depth-1 , cutOff/hit.kTran )*hit.kTran}return p

}

Termination Criteria

𝐼𝐼 = 𝐼𝐼𝐸𝐸 + �𝐿𝐿

𝐾𝐾𝐴𝐴 ⋅ 𝐼𝐼𝐿𝐿𝐴𝐴 + 𝐾𝐾𝐷𝐷 ⋅ 𝑁𝑁, 𝐿𝐿 + 𝐾𝐾𝑆𝑆 ⋅ 𝑉𝑉,𝑅𝑅 𝑛𝑛 ⋅ 𝐼𝐼𝐿𝐿 ⋅ 𝑆𝑆𝐿𝐿 + 𝐾𝐾𝑠𝑠 ⋅ 𝐼𝐼𝑅𝑅 + 𝐾𝐾𝑇𝑇 ⋅ 𝐼𝐼𝑇𝑇

Page 52: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Pixel GetColor( scene , ray , ir , depth , cutOff ){

Pixel p(0,0,0)Ray reflect, refractIntersection hit = FindIntersection( ray , scene )if ( hit ){

p += GetSurfaceColor( hit.position )

reflect.direction = Reflect( ray.direction , hit.normal )reflect.position = hit.position + reflect.direction*εif( depth>0 && hit.kSpec>cutOff )

p += GetColor( scene , reflect , ir , depth-1 , cutOff/hit.kSpec )*hit.kSpec

refract.direction = Refract( ray.direction , hit.normal , ir , hit.ir )refract.position = hit.position + refract.direction*εif( depth>0 && hit.kTran>cutOff )

p += GetColor( scene , refract , hit.ir , depth-1 , cutOff/hit.kTran )*hit.kTran}return p

}

Termination Criteria

Why do we add a small amount of the direction to the position?

To ensure that the new ray does not hit its starting location!

Page 53: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Pixel GetColor( scene , ray , ir , depth , cutOff ){

Pixel p(0,0,0)Ray reflect, refractIntersection hit = FindIntersection( ray , scene )if ( hit ){

p += GetSurfaceColor( hit.position )

reflect.direction = Reflect( ray.direction , hit.normal )reflect.position = hit.position + reflect.direction*εif( depth>0 && hit.kSpec>cutOff )

p += GetColor( scene , reflect , ir , depth-1 , cutOff/hit.kSpec )*hit.kSpec

refract.direction = Refract( ray.direction , hit.normal , ir , hit.ir )refract.position = hit.position + refract.direction*εif( depth>0 && hit.kTran>cutOff )

p += GetColor( scene , refract , hit.ir , depth-1 , cutOff/hit.kTran )*hit.kTran}return p

}

Termination Criteria

Warning:In practice, cutOff is a scalar while hit.kTran/kSpec are RGB values.

Page 54: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Pixel GetColor( scene , ray , ir , depth , cutOff ){

Pixel p(0,0,0)Ray reflect, refractIntersection hit = FindIntersection( ray , scene )if ( hit ){

p += GetSurfaceColor( hit.position )

reflect.direction = Reflect( ray.direction , hit.normal )reflect.position = hit.position + reflect.direction*εif( depth>0 && hit.kSpec>cutOff )

p += GetColor( scene , reflect , ir , depth-1 , cutOff/hit.kSpec )*hit.kSpec

refract.direction = Refract( ray.direction , hit.normal , ir , hit.ir )refract.position = hit.position + refract.direction*εif( depth>0 && hit.kTran>cutOff )

p += GetColor( scene , refract , hit.ir , depth-1 , cutOff/hit.kTran )*hit.kTran}return p

}

Termination Criteria

Note:When we refract, we enter a new material and the associated index of refraction changes.

Page 55: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Illumination Examples• Ray tracing (rays to point light source)

Courtesy Henrik Wann Jensen

Page 56: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

• Soft shadows (rays to area light source)

Illumination Examples

Courtesy Henrik Wann Jensen

Page 57: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Illumination Examples• Caustics (rays from light source)

Courtesy Henrik Wann Jensen

Page 58: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

• Full Global Illumination

Illumination Examples

Courtesy Henrik Wann Jensen

Page 59: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

• GetColor calls itself recursively

Recursive Ray Tracing

Image RayTrace( Camera camera , Scene scene ,int width , int height ,int depth , float cutOff )

{Image image = new Image( width , height );for( int i=0 ; i<width ; i++ ) for( int j=0 ; j<height ; j++ ){

Ray ray = ConstructRayThroughPixel( camera , i , j );image[i][j] = GetColor( scene , ray , 1 , depth , cutOff );

}return image;

}

Page 60: Indirect Illuminationmisha/Fall20/09.pdf · 2020. 9. 22. · Summary. • Ray casting (direct Illumination) Use simple analytic approximations for light source emission and surface

Summary• Ray casting (direct Illumination)

Use simple analytic approximations for light source emission and surface reflectance

• Recursive ray tracing (global illumination) Incorporate shadows, mirror reflections,

and pure refractions

More on global illumination later!

All of this is an approximationso that it is practical to compute