Lec 16 Ray Tracing 4(Monte Carlo Path Tracing)
阅读信息
约 0 个字 3 分钟 本页总访问量:加载中... 次
Monte Carlo Integration
Why: we want to solve an integral, but it can be too difficult to solve \(\int_a^b f(x)dx\) analytically.
What & how: estimate the integral of a function by averaging random samples of the function's value.
Monte Carlo estimator:
- The more samples, the less variance.
- Sample on X, integration on X.
Path Tracing
Problems of Whitted-Style:
- Glossy texure (Utah teapot)
- Color bleeding (Cornell box)
A simple example: direct illumination
- \(f(x)\): \(L_i(\mathrm{p},\omega_i)f_r(\mathrm{p},\omega_i,\omega_o)(n\cdot\omega_i)\)
- \(pdf(\omega)\): \(1/2\pi\)
Monte Carlo integration:
Code:
Text Only | |
---|---|
Introduce global illumination:
The light reflect from Q to P, equals to the direct illumination ar Q observed at P.
Text Only | |
---|---|
Problems 1: Explosion of rays as bounces go up
Rays will not explode iff N = 1.
This is "path tracing".
Code:
Text Only | |
---|---|
Ray Generation
Text Only | |
---|---|
Problem 1: The recursion won't stop.
Solution: Russian Roulette (RR)
Suppose we manually set a probability P (0<P<1).
With probability P, shoot a ray and return the shading result divided by P is Lo / P.
With probability 1-P, don't shoot a ray adn you'll get 0.
In this way, you can still expect to get Lo:
E = P _ (Lo / P) + (1 - P) _ 0 = Lo
Code:
Text Only | |
---|---|
Problem 2: Inefficient. When SPP (samplees per pixel) is low, get noisy results
Only a few rays hit the light, so a lot of rays are "wasted".
Solution: sample on the light
Assume pdf = 1 / A. But the rendering equation intefrates on the solid angle.
To sample on the light and integrate on the light, need the relationship between \(d\omega\) and \(dA\).
Rewrite the rendering equation:
Code:
Final problem: need to test if the ray os not blocked in the middle.
Hard to handle point light source.
Things haven't covered:
- Uniformly sampling the hemisphere
-
How? And in gengral. how to sample any function?
-
Monte Carlo intefration allows arbitatry pdfs
-
What's the best choice? (importance sampling)
-
Do random numbers matter?
-
Yes (low discrepancy sequences)
-
Sample the hemimsphere and the light
-
Can I combine them? Yes (multipe immp. sampling)
-
The radiance of a pixel is the average of radiance on all paths passing through it
-
Why? (pixel reconstruction filter)
-
Is the radiance of a pixel the color of a pixel?
- No. (gamma correction, curves, color space)