The radiosity model is defined by a Fredholm Integral equation of the second kind:
This equation represents the stable distribution of light within environment and needs to be solved to solve the global illumination problem.
These are the steps I followed to solve the equation:
To solve the problem, I used the finite element method to discretize my radiosity model into a sum of easier polynomial functions of the form:
Galerkin Form of Weighted Residuals.
I needed to define an error metric to approximate my radiosity model, I chose the Galerkin Form of weighted residuals to minimize the error as an average across element surface, so:
And the entries in E are:
We can simplify the above equation by assuming constant basis functions, and constant reflectivities and emissivities within element.
Where πΏππ is the Kronecker Delta function:
Then:
Making these substitutions in equation 6:
Dividing through π΄π and moving emission term to the right side gives:
Which is:
The Form-Factor
The Hemi-Cube Algorithm
If the distance between two elements is much larger than the sizes of each element, I can integrate over Area π only. For that I used equation 17 and set a hemi-cube around the normal in patch π and meshed each of its faces into square pixels (100 x 100 per face).
The hemicube contains 5 faces, 1 full face and 4 half-faces. The area of each pixel determines the multiple to multiply the form factor by, so the form factor for each pixel can be calculated as:
Each πΉπππ₯ππ value goes into a matrix of form factors. (e.x. if we are on element π and we see element π through pixel π then πΉπππ₯ππ π value goes into row π column π of Form Factor Matrix.)
Making this calculation for all elements in scene, we get filled a full n by n Form Factor Matrix, the resulting matrix can be seen in the next image (NOTE: it is possible that the values cannot be seen because they are relatively low values, but that is good because the sum of each row needs to be less than one to make the system converge):
NOTE: The matrix images are color coded. Red means negative value, Blue means positive value greater than 1.0 and gray scale means between 0 and 1 with 1 meaning white and 0 meaning black.
The Energy Balance solution
Where K is defined to be:
M is the identity matrix; P is a diagonal matrix with reflectivities on its diagonal and F is the matrix of form factors. Thus, K looks like:
Using the form factor matrix computed before we can do matrix operations to compute πΎ which leads to this matrix:
The matrix K is diagonally dominant; thus, it is well suited to iterative methods as Gauss-Seidel, which is the method I used to solve the system of linear equations.
The Gauss-Seidel Method is really fast with K matrix (only one iteration). Now to make it converge the spectral radius of K π(πΎ) must be less than 1. Therefore, the largest absolute value for an eigenvalue of K must be less than one.
Stimuli-Dependent
There is a system of linear equations per stimuli required, so for the radiosity code I solved three systems of linear equations (red, green and blue).
Rendering
The vertex values are used to bilinearly interpolate vertex colors when the rendering pass requests a color from the scene in a specific direction.
These are vertex colors for face xy with z = 0 without interpolation. (I only render Upper Left Vertex Color for each Quad in this case):
And this is face xz with y equal 0:
Now with interpolation respectively:
The radiosity solution is view-independent, therefore changing the view position does not need a new computation of radiosities nor form factors.
The Mesh is generated procedurally, for this image I used 10 elements per face side, each face side is 10 units long.
Thank you!
If you want to look at the code:
Bibliography:
- Hughes, J. F., & Dam, A. V. (2014). Computer Graphics Principles and Practice Third Edition (3rd ed.). Pearson Education.
- Pharr, M., & Jakob, W. (2017). Physically Based Rendering From Theory to Implementation (3rd ed.). Cambridge, MA: Morgan Kaufmann.
- DutrΓ©, P., & Bala, K. (2006). Advanced Global Illumination (2nd. ed.). Wellesley, Massachusetts: A K Peters.
- Neumann, L., Feda, M., Kopp, M., & Purgathofer, W. (1995). A New Stochastic Radiosity Method for Highly Complex Scenes. G. Sakas Et Al. (eds.), Photorealistic Rendering Techniques.
- Cohen, M. F., & Wallace, J. R. (1993). Radiosity and Realistic Image Synthesis. Cambridge, MA: AP Professional.
- Cohen, M. F., & Greenberg, D. P. (1985). The Hemi-Cube a radiosity solution for complex environments. Cornell University, Ithaca, N.Y.: ACM.
- Strang, G. (2016). Introduction to Linear Algebra. (5th ed.). Wellesley, MA: WellesleyCambridge Press.
- Stroustrup, B. (2013). The C++ Programming Language. (4th ed.). Pearson Education.
No comments:
Post a Comment