Lecture 6 - Path Tracing Welcome! , = (, ) , - - PowerPoint PPT Presentation

β–Ά
lecture 6 path tracing
SMART_READER_LITE
LIVE PREVIEW

Lecture 6 - Path Tracing Welcome! , = (, ) , - - PowerPoint PPT Presentation

INFOMAGR Advanced Graphics Jacco Bikker - November 2019 - February 2020 Lecture 6 - Path Tracing Welcome! , = (, ) , + , , ,


slide-1
SLIDE 1

𝑱 π’š, π’šβ€² = 𝒉(π’š, π’šβ€²) 𝝑 π’š, π’šβ€² + ΰΆ±

𝑻

𝝇 π’š, π’šβ€², π’šβ€²β€² 𝑱 π’šβ€², π’šβ€²β€² π’†π’šβ€²β€²

INFOMAGR – Advanced Graphics

Jacco Bikker - November 2019 - February 2020

Lecture 6 - β€œPath Tracing”

Welcome!

slide-2
SLIDE 2

Today’s Agenda:

β–ͺ Introduction β–ͺ Path Tracing

slide-3
SLIDE 3

Introduction

Advanced Graphics – Path Tracing 3

Previously in Advanced Graphics

The Rendering Equation: 𝑀𝑝 𝑦, πœ•π‘ = 𝑀𝐹 𝑦, πœ•π‘ + ΰΆ±

𝛻

𝑔

𝑠 𝑦, πœ•π‘, πœ•π‘— 𝑀𝑗 𝑦, πœ•π‘— cos πœ„π‘— π‘’πœ•π‘—

…which models light transport as it happens in the real world, by summing: β–ͺ Direct illumination: 𝑀𝐹(𝑦, πœ•π‘) β–ͺ Indirect illumination, or reflected light: Χ¬

𝛻 𝑔 𝑠 𝑦, πœ•π‘, πœ•π‘— 𝑀𝑗 𝑦, πœ•π‘— cos πœ„π‘— π‘’πœ•π‘—

We used quantities flux 𝛸 (joules per second), radiance 𝑀 (flux per 𝑛2 per sr) and irradiance 𝐹 (flux per 𝑛2).

slide-4
SLIDE 4

Introduction

Advanced Graphics – Path Tracing 4

Previously in Advanced Graphics

Particle transport: As an alternative to discrete flux / radiance / irradiance, we can reason about light transport in terms of particle transport. β–ͺ Flux then becomes the number of emitted photons; β–ͺ Radiance the number of photons travelling through a unit area in a unit direction; β–ͺ Irradiance the number of photons arriving on a unit area. A BRDF tells us how many particles are absorbed, and how outgoing particles are

  • distributed. The distribution depends on the incident and exitant direction.
slide-5
SLIDE 5

Introduction

Advanced Graphics – Path Tracing 5

Previously in Advanced Graphics

Probabilities: We can also reason about the behavior of a single photon. In that case, the BRDF tells us the probability of a photon being absorbed, or leaving in a certain direction.

slide-6
SLIDE 6

Introduction

Advanced Graphics – Path Tracing 6

Previously in Advanced Graphics

BRDFs:

slide-7
SLIDE 7

Introduction

Advanced Graphics – Path Tracing 7

Light Transport

𝑀 𝑑 ← 𝑦 = 𝑀𝐹 𝑑 ← 𝑦 + ΰΆ±

𝐡

𝑔

𝑠 𝑑 ← 𝑦 ← 𝑦′ 𝑀 𝑦 ← 𝑦′ 𝐻 𝑦 ↔ 𝑦′ 𝑒𝐡(𝑦′)

𝑀𝑝 𝑦, πœ•π‘ = 𝑀𝐹 𝑦, πœ•π‘ + ΰΆ±

𝛻

𝑔

𝑠 𝑦, πœ•π‘, πœ•π‘— 𝑀𝑗 𝑦, πœ•π‘— cos πœ„π‘— π‘’πœ•π‘—

Radiance Radiance Radiance Irradiance BRDF

slide-8
SLIDE 8

Introduction

Advanced Graphics – Path Tracing 8

Bidirectional Reflectance Distribution Function

BRDF: function describing the relation between radiance emitted in direction πœ•π‘ and irradiance arriving from direction πœ•π‘—: 𝑔

𝑠 πœ•π‘, πœ•π‘— = 𝑀𝑝(πœ•π‘)

𝐹𝑗(πœ•π‘—) = 𝑀𝑝(πœ•π‘) 𝑀𝑗 πœ•π‘— cos θ𝑗 = π‘π‘£π‘’π‘•π‘π‘—π‘œπ‘• π‘ π‘π‘’π‘—π‘π‘œπ‘‘π‘“ π‘—π‘œπ‘‘π‘π‘›π‘—π‘œπ‘• π‘—π‘ π‘ π‘π‘’π‘—π‘π‘œπ‘‘π‘“ Or, if spatially variant: 𝑔

𝑠 𝑦, πœ•π‘, πœ•π‘— = 𝑀𝑝(𝑦, πœ•π‘)

𝐹𝑗(𝑦, πœ•π‘—) = 𝑀𝑝(𝑦, πœ•π‘) 𝑀𝑗 𝑦, πœ•π‘— cos θ𝑗 Properties: β–ͺ Should be positive: 𝑔

𝑠 πœ•π‘, πœ•π‘— β‰₯ 0

β–ͺ Helmholtz reciprocity should be obeyed: 𝑔

𝑠 πœ•π‘, πœ•π‘— = 𝑔 𝑠 πœ•π‘—, πœ•π‘

β–ͺ Energy should be conserved: Χ¬

𝛻 𝑔 𝑠 πœ•π‘, πœ•π‘— cos πœ„π‘ π‘’πœ•π‘ ≀ 1

slide-9
SLIDE 9

Introduction

Advanced Graphics – Path Tracing 9

Bidirectional Reflectance Distribution Function

The diffuse BRDF is: 𝑔

𝑠 πœ•π‘, πœ•π‘— = π‘π‘šπ‘π‘“π‘’π‘

Ο€ So, for a total irradiance 𝐹 at surface point 𝑦, the

  • utgoing radiance 𝑀𝑝 = 𝐹𝑗

π‘π‘šπ‘π‘“π‘’π‘ 𝜌

. Why the 𝜌? Energy conservation: 𝐹𝑝 ≀ 𝐹𝑗 Suppose we have a directional light parallel to π‘œ, with intensity 1. Then: 𝐹𝑗 = 𝑀𝑗 = 1. Suppose our BRDF =

π‘π‘šπ‘π‘“π‘’π‘ 1

. Then, for albedo = 1 we get: 𝐹𝑝 = Χ¬

𝛻 𝑀𝑗 𝑔 𝑠(πœ•π‘ , πœ•π‘—) cos πœ•π‘ π‘’πœ•π‘ = Χ¬ 𝛻 cos πœ•π‘ π‘’πœ•π‘

Now: Χ¬

𝛻 cos πœ•π‘ π‘’πœ•π‘ = 𝜌 βž” 𝐹𝑝 = 𝜌 𝐹𝑗.

𝒐 𝝏𝒋

slide-10
SLIDE 10

Introduction

Advanced Graphics – Path Tracing 10

Bidirectional Reflectance Distribution Function

Mirror / Perfect specular: Reflects light in a fixed direction. For a given incoming direction πœ•π‘—, all light is emitted in a single infinitesimal set of directions. The specular BRDF is thus 𝑔

𝑠 𝑦, πœ•π‘, πœ•π‘— = α‰Šβˆž, along reflected vector

0, otherwise. This is not practical, and therefore we will handle the pure specular case (reflection and refraction) separately.

𝒐 𝝏𝒑 𝝏𝒋

slide-11
SLIDE 11

Introduction

Advanced Graphics – Path Tracing 11

Previously in Advanced Graphics

Monte Carlo integration: Complex integrals can be approximated by replacing them by the expected value of a stochastic experiment. β–ͺ Soft shadows: randomly sample the area of a light source; β–ͺ Glossy reflections: randomly sample the directions in a cone; β–ͺ Depth of field: randomly sample the aperture; β–ͺ Motion blur: randomly sample frame time. In the case of the rendering equation, we are dealing with a recursive integral. Pat ath tr tracing: evaluating th this in integral us using a a ran andom walk.

slide-12
SLIDE 12

Today’s Agenda:

β–ͺ Introduction β–ͺ Path Tracing

slide-13
SLIDE 13

Path Tracing

Advanced Graphics – Path Tracing 13

Solving the Rendering Equation

Let’s start with direct illumination: For a screen pixel, diffuse surface point π‘ž with normal 𝑂 is directly visible. What is the radiance travelling via π‘ž towards the eye? Answer: 𝑀𝑝 π‘ž, πœ•π‘ = ΰΆ±

𝛻

𝑔

𝑠 π‘ž, πœ•π‘, πœ•π‘— 𝑀𝑒 π‘ž, πœ•π‘— cos πœ„π‘— π‘’πœ•π‘—

p πœ•π‘ πœ•π‘— 𝑂

slide-14
SLIDE 14

Path Tracing

Advanced Graphics – Path Tracing 14

Solving the Rendering Equation

Let’s start with direct illumination: For a screen pixel, diffuse surface point π‘ž with normal 𝑂 is directly visible. What is the radiance travelling via π‘ž towards the eye? Answer: 𝑀𝑝 π‘ž, πœ•π‘ = ΰΆ±

𝛻

𝑔

𝑠 π‘ž, πœ•π‘, πœ•π‘— 𝑀𝑒 π‘ž, πœ•π‘— cos πœ„π‘— π‘’πœ•π‘—

p πœ•π‘ πœ•π‘— π‘œ 𝑀𝑝 π‘ž, πœ•π‘ = ΰΆ±

𝛻

𝑔

𝑠 π‘ž, πœ•π‘, πœ•π‘— 𝑀𝑒 π‘ž, πœ•π‘— cos πœ„π‘— π‘’πœ•π‘—

= π‘π‘šπ‘π‘“π‘’π‘ 𝜌 ΰΆ±

𝛻

𝑀𝑒 π‘ž, πœ•π‘— cos πœ„π‘— π‘’πœ•π‘— Q: What about distance attenuation? A: A far-away light is found by fewer directions πœ•π‘—: it’s solid ang angle on the hemisphere is smaller. Q: What about the diffuse surface? A: The BRDF is independent of πœ•π‘ (it doesn’t appear in the equation), but as πœ•π‘— approaches the horizon, cos πœ„π‘— approaches zero.

slide-15
SLIDE 15

Path Tracing

Advanced Graphics – Path Tracing 15

Direct Illumination

We can solve this integral using Monte-Carlo integration:

β–ͺ Chose N random directions over the hemisphere for π‘ž β–ͺ Find the first surface in each direction by tracing a ray β–ͺ Sum the luminance of the encountered surfaces β–ͺ Divide the sum by N and multiply by 2Ο€

𝑀𝑝 π‘ž, πœ•π‘ β‰ˆ 2𝜌 𝑂 ෍

𝑗=1 𝑂

𝑔

𝑠 π‘ž, πœ•π‘, πœ•π‘— 𝑀𝑒 π‘ž, πœ•π‘— cos πœ„π‘—

p πœ•π‘ πœ•π‘— π‘œ

slide-16
SLIDE 16

Path Tracing

Advanced Graphics – Path Tracing 16

Direct Illumination

𝑀𝑝 π‘ž, πœ•π‘ β‰ˆ 2𝜌 𝑂 ෍

𝑗=1 𝑂

𝑔

𝑠 π‘ž, πœ•π‘, πœ•π‘— 𝑀𝑒 π‘ž, πœ•π‘— cos πœ„

Questions: β–ͺ Why do we multiply by 2𝜌? β–ͺ What is the radiance 𝑀𝑒(π‘ž, πœ•π‘—) towards π‘ž for e.g. a 100W light? β–ͺ What is the irradiance 𝐹 at π‘ž from this light? p πœ•π‘ πœ•π‘— π‘œ

We integrate over the hemisphere, which has an area of 2𝜌. Do not confuse this with the 1/ 𝜌 factor in the BRDF, which doesn’t compensate for the surface of the hemisphere, but the integral of cos πœ„ over the hemisphere (𝜌). 𝑀 is per sr; 𝑀𝑒(π‘ž, πœ•π‘—) is proportional to the solid angle of the light as seen from p, so: ~ (cos πœ„π‘ 𝐡𝑀𝑒)/𝑠2. Note that the 100W flux is spread

  • ut over the area; irradiance is

defined per 𝑛2.

slide-17
SLIDE 17

Path Tracing

Advanced Graphics – Path Tracing 17

Direct Illumination

𝑀𝑝 π‘ž, πœ•π‘ = ΰΆ±

𝛻

𝑔

𝑠 π‘ž, πœ•π‘, πœ•π‘— 𝑀𝑒 π‘ž, πœ•π‘— cos πœ„π‘— π‘’πœ•π‘—

In many directions, we will not find light sources. We can improve our estimate by sampling the lights separately. 𝑀𝑝 π‘ž, πœ•π‘— = ෍

π‘˜=1 π‘šπ‘—π‘•β„Žπ‘’π‘‘

ΰΆ±

𝛻

𝑔

𝑠 π‘ž, πœ•π‘, πœ•π‘— 𝑀𝑒 π‘˜ π‘ž, πœ•π‘— cos πœ„π‘— π‘’πœ•π‘—

Obviously, sampling the entire hemisphere for each light is not necessary; we can sample the area of the light instead: 𝑀𝑝 π‘ž, πœ•π‘— = ෍

π‘˜=1 π‘šπ‘—π‘•β„Žπ‘’π‘‘

ΰΆ±

𝐡

𝑔

𝑠 π‘ž, πœ•π‘, πœ•π‘— 𝑀𝑒 π‘˜ π‘ž, πœ•π‘— cos πœ„π‘— π‘’πœ•π‘—

slide-18
SLIDE 18

Path Tracing

Advanced Graphics – Path Tracing 18

Direct Illumination

𝑀𝑝 π‘ž, πœ•π‘— = ෍

π‘˜=1 π‘šπ‘—π‘•β„Žπ‘’π‘‘

ΰΆ±

𝐡

𝑔

𝑠 π‘ž, πœ•π‘, πœ•π‘— 𝑀𝑒 π‘˜ π‘ž, πœ•π‘— cos πœ„π‘— π‘’πœ•π‘—

Using Monte-Carlo: 𝑀𝑝 π‘ž, πœ•π‘— β‰ˆ π‘šπ‘—π‘•β„Žπ‘’π‘‘ βˆ— 1 𝑂 ෍

𝑗=1 𝑂

𝑔

𝑠 π‘ž, πœ•π‘, 𝑄 𝑀𝑒 𝐾 π‘ž, 𝑄 π‘Š π‘ž ↔ 𝑄

𝐡𝑀𝑒

𝐾 cos πœ„π‘— cos πœ„π‘

βˆ₯ π‘ž βˆ’ 𝑄 βˆ₯2 where β–ͺ 𝑀𝑒

𝐾 (π‘ž, 𝑄) is the direct light towards p from random point 𝑄 on random light 𝐾

β–ͺ π‘Š π‘ž ↔ 𝑄 is the mutual visibility between π‘ž and 𝑄 β–ͺ 𝐡𝑀𝑒

𝐾 is the area of this light source

β–ͺ (𝐡𝑀𝑒

𝐾 cos πœ„π‘)/(βˆ₯ π‘ž βˆ’ 𝑄 βˆ₯2) is the area of the light source projected on the

hemisphere, which approximates the solid angle of the light.

Recall:

slide-19
SLIDE 19

Path Tracing

Advanced Graphics – Path Tracing 19

Direct Illumination

We now have two methods to estimate direct illumination using Monte Carlo integration:

  • 1. By random sampling the hemisphere:

𝑀𝑝 π‘ž, πœ•π‘ β‰ˆ 2𝜌 𝑂 ෍

𝑗=1 𝑂

𝑔

𝑠 π‘ž, πœ•π‘, Ω𝑗 𝑀𝑒 π‘ž, Ω𝑗 cos πœ„π‘—

  • 2. By sampling the lights directly:

𝑀𝑝 π‘ž, πœ•π‘— β‰ˆ π‘šπ‘—π‘•β„Žπ‘’π‘‘ βˆ— 1 𝑂 ෍

𝑗=1 𝑂

𝑔

𝑠 π‘ž, πœ•π‘, 𝑄 𝑀𝑒 𝐾 π‘ž, 𝑄 π‘Š π‘ž ↔ 𝑄

𝐡𝑀𝑒

𝐾 cos πœ„π‘— cos πœ„π‘

βˆ₯ π‘ž βˆ’ 𝑄 βˆ₯2 For 𝑂 = ∞, these yield the same result.

slide-20
SLIDE 20

Path Tracing

Advanced Graphics – Path Tracing 20

Direct Illumination

We now have two methods to estimate direct illumination using Monte Carlo integration:

  • 1. By random sampling the hemisphere:

𝑀𝑝 π‘ž, πœ•π‘ β‰ˆ 2𝜌 𝑂 ෍

𝑗=1 𝑂

𝑔

𝑠 π‘ž, πœ•π‘, Ω𝑗 𝑀𝑒 π‘ž, Ω𝑗 cos πœ„π‘—

  • 2. By sampling the lights directly (three point notation):

𝑀𝑝 𝑑 ← π‘ž β‰ˆ π‘šπ‘—π‘•β„Žπ‘’π‘‘ βˆ— 1 𝑂 ෍

𝑗=1 𝑂

𝑔

𝑠 𝑑 ← π‘ž ← 𝑅 𝑀𝑒 𝐾 π‘ž ← 𝑅 π‘Š π‘ž ↔ 𝑅

𝐡𝑀𝑒

𝐾 cos πœ„π‘— cos πœ„π‘

βˆ₯ π‘ž βˆ’ 𝑅 βˆ₯2 For 𝑂 = ∞, these yield the same result.

slide-21
SLIDE 21

Path Tracing

Advanced Graphics – Path Tracing 21

Verification

Method 1 in a small C# ray tracing framework:

In: Ray ray, with members O, D, N, t. Already calculated: intersection point I = O + t * D. Vector3 R = RTTools.DiffuseReflection( ray.N ); Ray rayToHemisphere = new Ray( I + R * EPSILON, R, 1e34f ); Scene.Intersect( rayToHemisphere ); if (rayToHemisphere.objIdx == LIGHT) { Vector3 BRDF = material.diffuse * INVPI; float cos_i = Vector3.Dot( R, ray.N ); return 2.0f * PI * BRDF * Scene.lightColor * cos_i; }

𝑀𝑝 π‘ž, πœ•π‘ β‰ˆ 2𝜌 𝑂 ෍

𝑗=1 𝑂

𝑔

𝑠 π‘ž, πœ•π‘, Ω𝑗 𝑀𝑒 π‘ž, Ω𝑗 cos πœ„π‘—

slide-22
SLIDE 22

Path Tracing

Advanced Graphics – Path Tracing 22

Verification

Method 2 in a small C# ray tracing framework:

// construct vector to random point on light Vector3 L = Scene.RandomPointOnLight() - I; float dist = L.Length(); L /= dist; float cos_o = Vector3.Dot( -L, lightNormal ); float cos_i = Vector3.Dot( L, ray.N ); if ((cos_o <= 0) || (cos_i <= 0)) return BLACK; // light is not behind surface point, trace shadow ray Ray r = new Ray( I + EPSILON * L, L, dist - 2 * EPSILON ); Scene.Intersect( r ); if (r.objIdx != -1) return Vector3.Zero; // light is visible (V(p,p’)=1); calculate transport Vector3 BRDF = material.diffuse * INVPI; float solidAngle = (cos_o * Scene.LIGHTAREA) / (dist * dist); return BRDF * lightCount * Scene.lightColor * solidAngle * cos_i;

𝑀𝑝 π‘ž, πœ•π‘— β‰ˆ π‘šπ‘—π‘•β„Žπ‘’π‘‘ βˆ— 1 𝑂 ෍

𝑗=1 𝑂

𝑔

𝑠 π‘ž, πœ•π‘, 𝑄 𝑀𝑒 𝐾 π‘ž, 𝑄 π‘Š π‘ž ↔ 𝑄

𝐡𝑀𝑒

𝐾 cos πœ„π‘— cos πœ„π‘

βˆ₯ π‘ž βˆ’ 𝑄 βˆ₯2

slide-23
SLIDE 23

Path Tracing

Advanced Graphics – Path Tracing 23

0.1s

slide-24
SLIDE 24

Path Tracing

Advanced Graphics – Path Tracing 24

0.5s

slide-25
SLIDE 25

Path Tracing

Advanced Graphics – Path Tracing 25

2.0s

slide-26
SLIDE 26

Path Tracing

Advanced Graphics – Path Tracing 26

30.0s

slide-27
SLIDE 27

Path Tracing

Advanced Graphics – Path Tracing 27

Rendering using Monte Carlo Integration

In the demonstration, we sampled each light using only 1 sample. The (very noisy) result is directly visualized. To get a better estimate, we average the result of several frames (and thus: several samples). Observations:

  • 1. The light sampling estimator is much better than the hemisphere estimator;
  • 2. Relatively few samples are sufficient for a recognizable image;
  • 3. Noise reduces over time, but we quickly get diminishing returns.
slide-28
SLIDE 28

Path Tracing

Advanced Graphics – Path Tracing 28

Indirect Light

Returning to the full rendering equation: We know how to evaluate direct lighting: What remains is indirect light. This is the light that is not emitted by the surface in direction πœ•π‘—, but reflected.

slide-29
SLIDE 29

Path Tracing

Advanced Graphics – Path Tracing 29 direct light 1st bounce 2nd bounce

β‰ˆβ€¦ Indirect Light

Let’s expand / reorganize this: 𝑀𝑝 𝑦, πœ•π‘

𝑦 = 𝑀𝐹 𝑦, πœ•π‘ 𝑦

+ ΰΆ±

𝛻

𝑀𝐹 𝑧, πœ•π‘

𝑧 𝑔 𝑠 𝑦, πœ•π‘ 𝑦, πœ•π‘— 𝑦

cos πœ„π‘—

𝑦 π‘’πœ•π‘— 𝑦

+ ΰΆ±

𝛻

ΰΆ±

𝛻

𝑀𝐹 𝑨, πœ•π‘

π‘Ÿ 𝑔 𝑠 𝑧, πœ•π‘ π‘Ÿ, πœ•π‘— π‘Ÿ

cos πœ„π‘—

π‘Ÿ 𝑔 𝑠 𝑦, πœ•π‘ 𝑦, πœ•π‘— 𝑦

cos πœ„π‘—

𝑦 π‘’πœ•π‘— 𝑦 π‘’πœ•π‘— π‘Ÿ

+ ΰΆ±

𝛻

ΰΆ±

𝛻

ΰΆ±

𝛻

… 𝑦 𝑧 π‘Ÿ 𝑨

slide-30
SLIDE 30

Path Tracing

Advanced Graphics – Path Tracing 30

Indirect Light

One particle finding the light via a surface:

I, N = Trace( ray ); R = DiffuseReflection( N ); lightColor = Trace( new Ray( I, R ) ); return dot( R, N ) *

π‘π‘šπ‘π‘“π‘’π‘ 𝜌

* lightColor * 2𝜌;

One particle finding the light via two surfaces:

I1, N1 = Trace( ray ); R1 = DiffuseReflection( N1 ); I2, N2 = Trace( new Ray( I1, R1 ) ); R2 = DiffuseReflection( N2 ); lightColor = Trace( new Ray( I2, R2 ) ); return dot( R1, N1 ) *

π‘π‘šπ‘π‘“π‘’π‘ 𝜌

* 2𝜌 * dot( R2, N2 ) *

π‘π‘šπ‘π‘“π‘’π‘ 𝜌

* 2𝜌 * lightColor;

𝑦 𝑧 𝑧 𝑨

slide-31
SLIDE 31

Path Tracing

Advanced Graphics – Path Tracing 31

Path Tracing Algorithm

Color Sample( Ray ray ) { // trace ray I, N, material = Trace( ray ); // terminate if ray left the scene if (ray.NOHIT) return BLACK; // terminate if we hit a light source if (material.isLight) return material.emittance; // continue in random direction R = DiffuseReflection( N ); Ray newRay( I, R ); // update throughput BRDF = material.albedo / PI; Ei = Sample( newRay ) * dot( N, R ); // irradiance return PI * 2.0f * BRDF * Ei; }

𝑦 𝑧 𝑧 𝑨

slide-32
SLIDE 32

Path Tracing

Advanced Graphics – Path Tracing 32

slide-33
SLIDE 33

Path Tracing

Advanced Graphics – Path Tracing 33

slide-34
SLIDE 34

Path Tracing

Advanced Graphics – Path Tracing 34

slide-35
SLIDE 35

Path Tracing

Advanced Graphics – Path Tracing 35

slide-36
SLIDE 36

Path Tracing

Advanced Graphics – Path Tracing 36

Particle Transport

The random walk is analogous to particle transport: β–ͺ a particle leaves the camera β–ͺ at each surface, energy is absorbed proportional to 1-albedo (β€˜surface color’) β–ͺ at each surface, the particle picks a new direction β–ͺ at a light, the path transfers energy to the camera. In the simulation, particles seem to travel backwards. This is valid because of the Helmholtz reciprocity. Notice that longer paths tend to return less energy.

Color Sample( Ray ray ) { // trace ray I, N, material = Trace( ray ); // terminate if ray left the scene if (ray.NOHIT) return BLACK; // terminate if we hit a light source if (material.isLight) return emittance; // continue in random direction R = DiffuseReflection( N ); Ray r( I, R ); // update throughput BRDF = material.albedo / PI; Ei = Sample( r ) * (Nβˆ™R); return PI * 2.0f * BRDF * Ei; }

slide-37
SLIDE 37

Path Tracing

Advanced Graphics – Path Tracing 37

Particle Transport - Mirrors

Handling a pure specular surface: A particle that encounters a mirror continues in a deterministic way. Question: β–ͺ What happens at a red mirror? β–ͺ What happens if a material is only half reflective?

Color Sample( Ray ray ) { // trace ray I, N, material = Trace( ray ); // terminate if ray left the scene if (ray.NOHIT) return BLACK; // terminate if we hit a light source if (material.isLight) return emittance; // surface interaction if (material.isMirror) { // continue in fixed direction Ray r( I, Reflect( N ) ); return material.albedo * Sample( r ); } // continue in random direction R = DiffuseReflection( N ); BRDF = material.albedo / PI; Ray r( I, R ); // update throughput Ei = Sample( r ) * (Nβˆ™R); return PI * 2.0f * BRDF * Ei; }

slide-38
SLIDE 38

Path Tracing

Advanced Graphics – Path Tracing 38

Particle Transport - Glass

Handling dielectrics: Dielectrics reflect and transmit light. In the ray tracer, we handled this using two rays. A particle must chose. The probability of each choice is calculated using the Fresnel equations.

Color Sample( Ray ray ) { // trace ray I, N, material = Trace( ray ); // terminate if ray left the scene if (ray.NOHIT) return BLACK; // terminate if we hit a light source if (material.isLight) return emittance; // surface interaction if (material.isMirror) { // continue in fixed direction Ray r( I, Reflect( N ) ); return material.albedo * Sample( r ); } // continue in random direction R = DiffuseReflection( N ); BRDF = material.albedo / PI; Ray r( I, R ); // update throughput Ei = Sample( r ) * (Nβˆ™R); return PI * 2.0f * BRDF * Ei; }

slide-39
SLIDE 39

Path Tracing

Advanced Graphics – Path Tracing 39

slide-40
SLIDE 40

Path Tracing

Advanced Graphics – Path Tracing 40

slide-41
SLIDE 41

Today’s Agenda:

β–ͺ Introduction β–ͺ Path Tracing

slide-42
SLIDE 42

INFOMAGR – Advanced Graphics

Jacco Bikker - November 2019 - February 2020

END of β€œPath Tracing”

next lecture: β€œGPU Ray Tracing (1)”

slide-43
SLIDE 43

Path Tracing

Advanced Graphics – Path Tracing 43

Solid Angle

A few words on solid angle: As mentioned in lecture 4, solid angle is measured in steradians. Where radians are the length of an arc on the unit circle subtended by two directions, steradians are the surface

  • n the unit sphere subtended by a shape.

In this lecture, we used:

𝐡 cos ΞΈ 𝑠2

, which is only an approximation, except when the shape is a segment of a sphere and cos ΞΈ = 1. For 𝑠 ≫ 𝐡, this approximation is β€˜good enough’.

slide-44
SLIDE 44

Path Tracing

Advanced Graphics – Path Tracing 44

Additional literature:

Slides for lecture 9 of the Advanced Computer Graphics course of the University of Freiburg, by Matthias Teschner: http://cg.informatik.uni-freiburg.de/course_notes/graphics2_09_pathTracing.pdf Blog: A graphics guy’s note: https://agraphicsguy.wordpress.com Monte Carlo Path Tracing, Path Hanrahan: http://cs.brown.edu/courses/cs224/papers/mc_pathtracing.pdf Path Tracing - Theoretical Foundation, by Vidar Nelson: http://www.vidarnel.com/post/path_tracing Importance Sampling for Production Rendering, SIGGRAPH 2010 course: http://igorsklyar.com/system/documents/papers/4/fiscourse.comp.pdf Please share additional resources on the forum.