Rendering function:
Following progress is included in one single ray casting:
(Rigidly, Only the emission directly from light sources and direct illumination on surfaces is direct illumination)
For direct illumination
In function
But sample randomly in space is not efficient sampling method, we can restrict only sampling the ray to the light source.
We transform the differential of incident solid angle(
After sample point from the light source, we also need to check whether there's obstacle between the reflecting object and light source.
This is the direct illumination part.
For indirect illumination
In function
Since this progress is recursively, so we only sample one ray in both two kinds of illumination(N=1). And we stop the recursion by RussianRoulette.
Noticed: this sampled ray shouldn't hit the light source.
This is a kind of new material kind.
It differs in BRDF calculation.
Here is the reflection(specular) part of microfacet BRDF:
D: Normal distribution function(approximates the amount the surface's microfacets are aligned to the halfway vector)
G: Geometry function(describes the self-shadowing property)
F: Fresnel equation(the ratio of surface reflection at different surface angles)
D and G is controlled by a roughness parameter
Self shadowing considers both view and light:
Fresnel equation just take Fresnel-Schlick approximation here, instead of complex equation:
The refracted light plays an effect like diffuse light.
The sum of ratio of reflected and refracted light is 100%.
The final BRDF becomes:
Noticed:
In Monte Carlo integration, if we take pdf(x) = f(x), integrated function will be a constant function:
So a good approximation to integrated function is good for pdf(x) for sampled x.
When we consider the common diffuse material, We think the irradiance is reflected evenly in the whole hemisphere solid angle.
The variance triggered by uniform sample over solid angle
But for microfacet, the NDF is usually the dominant one(it has an extremely high peak when
Instead of sampling solid angle directly, we usually use spherical coordinate to sample it. So it is not the pdf respecting the solid angle that we are interested, it is the pdf respecting the spherical coordinates.
All we need to do is randomly sample probability
Don't forget to consider this new
[1] GAMES101
[2] Monte Carlo Methods in Practice
[6] Ubpa/RenderLab