Evaluating the Rendering Equation by hand (simple case) | pressku.com

Trending 4 months ago

I'm trying to make intuitive consciousness of nan rendering equation and truthful I'm trying to activity retired a trivial illustration by hand, though yet I'm conscionable trying to understand really monte carlo value sampling is applied.

Lets disregard for emittance, and truthful nan rendering equation is simply:

$$ L_o(x, \omega_o) = \int_{\Omega} f(x,\omega_o,\omega_i)L_i(x,\omega_i) \left(\omega_i \cdot \hat{n}\right) \ d\omega_i $$

Now for my purposes, I'm considering a spherical ray pinch a radius $R$ and a twinkling powerfulness of $\Phi$, that is $d$ distant from constituent $x$ straight on nan aboveground normal vector $\hat{n}$. I'm besides assuming nan BRDF is lambertian:

$$ f_r = \frac{\rho}{\pi} $$

where $\rho$ is nan surface's albedo. In this case, nan integral simply becomes:

$$ L_r = \frac{\rho}{\pi}\int_{\Omega}L_i(x,\omega_i) \left(\omega_i \cdot \hat{n}\right) \ d\omega_i $$

where $L_r$ is nan full reflected radiance. If I presume that nan twinkling powerfulness of nan ray is changeless crossed its full aboveground (and frankincense crossed nan full coagulated perspective it subtends) I tin propulsion that retired of nan integral arsenic well, leaving maine with:

$$ L_r = \frac{\rho}{\pi} L_i \int_{\Omega} \left(\omega_i \cdot \hat{n}\right) \ d\omega_i $$

Given that nan ray is located straight supra nan point, on $\hat{n}$, past each of nan ray incident connected $x$ is wrong $\delta$ of $\hat{n}$, wherever $\delta$ is nan half nan angular diameter of nan light. The angular diameter is defined as:

$$ \delta = \sin^{-1}\left(\frac{R}{d}\right) $$

Therefore, our integral tin beryllium rewritten as: $$ L_r = \frac{\rho}{\pi} L_i \int_0^{2\pi} \int_0^{\delta} \cos{\theta_i}\sin{\theta_i} \ d\theta d\phi $$

$$ = \frac{\rho}{\pi} L_i \int_0^{2\pi} \left[\frac{-\cos^2{\theta}}{2}\right]_0^\delta \ d\phi $$

$$ = \frac{\rho}{\pi} L_i \left(\pi \sin^2\left(\sin^{-1}\frac{R}{d}\right)\right) $$

$$ \boxed{L_r = \rho L_i \frac{R^2}{d^2}} $$

This looks arsenic though it could beryllium right, but I'm not sure. Now lets opportunity I want to setup a monte carlo estimator:

$$ F = \int f(x) dx \Rightarrow F \approx \frac{1}{N} \sum_{i=1}^N \frac{f(x_i)}{p(x_i)} $$

For our peculiar problem here, that would look for illustration this:

$$ L_r \approx \frac{\rho}{\pi} \frac{1}{N} \sum_{i=1}^N \frac{L_i(\omega_i)\cos{\theta_i}}{p(\omega_i)} $$

If I uniformly sample $\omega_i$ from nan hemisphere, past $p(\omega_i) = \frac{1}{2\pi}$ and truthful nan estimator simplifies to:

$$ L_r \approx 2\rho \frac{1}{N} \sum_{i=1}^N L_i(\omega_i)\cos{\theta_i} $$

If instead, I were to usage value sampling and straight sample nan light, I would request a much analyzable $p(\omega_i)$. My intuition tells maine it should beryllium 1 complete nan coagulated perspective subtended by nan ray divided by $2\pi$ (the coagulated perspective of nan full hemisphere):

$$ p(\omega_i) = \frac{1}{\Omega_{light} / 2\pi} = \frac{2\pi}{\Omega_{light}} $$

where $\Omega_{light}$ tin beryllium calculated using:

$$ \Omega_{light} = 2\pi\left(1 - \frac{\sqrt{d^2 - R^2}}{d}\right) $$

My rationale being, if each guidance successful nan hemisphere is arsenic likely, past nan probability of a ray hitting nan ray should beryllium adjacent to nan proportionality of nan hemisphere nan ray occupies.

Introducing this to our monte carlo estimator gives america an value sampled type written as:

$$ L_r \approx \frac{\rho}{\pi} \frac{\Omega_{light}}{2\pi} \frac{1}{N} \sum_{i=1}^N L_i(\omega_i)\cos{\theta_i} $$

Coding this up quickly, if I presume $\Phi = 100W$, $d = 100m$, $R = 10m$, $\rho = 0.4$, my analytical solution yields:

$$ L = 1.0132\times10^{-4} \frac{W}{sr\cdot m^2} $$

If I usage nan uniformly sampled monte carlo method pinch a cardinal samples, I get:

$$ L_{uniform} = 1.0141\times10^{-4} \frac{W}{sr\cdot m^2} $$

And if I usage nan value sampled version, I get:

$$ L_{importance} = 1.6126\times10^{-5} \frac{W}{sr\cdot m^2} $$

So $L_{uniform}$ matches nan analytical solution to wrong only .09%. So that gives maine immoderate assurance successful some solutions. However nan estimate from value sampling is disconnected by a cleanable facet of $2\pi$:

$$ \frac{1.0132\times10^{-4}}{1.6126\times10^{-5}} = 6.2832 \approx 2\pi $$

I'm not wholly judge wherever I went incorrect pinch my methods. Further, I'm confused of what happens erstwhile nan BRDF is not constant. How is it imaginable to decently merge this (either analytically aliases numerically) erstwhile your integral besides depends connected a BRDF that depends connected $\omega_o$ and $\omega_i$ arsenic well?