|
1345 | 1345 | PDF can also vary with _incident direction_: $\mathit{pScatter}(\omega_i, \omega_o)$. You can see
|
1346 | 1346 | this varying with incident direction when you look at reflections off a road -- they become
|
1347 | 1347 | mirror-like as your viewing angle (incident angle) approaches grazing. Lastly, the scattering PDF
|
1348 |
| -can also depend on the scattering position: $\mathit{pScatter}(\textbf{x}, \omega_i, \omega_o)$. The |
1349 |
| -$\textbf{x}$ is just a vector representing the scattering position: $\textbf{x} = (x, y, z)$. The |
1350 |
| -Albedo of an object can also depend on these quantities: $A(\textbf{x}, \omega_i, \omega_o)$. |
| 1348 | +can also depend on the scattering position: $\mathit{pScatter}(\mathbf{x}, \omega_i, \omega_o)$. The |
| 1349 | +$\mathbf{x}$ is just a vector representing the scattering position: $\mathbf{x} = (x, y, z)$. The |
| 1350 | +Albedo of an object can also depend on these quantities: $A(\mathbf{x}, \omega_i, \omega_o)$. |
1351 | 1351 |
|
1352 | 1352 | <div class='together'>
|
1353 | 1353 | The color of a surface is found by integrating these terms over the unit hemisphere by the incident
|
1354 | 1354 | direction:
|
1355 | 1355 |
|
1356 |
| - $$ \text{Color}_o(\textbf{x}, \omega_o) = \int_{\omega_i} |
1357 |
| - A(\textbf{x}, \omega_i, \omega_o) \cdot |
1358 |
| - \mathit{pScatter}(\textbf{x}, \omega_i, \omega_o) \cdot |
1359 |
| - \text{Color}_i(\textbf{x}, \omega_i) $$ |
| 1356 | + $$ \text{Color}_o(\mathbf{x}, \omega_o) = \int_{\omega_i} |
| 1357 | + A(\mathbf{x}, \omega_i, \omega_o) \cdot |
| 1358 | + \mathit{pScatter}(\mathbf{x}, \omega_i, \omega_o) \cdot |
| 1359 | + \text{Color}_i(\mathbf{x}, \omega_i) $$ |
1360 | 1360 |
|
1361 | 1361 | We've added a $\text{Color}_i$ term. The scattering PDF and the albedo at the surface of an object
|
1362 | 1362 | are acting as filters to the light that is shining on that point. So we need to solve for the light
|
|
1373 | 1373 | <div class='together'>
|
1374 | 1374 | If we apply the Monte Carlo basic formula we get the following statistical estimate:
|
1375 | 1375 |
|
1376 |
| - $$ \text{Color}_o = \frac{A(\textbf{x}, \omega_i, \omega_o) \cdot |
1377 |
| - \mathit{pScatter}(\textbf{x}, \omega_i, \omega_o) \cdot |
1378 |
| - \text{Color}_i(\textbf{x}, \omega_i)} |
1379 |
| - {p(\textbf{x}, \omega_o)} $$ |
| 1376 | + $$ \text{Color}_o = \frac{A(\mathbf{x}, \omega_i, \omega_o) \cdot |
| 1377 | + \mathit{pScatter}(\mathbf{x}, \omega_i, \omega_o) \cdot |
| 1378 | + \text{Color}_i(\mathbf{x}, \omega_i)} |
| 1379 | + {p(\mathbf{x}, \omega_o)} $$ |
1380 | 1380 |
|
1381 |
| -where $p(\textbf{x}, \omega_o)$ is the PDF of whatever outgoing direction we randomly generate. |
1382 |
| -We'll simplify to just $p(\omega_o)$ because we won't be varying the PDF by $\textbf{x}$. |
| 1381 | +where $p(\mathbf{x}, \omega_o)$ is the PDF of whatever outgoing direction we randomly generate. |
| 1382 | +We'll simplify to just $p(\omega_o)$ because we won't be varying the PDF by $\mathbf{x}$. |
1383 | 1383 | </div>
|
1384 | 1384 |
|
1385 | 1385 | For a Lambertian surface we already implicitly implemented this formula for the special case where
|
|
1414 | 1414 |
|
1415 | 1415 | The numerator and denominator cancel out, and we get:
|
1416 | 1416 |
|
1417 |
| - $$ \text{Color}_o = A(\textbf{x}, \omega_i, \omega_o) \cdot |
1418 |
| - \text{Color}_i(\textbf{x}, \omega_i) $$ |
| 1417 | + $$ \text{Color}_o = A(\mathbf{x}, \omega_i, \omega_o) \cdot |
| 1418 | + \text{Color}_i(\mathbf{x}, \omega_i) $$ |
1419 | 1419 |
|
1420 | 1420 | This is exactly what we had in our original `ray_color()` function!
|
1421 | 1421 |
|
|
1427 | 1427 | volumes. If you read the literature, you’ll see reflection defined by the
|
1428 | 1428 | _Bidirectional Reflectance Distribution Function_ (BRDF). It relates pretty simply to our terms:
|
1429 | 1429 |
|
1430 |
| - $$ BRDF(\omega_i, \omega_o) = \frac{A(\textbf{x}, \omega_i, \omega_o) \cdot |
1431 |
| - \mathit{pScatter}(\textbf{x}, \omega_i, \omega_o)}{\cos(\theta_o)} $$ |
| 1430 | + $$ BRDF(\omega_i, \omega_o) = \frac{A(\mathbf{x}, \omega_i, \omega_o) \cdot |
| 1431 | + \mathit{pScatter}(\mathbf{x}, \omega_i, \omega_o)}{\cos(\theta_o)} $$ |
1432 | 1432 |
|
1433 | 1433 | So for a Lambertian surface for example, $BRDF = A / \pi$. Translation between our terms and BRDF is
|
1434 | 1434 | easy. For participating media (volumes), our albedo is usually called the _scattering albedo_, and
|
|
1459 | 1459 | we can use any PDF: _all PDFs eventually converge to the correct answer_. So, the game is to figure
|
1460 | 1460 | out how to make the PDF larger where the product
|
1461 | 1461 |
|
1462 |
| - $$ \mathit{pScatter}(\textbf{x}, \omega_i, \omega_o) \cdot |
1463 |
| - \text{Color}_i(\textbf{x}, \omega_i) $$ |
| 1462 | + $$ \mathit{pScatter}(\mathbf{x}, \omega_i, \omega_o) \cdot |
| 1463 | + \text{Color}_i(\mathbf{x}, \omega_i) $$ |
1464 | 1464 |
|
1465 | 1465 | is largest. For diffuse surfaces, this is mainly a matter of guessing where
|
1466 |
| -$\text{Color}_i(\textbf{x}, \omega_i)$ is largest. Which is equivalent to guessing where the most |
| 1466 | +$\text{Color}_i(\mathbf{x}, \omega_i)$ is largest. Which is equivalent to guessing where the most |
1467 | 1467 | light is coming from.
|
1468 | 1468 |
|
1469 | 1469 | For a mirror, $\mathit{pScatter}()$ is huge only near one direction, so $\mathit{pScatter}()$
|
|
0 commit comments