**Homework 3** Student name: Cedric Hölzl Sciper number: 257844 Monte Carlo Sampling (60 pts) ============================= Tent ---- $$ p(x, y)=(p_1(x)\text{,} p_1(y)) \\ p_1(t) = \begin{cases} 1-|t|, & -1\le t\le 1\\ 0,&\text{otherwise}\\ \end{cases} \\ P_1(t) = \begin{cases} 1, & t \gt 1\\ \frac{1}{2}(t+1)^2 + 1, & 0 \le t \le 1\\ \frac{1}{2}(t+1)^2, & -1 \le t \lt 0\\ 0, & -1 \gt t\\ \end{cases} \\ P_1^{-1}(t) = \begin{cases} \sqrt{2t}-1, & 0 \le t \lt 0.5\\ 1 - \sqrt{2(1-t)}, & 0.5 \le t \le 1\\ \end{cases} $$ Tent X2 Uniform disk ------------ $$ p(x, y)= (p_1(\sqrt{x}, 2\pi y)\text{,} p_2(\sqrt{x}, 2\pi y)) \\ p_i(r, \theta) = \begin{cases} r * \cos(\theta), & i = 1\\ r * \sin(\theta), & i = 2\\ \end{cases} \\ P_i^{-1}(x, y) = \begin{cases} 0, & x^2 + y^2 \gt 1\\ \frac{1}{\pi}, & otherwhise\\ \end{cases} $$ Disk X2 Uniform sphere -------------- $$ p(x, y)= (p_1(\arccos(1-2x), 2\pi y)\text{,} p_2(\arccos(1-2x), 2\pi y)\text{,} p_3(\arccos(1-2x), 2\pi y)) \\ p_i(\theta, \phi) = \begin{cases} \sin(\theta)\cos(\phi), & i = 1\\ \sin(\theta)\sin(\phi), & i = 2\\ \cos(\theta), & i = 3\\ \end{cases} \\ P_i^{-1}(x, y, z) = \frac{1}{4\pi} $$ Sphere X2 Uniform hemisphere ------------------ $$ p(x, y) = (p_1(\arccos(1-x), 2\pi y)\text{,} p_2(\arccos(1-x), 2\pi y)\text{,} p_3(\arccos(1-x), 2\pi y)) \\ p_i(\theta, \phi) = \begin{cases} \sin(\theta)\cos(\phi), & i = 1\\ \sin(\theta)\sin(\phi), & i = 2\\ \cos(\theta), & i = 3\\ \end{cases} \\ P_i^{-1}(x, y, z) = \begin{cases} \frac{1}{2\pi}, & z \ge 0\\ 0, & otherwhise\\ \end{cases} $$ HemiSphere X2 Cosine hemisphere ----------------- $$ p(x, y)= (p_1(\sqrt{x}, 2\pi y)\text{,} p_2(\sqrt{x}, 2\pi y)\text{,} p_3(\sqrt{x}, 2\pi y)) \\ p_i(r, \theta) = \begin{cases} r * \cos(\theta), & i = 1\\ r * \sin(\theta), & i = 2\\ \sqrt{1 - r^2(\cos^2(\theta)-\sin^2(\theta))}, & i = 3\\ \end{cases} \\ P_i^{-1}(x, y, z) = \begin{cases} \frac{z}{2\pi}, & z \ge 0\\ 0, & otherwhise\\ \end{cases} $$ Cosine HemiSphere X2 Beckmann distribution --------------------- We start with de provided formulas and can build the PDF formula from it (thanks to the mapping hint): $$ D(\theta, \phi) = \frac{1}{2\pi}\ \cdot\ \frac{2 e^{\frac{-\tan^2{\theta}}{\alpha^2}}}{\alpha^2 \cos^3 \theta} \\ P_i^{-1}(x, y, z, a) = \frac{e^{\frac{-((x^2 + y^2)/(z^2))}{a^2}}}{\pi a^2 z^3} $$ To find the warp method, we multiply it by $2\pi$ (equivalent to integrating over $\phi$) and integrate it (as seen in the explanation) to find the following mappings for $\phi$ and $\theta$: $$ \theta = \arctan(\sqrt{(-a^2 \log(1-y))}) \\ \phi = 2\pi x $$ So finaly, we can build our warp using those new mappings: $$ p(x, y, a) = (p_1(\arctan(\sqrt{(-a^2 \log(1-y))}), 2\pi x)\text{,}\\ p_2(\arctan(\sqrt{(-a^2 \log(1-y))}), 2\pi x)\text{,}\\ p_3(\arctan(\sqrt{(-a^2 \log(1-y))}), 2\pi x)) \\ p_i(\theta, \phi) = \begin{cases} \sin(\theta)\cos(\phi), & i = 1\\ \sin(\theta)\sin(\phi), & i = 2\\ \cos(\theta), & i = 3\\ \end{cases} $$ Beckmann (coef 1.0) X2 Beckmann (coef 0.5) X2 Beckmann (coef 0.05) X2 Two simple rendering algorithms (40 pts) ======================================== Point lights ------------ Ajax bust illuminated by a point light source:
Reference Mine
We can see that the pictures match. Ambient occlusion ----------------- Ajax bust rendered using ambient occlusion:
Reference Mine
We can see that the pictures match. Hacker Points ------------- I tried implementing the Hierarchical Sample Warping, I couldn't find the issue with the PDF function. Also the matrix to be used is currently entered by hand and not parsed from a file. We use a single array containing the Mipmap until we have only a 2x2 image. I couldnt make it function for a 512x512 image(matrix). Unfortunately I didn't have more time to debug and resolve those issues. Cosine HemiSphere X2 Feedback ======== * Time taken: 6h designing, had some trouble with some PDF functions, especialy for the HSW. Coding from this was relativly quick and took 4h. Finaly testing was fast since I just needed to run executables. * Sources or documents to help with HSW would have been great, I tried to look on the internet and in the book of the course but found not a great amount of information. * The hardest part was the math. The integrators were easier to implement than expected thanks to the warp functions we made. * I enjoyed seing the points build a grid with disformation(warp).