Welcome! , = (, ) , + , , - - PowerPoint PPT Presentation

β–Ά
welcome
SMART_READER_LITE
LIVE PREVIEW

Welcome! , = (, ) , + , , - - PowerPoint PPT Presentation

INFOMAGR Advanced Graphics Jacco Bikker - February April 2016 Welcome! , = (, ) , + , , , Todays Agenda:


slide-1
SLIDE 1

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

𝑻

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

INFOMAGR – Advanced Graphics

Jacco Bikker - February – April 2016

Welcome!

slide-2
SLIDE 2

Today’s Agenda:

  • Introduction
  • Stratification
  • Next Event Estimation
  • Importance Sampling
  • MIS
slide-3
SLIDE 3

Introduction

Advanced Graphics – Variance Reduction 3

Previously in Advanced Graphics

slide-4
SLIDE 4

Introduction

Advanced Graphics – Variance Reduction 4

slide-5
SLIDE 5

Introduction

Advanced Graphics – Variance Reduction 5

Today in Advanced Graphics:

  • Stratification
  • Next Event Estimation
  • Importance Sampling
  • Multiple Importance Sampling
  • Resampled Importance Sampling*

Aim:

  • to get a better image with the same number of samples
  • to increase the efficiency of a path tracer
  • to reduce variance in the estimate

Requirement:

  • produce the correct image

*: If time permits

slide-6
SLIDE 6

Today’s Agenda:

  • Introduction
  • Stratification
  • Next Event Estimation
  • Importance Sampling
  • MIS
slide-7
SLIDE 7

Stratification

Advanced Graphics – Variance Reduction 7

Uniform Random Sampling

To sample a light source, we draw two random values in the range 0..1. The resulting 2D positions are not uniformly distributed

  • ver the area.

We can improve uniformity using stratification:

  • ne sample is placed in each stratum.
slide-8
SLIDE 8

Stratification

Advanced Graphics – Variance Reduction 8

Uniform Random Sampling

To sample a light source, we draw two random values in the range 0..1. The resulting 2D positions are not uniformly distributed

  • ver the area.

We can improve uniformity using stratification:

  • ne sample is placed in each stratum.

For 4x4 strata:

stratum_x = (idx % 4) * 0.25 // idx = 0..15 stratum_y = (idx / 4) * 0.25 r0 = Rand() * 0.25 r1 = Rand() * 0.25 P = vec2( stratum_x + r0, stratum_y + r1 )

slide-9
SLIDE 9

Stratification

Advanced Graphics – Variance Reduction 9

slide-10
SLIDE 10

Stratification

Advanced Graphics – Variance Reduction 10

Use Cases

Stratification can be applied to any Monte Carlo process:

  • Anti-aliasing (sampling the pixel)
  • Depth of field (sampling the lens)
  • Motion blur (sampling time)
  • Soft shadows (sampling area lights)
  • Diffuse reflections (sampling the hemisphere)

However, there are problems:

  • We need to take one sample per stratum
  • Stratum count: higher is better, but with diminishing returns
  • Combining stratification for e.g. depth of field and soft shadows leads to

correlation of the samples, unless we stratify the 4D space - which leads to a very large number of strata: the curse of dimensionality.

slide-11
SLIDE 11

Stratification

Advanced Graphics – Variance Reduction 11

Alleviating the Curse of Dimensionality

Imagine we have 2x2 strata for the lens, and 2x2 for area lights. We can sample this with 4 samples without correlation by randomly combining strata. In practice:

  • We generate 4 positions on the lens with stratification;
  • We generate 4 positions on the area light with

stratification;

  • When sampling the lens, we randomly select a stratum

from the array of lens samples;

  • When sampling the area light, we randomly select a

stratum from the array of area light samples.

slide-12
SLIDE 12

Stratification

Advanced Graphics – Variance Reduction 12

Alleviating the Curse of Dimensionality

Imagine we have 2x2 strata for the lens, and 2x2 for area lights. We can sample this with 4 samples without correlation by randomly combining strata. Even more practical:

  • Generate an array of stratified pairs of random numbers:

random[N][M][2], where 𝑂 is the number of strata and 𝑁 is the number of dimensions / 2.

  • Shuffle entries 0..N-1 for each M.
  • Take samples from this array whenever you need a

random number.

  • If you run out, switch to uniform random numbers.
slide-13
SLIDE 13

Stratification

Advanced Graphics – Variance Reduction 13

Troubleshooting Path Tracing Experiments

When experimenting with stratification and other variance reduction methods you will frequently produce incorrect images. Tip: Keep a simple reference path tracer without any tricks. Compare your output to this reference solution frequently.

slide-14
SLIDE 14

Today’s Agenda:

  • Introduction
  • Stratification
  • Next Event Estimation
  • Importance Sampling
  • MIS
slide-15
SLIDE 15

NEE

Advanced Graphics – Variance Reduction 15 Also recall that we had two ways to sample direct illumination:

randomly sampling the hemisphere directly sampling the lights

Can we apply this to the full rendering equation, instead of just direct illumination?

Next Event Estimation

Recall the rendering equation: …and the way we sampled it using Monte Carlo:

Vector3 R = DiffuseReflection( ray.N ); Ray rayToHemisphere = new Ray( I + R * EPSILON, R ); Scene.Intersect( rayToHemisphere ); if (rayToHemisphere.objIdx == LIGHT) { Vector3 BRDF = material.diffuse / 𝜌; float cos_i = Vector3.Dot( R, ray.N ); return 2.0f * 𝜌 * BRDF * Scene.lightColor * cos_i; }

slide-16
SLIDE 16

NEE

Advanced Graphics – Variance Reduction 16

Next Event Estimation

Light travelling via any vertex on the path consists of indirect light and direct light for that vertex. Next Event Estimation: sampling direct and indirect separately.

slide-17
SLIDE 17

NEE

Advanced Graphics – Variance Reduction 17

Next Event Estimation

Light travelling via any vertex on the path consists of indirect light and direct light for that vertex. Next Event Estimation: sampling direct and indirect separately. Mathematically: = 𝑀𝑓 𝑦, πœ•π‘ +

𝛻

𝑔

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

+

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

𝑔

𝑠 𝑑 ← 𝑦 ← 𝑦′ 𝑀𝑒 π‘˜ 𝑦 ← 𝑦′

𝐡𝑀𝑒

π‘˜ cos πœ„π‘— cos πœ„π‘

βˆ₯ 𝑦 βˆ’ 𝑦′ βˆ₯2 π‘’πœ•π‘— Problem: we are now sampling lights twice. Solution 1: scale by 0.5. Solution 2: ignore direct light when using 1 .

1 2

slide-18
SLIDE 18

NEE

Advanced Graphics – Variance Reduction 18

Next Event Estimation

Per surface interaction, we trace two rays.

  • Ray A returns via point x the energy reflected by 𝑧
  • Ray B returns the direct illumination on point 𝑦
  • Ray C returns the direct illumination on point 𝑧, which will reach the sensor via ray A.
  • Ray D leaves the scene.

𝑦 𝑧 A B C D

slide-19
SLIDE 19

NEE

Advanced Graphics – Variance Reduction 19

Next Event Estimation

When a ray for indirect illumination stumbles upon a light, the path is terminated and no energy is transported via ray D: This way, we prevent accounting for direct illumination on point 𝑧 twice. 𝑦 𝑧 A B C D

slide-20
SLIDE 20

NEE

Advanced Graphics – Variance Reduction 20

Next Event Estimation

Color Sample( Ray ray ) { // trace ray I, N, material = Trace( ray ); BRDF = material.albedo / PI; // terminate if ray left the scene if (ray.NOHIT) return BLACK; // terminate if we hit a light source if (material.isLight) return BLACK; // sample a random light source L, Nl, dist, A = RandomPointOnLight(); Ray lr( I, L, dist ); if (Nβˆ™L > 0 && Nlβˆ™-L > 0) if (!Trace( lr )) { solidAngle = ((Nlβˆ™-L) * A) / dist2; Ld = lightColor * solidAngle * BRDF * Nβˆ™L; } // continue random walk R = DiffuseReflection( N ); Ray r( I, R ); Ei = Sample( r ) * (Nβˆ™R); return PI * 2.0f * BRDF * Ei + Ld; }

slide-21
SLIDE 21

NEE

Advanced Graphics – Variance Reduction 21

slide-22
SLIDE 22

NEE

Advanced Graphics – Variance Reduction 22

slide-23
SLIDE 23

NEE

Advanced Graphics – Variance Reduction 23

slide-24
SLIDE 24

NEE

Advanced Graphics – Variance Reduction 24

Next Event Estimation

Some vertices require special attention:

  • If the first vertex after the camera is emissive, its energy can’t

be reflected to the camera.

  • For specular surfaces, the BRDF to a light is always 0.

Since a light ray doesn’t make sense for specular vertices, we will include emission from a vertex directly following a specular vertex. The same goes for the first vertex after the camera: if this is emissive, we will also include this. This means we need to keep track of the type of the previous vertex during the random walk.

slide-25
SLIDE 25

NEE

Advanced Graphics – Variance Reduction 25

Color Sample( Ray ray, bool lastSpecular ) { // trace ray I, N, material = Trace( ray ); BRDF = material.albedo / PI; // terminate if ray left the scene if (ray.NOHIT) return BLACK; // terminate if we hit a light source if (material.isLight) if (lastSpecular) return material.emissive; else return BLACK; // sample a random light source L, Nl, dist, A = RandomPointOnLight(); Ray lr( I, L, dist ); if (Nβˆ™L > 0 && Nlβˆ™-L > 0) if (!Trace( lr )) { solidAngle = ((Nlβˆ™-L) * A) / dist2; Ld = lightColor * solidAngle * BRDF * Nβˆ™L; } // continue random walk R = DiffuseReflection( N ); Ray r( I, R ); Ei = Sample( r, false ) * (Nβˆ™R); return PI * 2.0f * BRDF * Ei + Ld; }

slide-26
SLIDE 26

Today’s Agenda:

  • Introduction
  • Stratification
  • Next Event Estimation
  • Importance Sampling
  • MIS
slide-27
SLIDE 27

Importance Sampling

Advanced Graphics – Variance Reduction 27

Importance Sampling for Monte Carlo

Monte Carlo integration: π‘Š

𝐡 = 𝐡 𝐢

𝑔(𝑦) 𝑒𝑦 =

𝐡 𝐢

𝑒𝑦 𝐹 𝑔 𝑦 β‰ˆ 𝐡 βˆ’ 𝐢 𝑂

𝑗=1 𝑂

𝑔 x𝑗 Example 1: rolling two dice 𝐸1 and 𝐸2, the outcome is 6𝐸1 + 𝐸2. What is the expected value of this experiment? (average die value is 3.5, so the answer is of course 3.5 * 6 + 3.5 = 24.5) Using Monte Carlo: π‘Š = 1 𝑂

𝑗=1 𝑂

𝑔( 𝐸1) + 𝑕( 𝐸2) π‘₯β„Žπ‘“π‘ π‘“: 𝐸1, 𝐸1∈ {1,2,3,4,5,6}, 𝑔 𝑦 = 6𝑦, 𝑕 𝑦 = 𝑦

slide-28
SLIDE 28

Importance Sampling

Advanced Graphics – Variance Reduction 28

Importance Sampling for Monte Carlo

Changing the experiment slightly: each sample is one roll of one die. Using Monte Carlo: π‘Š = 1 𝑂

𝑗=1 𝑂 𝑔(

π‘œ, 𝐸) 0.5 π‘₯β„Žπ‘“π‘ π‘“: 𝐸 ∈ {1,2,3,4,5,6}, π‘œ ∈ {0,1}, 𝑔 π‘œ, 𝑦 = 5π‘œ + 1 𝑦

for( int i = 0; i < 1000; i++ ) { int D1 = IRand( 6 ) + 1; int D2 = IRand( 6 ) + 1; float f = (float)(6 * D1 + D2); total += f; rolls++; } for( int i = 0; i < 1000; i++ ) { int D = IRand( 6 ) + 1; int n = IRand( 2 ); float f = (float)((5 * n + 1) * D) / 0.5f; total += f; rolls++; }

0.5: Probability of using die π‘œ.

slide-29
SLIDE 29

Importance Sampling

Advanced Graphics – Variance Reduction 29

Importance Sampling for Monte Carlo

What happens when we don’t pick each die with the same probability?

  • we get the correct answer;
  • we get lower variance.

for( int i = 0; i < 1000; i++ ) { int D = IRand( 6 ) + 1; float r = Rand(); // uniform 0..1 int n = (r < 0.8f) ? 0 : 1; float p = (n == 0) ? 0.8f : 0.2f; float f = (float)((5 * n + 1) * D) / p; total += f; rolls++; }

slide-30
SLIDE 30

Importance Sampling

Advanced Graphics – Variance Reduction 30

Importance Sampling for Monte Carlo

Example 2: sampling two area lights. Sampling the large light with a greater probability yields a better estimate.

slide-31
SLIDE 31

Importance Sampling

Advanced Graphics – Variance Reduction 31

Importance Sampling for Monte Carlo

Example 3: sampling an integral. Considering the previous experiments, which stratum should be sample more often? 1 2

slide-32
SLIDE 32

Importance Sampling

Advanced Graphics – Variance Reduction 32

Importance Sampling for Monte Carlo

Example 3: sampling an integral. Considering the previous experiments, which stratum should be sample more often? 1 2 3 4

slide-33
SLIDE 33

Importance Sampling

Advanced Graphics – Variance Reduction 33

Importance Sampling for Monte Carlo

Example 3: sampling an integral. Considering the previous experiments, which stratum should be sample more often? 1 2 3 4 5 6 7 8

When using 8 strata and a uniform random distribution, each stratum will be sampled with a 0.125 probability. When using 8 strata and a non-uniform sampling scheme, the sum of the sampling probabilities must be 1. Good sampling probabilities are obtained by simply following the function we’re

  • sampling. Note: we must normalize.

We don’t have to use these probabilities; any set of non-zero probabilities will work, but with greater variance. This includes any approximation of the function we’re sampling, whether this approximation is good or not.

slide-34
SLIDE 34

Importance Sampling

Advanced Graphics – Variance Reduction 34

Importance Sampling for Monte Carlo

Example 3: sampling an integral. Considering the previous experiments, which stratum should be sample more often?

If we go from 8 to infinite strata, the probability of sampling a stratum becomes 0. This is where we introduce the PDF, or probability density function. On a continuous domain, the probability of sampling a specific x is 0. However, we can say that the probability of chosing any x in the domain is 1, and the probability of chosing x in the first half of the domain is 0.5. We get this 0.5 by integrating a function p(x) over the domain [0,0.5). Function p(x) (the PDF) is the probability per unit width of sampling a particular x.

slide-35
SLIDE 35

Importance Sampling

Advanced Graphics – Variance Reduction 35

Importance Sampling for Monte Carlo

Example 4: sampling the hemisphere. βˆ’πœŒ 𝜌

slide-36
SLIDE 36

Importance Sampling

Advanced Graphics – Variance Reduction 36

Importance Sampling for Monte Carlo

Example 4: sampling the hemisphere. βˆ’πœŒ 𝜌

slide-37
SLIDE 37

Importance Sampling

Advanced Graphics – Variance Reduction 37

Importance Sampling for Monte Carlo

Monte Carlo without importance sampling: 𝐹 𝑔 𝑦 β‰ˆ 1 𝑂

𝑗=1 𝑂

𝑔 x𝑗 With importance sampling: 𝐹 𝑔 𝑦 β‰ˆ 1 𝑂

𝑗=1 𝑂 𝑔

x𝑗 π‘ž x𝑗 Here, π‘ž x𝑗 is the probability density function (PDF).

slide-38
SLIDE 38

Importance Sampling

Advanced Graphics – Variance Reduction 38

Probability Density Function

Properties of a valid PDF π‘ž(𝑦): 1. π‘ž 𝑦 > 0 for all 𝑦 ∈ 𝐸 where 𝑔(𝑦) β‰  0 2.

𝐸 π‘ž 𝑦 π‘’πœˆ 𝑦 = 1

Note: π‘ž(𝑦) is a density, not a probability; it can (and will) exceed 1 for some 𝑦. Applied to direct light sampling: π‘ž 𝑦 = 𝐷 for the part of the hemisphere covered by the light source  C = 1 / solid angle to ensure π‘ž(𝑦) integrates to 1  Since samples are divided py π‘ž(𝑦), we multiply by 1/(1/solid angle)):

slide-39
SLIDE 39

Importance Sampling

Advanced Graphics – Variance Reduction 39

Probability Density Function

Applied to hemisphere sampling: Light arriving over the hemisphere is cosine weighted.  Without further knowledge of the environment, the ideal PDF is the cosine function. 𝑄𝐸𝐺: π‘ž πœ„ = cos πœ„ Question: how do we normalize this?

𝛻

π‘‘π‘π‘‘πœ„π‘’πœ„ = 𝜌 β‡’

𝛻

π‘‘π‘π‘‘πœ„ 𝜌 π‘’πœ„ = 1 Question: how do we chose random directions using this PDF?

slide-40
SLIDE 40

Importance Sampling

Advanced Graphics – Variance Reduction 40

Cosine-weighted Random Direction

Without deriving this in detail: A cosine-weighted random distribution is obtained by generating points on the unit disc, and projecting the disc on the unit hemisphere. In code:

float3 CosineWeightedDiffuseReflection() { float r0 = Rand(), r1 = Rand(); float r = sqrt( r0 ); float theta = 2 * PI * r1; float x = r * cosf( theta ); float y = r * sinf( theta ); return float3( x, y, sqrt( 1 – r0 ) ); }

Note: you still have to transform this to tangent space.

slide-41
SLIDE 41

Importance Sampling

Advanced Graphics – Variance Reduction 41

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; PDF = 1 / (2 * PI); Ei = Sample( r ) * (Nβˆ™R) / PDF; return BRDF * Ei; } 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 = CosineWeightedDiffuseReflection( N ); Ray r( I, R ); // update throughput BRDF = material.albedo / PI; PDF = (Nβˆ™R) / PI; Ei = Sample( r ) * (Nβˆ™R) / PDF; return BRDF * Ei; }

slide-42
SLIDE 42

Today’s Agenda:

  • Introduction
  • Stratification
  • Next Event Estimation
  • Importance Sampling
  • MIS
slide-43
SLIDE 43

MIS

Advanced Graphics – Variance Reduction 43 sampling the lights sampling the hemisphere

specular glossy diffuse

slide-44
SLIDE 44

MIS

Advanced Graphics – Variance Reduction 44

Multiple Importance Sampling

Light sampling: paths to random points on the light yield high variance. Hemisphere sampling (with importance): random rays yield low variance.

slide-45
SLIDE 45

MIS

Advanced Graphics – Variance Reduction 45

Multiple Importance Sampling

Light sampling: paths to random points on the light yield low variance. Hemisphere sampling (with importance): random rays yield very high variance.

slide-46
SLIDE 46

MIS

Advanced Graphics – Variance Reduction 46

Multiple Importance Sampling

MIS: combining samples taken using multiple strategies.

  • 1. At point π‘ž, we encounter a light source via light sampling: here,

π‘žπ‘’π‘” ꙍ =

1 π‘‘π‘π‘šπ‘—π‘’ π‘π‘œπ‘•π‘šπ‘“.

  • 2. We also find a light source by sampling the BRDF: here,

π‘žπ‘’π‘” ꙍ = 1

2𝜌.

Since both methods are equivalent (they sample the same direction ꙍ), we can simply average the pdfs: π‘žπ‘’π‘” ꙍ = π‘₯ π‘ž1 + π‘₯ π‘ž2, π‘₯ = 0.5

slide-47
SLIDE 47

MIS

Advanced Graphics – Variance Reduction 47

Multiple Importance Sampling

MIS: combining samples taken using multiple strategies. Computing optimal weights for multiple importance sampling: π‘₯𝑗 𝑦 = π‘žπ‘—( 𝑦) π‘ž1 𝑦 + π‘ž2( 𝑦) This is known as the balance heuristic. Note that the balance heuristic simply assigns a greater weight to the pdf with the largest value at 𝑦.

slide-48
SLIDE 48

MIS

Advanced Graphics – Variance Reduction 48

Color Sample( Ray ray ) { // trace ray I, N, material = Trace( ray ); BRDF = material.albedo / PI; // terminate if ray left the scene if (ray.NOHIT) return BLACK; // terminate if we hit a light source if (material.isLight) return BLACK; // sample a random light source L, Nl, dist, A = RandomPointOnLight(); Ray lr( I, L, dist ); if (Nβˆ™L > 0 && Nlβˆ™-L > 0) if (!Trace( lr )) { solidAngle = ((Nlβˆ™-L) * A) / dist2; Ld = lightColor * solidAngle * BRDF * Nβˆ™L; } // continue random walk R = DiffuseReflection( N ); Ray r( I, R ); Ei = Sample( r ) * (Nβˆ™R); return PI * 2.0f * BRDF * Ei + Ld; } Color Sample( Ray ray ) { T = ( 1, 1, 1 ), E = ( 0, 0, 0 ); while (1) { I, N, material = Trace( ray ); BRDF = material.albedo / PI; if (ray.NOHIT) break; if (material.isLight) break; // sample a random light source L, Nl, dist, A = RandomPointOnLight(); Ray lr( I, L, dist ); if (Nβˆ™L > 0 && Nlβˆ™-L > 0) if (!Trace( lr )) { solidAngle = ((Nlβˆ™-L) * A) / dist2; lightPDF = 1 / solidAngle; E += T * (Nβˆ™L / lightPDF) * BRDF * lightColor; } // continue random walk R = DiffuseReflection( N ); hemiPDF = 1 / (PI * 2.0f); ray = Ray( I, R ); T *= ((Nβˆ™R) / hemiPDF) * BRDF; } return E; }

slide-49
SLIDE 49

MIS

Advanced Graphics – Variance Reduction 49

Multiple Importance Sampling

Earlier, we separated direct and indirect illumination:

  • Direct illumination is sampled using a PDF for a light source:

π‘žπ‘’π‘”

π‘šπ‘—π‘•β„Žπ‘’ 𝑦 = 1/π‘‘π‘π‘šπ‘—π‘’π‘π‘œπ‘•π‘šπ‘“, where 𝑦 is a direction towards the light.

  • Indirect illumination is sampled using a PDF proportional to the BRDF:

π‘žπ‘’π‘”

𝑐𝑠𝑒𝑔 𝑦 = 1/2𝜌, where 𝑦 is a uniform random direction on the hemisphere, or

π‘žπ‘’π‘”

𝑐𝑠𝑒𝑔 𝑦 = (𝑂 βˆ™ 𝑆)/𝜌, where 𝑦 is a random direction using a cosine weighted distribution.

When sampling the light, we can calculate π‘žπ‘’π‘”

𝑐𝑠𝑒𝑔 𝑦 for that same direction.

Likewise, when we encounter a light via the BRDF pdf, we can calculate π‘žπ‘’π‘”

π‘šπ‘—π‘•β„Žπ‘’(𝑦).

Using these quantities, we can now balance the pdfs.

slide-50
SLIDE 50

MIS

Advanced Graphics – Variance Reduction 50

Multiple Importance Sampling

When sampling the light, we can calculate π‘žπ‘’π‘”

𝑐𝑠𝑒𝑔 𝑦 for that same direction.

Likewise, when we encounter a light via the BRDF pdf, we can calculate π‘žπ‘’π‘”

π‘šπ‘—π‘•β„Žπ‘’(𝑦).

Example: next event estimation:

L, Nl, dist, A = RandomPointOnLight(); Ray lr( I, L, dist ); if (Nβˆ™L > 0 && Nlβˆ™-L > 0) if (!Trace( lr )) { solidAngle = ((Nlβˆ™-L) * A) / dist2; lightPDF = 1 / solidAngle; brdfPDF = 1 / (2 * PI); // or: (Nβˆ™L) / PI misPDF = lightPDF + brdfPDF; E += T * (Nβˆ™L / misPDF) * BRDF * lightColor; }

Note: PBR (and many others) uses a different formulation, using weights. This is the same as what we are doing here. PBR says: we sample function 𝑔 using 2 random directions 𝑦 and 𝑧, each picked from a pdf. Then: 𝐹 =

𝑔 𝑦 π‘₯𝑐𝑠𝑒𝑔 π‘žπ‘π‘ π‘’π‘”(𝑦) + 𝑔 𝑧 π‘₯π‘šπ‘—π‘•β„Žπ‘’ π‘žπ‘šπ‘—π‘•β„Žπ‘’(𝑧) , where π‘₯𝑐𝑠𝑒𝑔 + π‘₯π‘šπ‘—π‘•β„Žπ‘’ = 1 to compensate for

the fact that we are now taking two samples. Using the balance heuristic, π‘₯𝑐𝑠𝑒𝑔 =

π‘žπ‘π‘ π‘’π‘”(𝑦) π‘žπ‘π‘ π‘’π‘”(𝑦)+π‘žπ‘šπ‘—π‘•β„Žπ‘’(𝑧) and π‘₯π‘šπ‘—π‘•β„Žπ‘’ = π‘žπ‘šπ‘—π‘•β„Žπ‘’(𝑧) π‘žπ‘π‘ π‘’π‘”(𝑦)+π‘žπ‘šπ‘—π‘•β„Žπ‘’(𝑧).

Then, 𝐹 =

𝑔 𝑦

π‘žπ‘π‘ π‘’π‘”(𝑦) π‘žπ‘π‘ π‘’π‘”(𝑦)+π‘žπ‘šπ‘—π‘•β„Žπ‘’(𝑧)

π‘žπ‘π‘ π‘’π‘”(𝑦)

+

𝑔 𝑧

π‘žπ‘šπ‘—π‘•β„Žπ‘’(𝑧) π‘žπ‘π‘ π‘’π‘”(𝑦)+π‘žπ‘šπ‘—π‘•β„Žπ‘’(𝑧)

π‘žπ‘šπ‘—π‘•β„Žπ‘’(𝑧)

; this can be reduced to 𝐹 = 𝑔 𝑦

1 π‘žπ‘π‘ π‘’π‘”(𝑦)+π‘žπ‘šπ‘—π‘•β„Žπ‘’(𝑧) + 𝑔 𝑧 1 π‘žπ‘π‘ π‘’π‘”(𝑦)+π‘žπ‘šπ‘—π‘•β„Žπ‘’(𝑧).

Sampling 𝑔(𝑦) alone (when stumbling upon a light) thus yields 𝑔 𝑦 /(π‘žπ‘π‘ π‘’π‘”(𝑦) + π‘žπ‘šπ‘—π‘•β„Žπ‘’(𝑧)); sampling 𝑔(𝑧) alone (next event estimation) yields 𝑔(𝑦)/(π‘žπ‘π‘ π‘’π‘”(𝑦) + π‘žπ‘šπ‘—π‘•β„Žπ‘’(𝑧)).

slide-51
SLIDE 51

MIS

Advanced Graphics – Variance Reduction 51

slide-52
SLIDE 52

MIS

Advanced Graphics – Variance Reduction 52

slide-53
SLIDE 53

MIS

Advanced Graphics – Variance Reduction 53

slide-54
SLIDE 54

Today’s Agenda:

  • Introduction
  • Stratification
  • Next Event Estimation
  • Importance Sampling
  • MIS
slide-55
SLIDE 55

INFOMAGR – Advanced Graphics

Jacco Bikker - February – April 2016

END of β€œVariance Reduction”

next lecture: β€œVarious”