{"id":2976,"date":"2023-03-05T22:00:14","date_gmt":"2023-03-05T14:00:14","guid":{"rendered":"https:\/\/www.caiqinyi.cn\/?p=2976"},"modified":"2025-02-26T11:14:03","modified_gmt":"2025-02-26T03:14:03","slug":"ray_tracing_mark","status":"publish","type":"post","link":"https:\/\/www.caiqinyi.cn\/index.php\/2023\/03\/05\/ray_tracing_mark\/","title":{"rendered":"\u5149\u7ebf\u8ffd\u8e2a\u6ce8\u8bb0"},"content":{"rendered":"<p><script type=\"text\/javascript\" async src=\"https:\/\/www.caiqinyi.cn\/wp-content\/MathJax\/MathJax.js?config=TeX-AMS_CHTML\">\n<\/script><br \/>\n<script type=\"text\/x-mathjax-config\">\n    MathJax.Hub.Config({\n        tex2jax: {inlineMath: [['$','$']]},\n        TeX: {equationNumbers: {autoNumber: [\"AMS\"], useLabelIds: true}},\n        \"HTML-CSS\": {linebreaks: {automatic: true}},\n        SVG: {linebreaks: {automatic: true}}\n    });\n<\/script><\/p>\n<p>\u8fd9\u4e2a\u5468\u672b\u5e94\u8be5\u662f\u8eab\u4e3a\u7f51\u6613\u5458\u5de5\u7684\u6700\u540e\u4e00\u4e2a\u5468\u672b\u4e86, \u76ee\u524d\u7684\u5fc3\u6001\u597d\u4f3c\u65e9\u5df2\u4e22\u6389\u4e86\u4e0d\u5b89\u7684\u90e8\u5206, \u53ea\u5269\u4e0b\u5bf9\u4e0b\u5468\u4e09\u79bb\u804c\u7684\u5766\u7136, \u4e0e\u5bf9\u65b0\u751f\u6d3b\u7684\u671f\u5f85~ \u5fc3\u4e4b\u6240\u5411, \u65e0\u60e7\u65e0\u6094. \u56de\u5230\u6b63\u9898\u6765, \u672c\u6587\u4e3b\u8981\u7528\u4e8e\u8bb0\u5f55\u4e00\u4e9b\u5173\u4e8e\u5149\u7ebf\u8ffd\u8e2a\u7684\u77e5\u8bc6\u70b9.<\/p>\n<p><!--more--><\/p>\n<p><strong>\u53c2\u8003\u6750\u6599<\/strong><br \/>\n1. <a href=\"https:\/\/learnopengl-cn.github.io\/05%20Advanced%20Lighting\/01%20Advanced%20Lighting\/\">\u9ad8\u7ea7\u5149\u7167<\/a><\/p>\n<p><strong>1. \u8ba1\u7b97\u89c2\u5bdf\u5149\u7ebf<\/strong><\/p>\n<p>\u4e3a\u4e86\u751f\u6210\u5149\u7ebf, \u6211\u4eec\u9996\u5148\u9700\u8981\u4e00\u4e2a\u5173\u4e8e\u5149\u7ebf\u7684\u6570\u5b66\u8868\u8fbe\u5f0f. \u5b9e\u9645\u4e0a, \u5149\u7ebf\u4ec5\u88ab\u4e00\u4e2a\u539f\u70b9\u4e0e\u4e00\u4e2a\u65b9\u5411\u6240\u51b3\u5b9a, i.e. \u4ece\u89c2\u5bdf\u70b9$\\mathbf{e}$\u51fa\u53d1, \u7ecf\u8fc7\u50cf\u5e73\u9762\u4e0a\u70b9$\\mathbf{s}$\u7684\u4e09\u7ef4\u5149\u7ebf\u4e3a$$\\mathbf{p}(t) = \\mathbf{e} + t(\\mathbf{s} &#8211; \\mathbf{e}),$$\u5219$\\mathbf{s} &#8211; \\mathbf{e}$\u4e3a\u5149\u7ebf\u7684\u65b9\u5411. \u4e0a\u5f0f\u53ef\u4ee5\u89e3\u91ca\u4e3a: \u6211\u4eec\u4ece\u89c2\u5bdf\u70b9$\\mathbf{e}$\u51fa\u53d1, \u6cbf\u7740\u5411\u91cf$\\mathbf{s} &#8211; \\mathbf{e}$\u524d\u8fdb\u8ddd\u79bb$t$\u5230\u8fbe\u70b9$\\mathbf{p}$.<br \/>\n$\\\\$ \u6ce8\u610f\u5230$\\mathbf{p}(0) = \\mathbf{e}$, $\\mathbf{p}(1) = \\mathbf{s}$, \u66f4\u4e00\u822c\u5730, \u82e5$0 < t_1 < t_2$, \u90a3\u4e48$\\mathbf{p}(t_1)$\u6bd4$\\mathbf{p}(t_2)$\u66f4\u63a5\u8fd1\u89c2\u5bdf\u70b9$\\mathbf{e}$. \u540c\u6837\u5730, \u82e5$t < 0$, \u90a3\u4e48$\\mathbf{p}(t)$\u5728\u89c2\u5bdf\u70b9$\\mathbf{e}$\u540e. \u5f53\u6211\u4eec\u5bfb\u627e\u5149\u7ebf\u51fb\u4e2d\u7684\u79bb\u89c2\u5bdf\u70b9$\\mathbf{e}$\u6700\u8fd1\u4e14\u4e0d\u5728$\\mathbf{e}$\u540e\u9762\u7684\u7269\u4f53\u65f6, \u8fd9\u4e9b\u6027\u8d28\u5c06\u5341\u5206\u6709\u7528.\n$\\\\$ \u63a5\u4e0b\u6765, \u6211\u4eec\u9700\u8981\u786e\u5b9a\u56fe\u50cf\u5728\u50cf\u5e73\u9762\u4e0a\u7684\u4f4d\u7f6e(\u5373\u786e\u5b9a\u50cf\u5e73\u9762\u4e0a\u7684\u70b9$\\mathbf{s}$). \u8bbe\u50cf\u5e73\u9762\u4e0a\u7684\u4e00\u70b9\u4e3a$O$, \u4ee5\u70b9$O$\u4e3a\u8d77\u70b9\u7684\u4e24\u6761\u76f8\u4e92\u5782\u76f4\u7684\u5c04\u7ebf\u4e3a$$\\mathbb{r}_1(t) = O + t \\mathbf{u}, \\\\ \\mathbb{r}_2(t) = O + t \\mathbf{v},$$\u5176\u4e2d, $\\mathbf{u}$, $\\mathbf{v}$\u5206\u522b\u4e3a\u4e24\u6761\u5c04\u7ebf$\\mathbb{r}_1(t)$, $\\mathbb{r}_2(t)$\u5bf9\u5e94\u7684\u65b9\u5411\u5411\u91cf. \u56fe\u50cf\u5de6, \u53f3\u8fb9\u7f18\u6240\u5728\u7684\u76f4\u7ebf\u4e0e\u5c04\u7ebf$\\mathbb{r}_1(\\mathbf{s})$\u6240\u5728\u7684\u76f4\u7ebf\u7684\u4ea4\u70b9\u5206\u522b\u4e3a$O + L \\mathbf{u}$, $O $$ + R \\mathbf{u}$; \u56fe\u50cf\u4e0a, \u4e0b\u8fb9\u7f18\u6240\u5728\u7684\u76f4\u7ebf\u4e0e\u5c04\u7ebf$\\mathbb{r}_2(t)$\u6240\u5728\u7684\u76f4\u7ebf\u7684\u4ea4\u70b9\u5206\u522b\u4e3a$O + $$ T \\mathbf{v}$, $O + B \\mathbf{v}$. \u4e00\u822c\u6765\u8bf4, $L < $$ 0 < R$, $B < 0 < T$.\n$\\\\$ \u4e3a\u4e86\u5c06\u542b\u6709$n_x \\times n_y$\u4e2a\u50cf\u7d20\u7684\u56fe\u50cf\u653e\u5165\u5927\u5c0f\u4e3a$(R \u2212 L) \\times $$ (T \u2212 B)$\u7684\u77e9\u5f62\u4e2d, \u50cf\u7d20\u95f4\u7684\u6c34\u5e73\u95f4\u9694\u5e94\u4e3a$(R \u2212 L) \/ n_x$, \u5782\u76f4\u95f4\u9694\u5e94\u4e3a$(T \u2212 B $$ ) \/ n_y$. \u8fd9\u6837\u4e00\u6765, \u6211\u4eec\u4e5f\u5c06\u77e9\u5f62\u5212\u5206\u4e3a$n_x \\times n_y$\u4e2a\u683c\u5b50. \u6b64\u5916, \u5728\u56fe\u50cf\u8fb9\u7f18\u5904\u8fd8\u9700\u7559\u51fa\u534a\u4e2a\u50cf\u7d20\u5927\u5c0f\u7684\u7a7a\u95f4, \u4f7f\u5f97\u6bcf\u4e00\u4e2a\u50cf\u7d20\u5747\u5728\u6240\u5904\u7684\u77e9\u5f62\u683c\u5b50\u5185\u5c45\u4e2d, \u5373\u5149\u6805\u5316\u56fe\u50cf\u4e2d\u5750\u6807\u4e3a$(i, $$ j)$\u7684\u50cf\u7d20\u7684\u4f4d\u7f6e\u4e3a$$u = L + (R \u2212 L)(i + 0.5) \/ n_x, \\\\ v = B + (T \u2212 B)(j + 0.5) \/ n_y,$$\u5176\u4e2d, $(u, v)$\u4e3a\u50cf\u7d20\u5728\u50cf\u5e73\u9762\u4e0a\u7684\u4f4d\u7f6e\u5750\u6807.\n\n$\\\\$\n$\\\\$ <strong>2. \u5149\u7ebf\u4e0e\u7269\u4f53\u7684\u76f8\u4ea4\u8ba1\u7b97<\/strong><\/p>\n<p><strong>2.1 \u5149\u7ebf\u4e0e\u7403\u7684\u76f8\u4ea4\u8ba1\u7b97<\/strong><\/p>\n<p>\u7ed9\u5b9a\u4e00\u6761\u5149\u7ebf$\\mathbf{p}(t) = \\mathbf{e} + t\\mathbf{d}$\u4e0e\u4e00\u4e2a\u9690\u5f0f\u66f2\u9762$f(\\mathbf{p}) = 0$, \u5176\u4ea4\u70b9\u9700\u8981\u540c\u65f6\u5728\u5149\u7ebf\u4e0e\u9690\u5f0f\u66f2\u9762\u4e0a, \u6545\u5f85\u6c42\u7684$t$\u6ee1\u8db3\u4e0b\u8ff0\u65b9\u7a0b$$f(\\mathbf{p}(t)) = 0, f(\\mathbf{e} + t\\mathbf{d}) = 0.$$\u4e00\u4e2a\u7403\u5fc3\u4e3a$\\mathbf{c} = (x_\\mathbf{c}, y_\\mathbf{c}, z_\\mathbf{c})^T$, \u534a\u5f84\u4e3a$R$\u7684\u7403\u53ef\u4ee5\u4f7f\u7528\u4e0b\u8ff0\u9690\u5f0f\u65b9\u7a0b\u8868\u793a:$$(x &#8211; x_\\mathbf{c})^2 + (y &#8211; y_\\mathbf{c})^2 + (z &#8211; z_\\mathbf{c})^2 &#8211; R^2 = 0.$$\u6211\u4eec\u53ef\u4ee5\u628a\u4e0a\u8ff0\u65b9\u7a0b\u5199\u4e3a\u5411\u91cf\u5f62\u5f0f:$$(\\mathbf{p} &#8211; \\mathbf{c}) \\cdot (\\mathbf{p} &#8211; \\mathbf{c}) &#8211; R^2 = 0.$$\u7403\u9762\u4e0a\u7684\u4efb\u610f\u70b9$\\mathbf{p}$\u5747\u6ee1\u8db3\u4e0a\u8ff0\u65b9\u7a0b. \u82e5\u6211\u4eec\u628a\u5149\u7ebf$\\mathbf{p}(t) = \\mathbf{e} + t\\mathbf{d}$\u4e0a\u7684\u70b9\u4ee3\u5165\u4e0a\u8ff0\u65b9\u7a0b, \u6211\u4eec\u53ef\u4ee5\u5f97\u5230\u4e00\u4e2a\u5173\u4e8e$t$\u7684\u65b9\u7a0b:$$(\\mathbf{e} + t\\mathbf{d} &#8211; \\mathbf{c}) \\cdot (\\mathbf{e} + t\\mathbf{d} &#8211; \\mathbf{c}) &#8211; R^2 = 0.$$\u5408\u5e76\u540c\u7c7b\u9879\u53ef\u5f97$$(\\mathbf{d} \\cdot \\mathbf{d})t^2 + 2\\mathbf{d} \\cdot (\\mathbf{e} &#8211; \\mathbf{c})t + (\\mathbf{e} &#8211; \\mathbf{c}) \\cdot (\\mathbf{e} &#8211; \\mathbf{c}) &#8211; R^2 = 0.$$\u89e3\u4e4b,$$t = \\frac{-\\mathbf{d} \\cdot (\\mathbf{e} &#8211; \\mathbf{c}) \\pm \\sqrt{(\\mathbf{d} \\cdot (\\mathbf{e} &#8211; \\mathbf{c}))^2 &#8211; (\\mathbf{d} \\cdot \\mathbf{d})((\\mathbf{e} &#8211; \\mathbf{c}) \\cdot (\\mathbf{e} &#8211; \\mathbf{c}) &#8211; R^2)}}{(\\mathbf{d} \\cdot \\mathbf{d})}.$$\u5b9e\u9645\u8ba1\u7b97\u4e2d, \u5728\u8ba1\u7b97\u5176\u5b83\u9879\u4e4b\u524d, \u5e94\u8be5\u9996\u5148\u68c0\u67e5\u5224\u522b\u5f0f\u7684\u503c. \u82e5\u7403\u4f53\u4ec5\u88ab\u7528\u4f5c\u66f4\u590d\u6742\u7684\u5bf9\u8c61\u7684Bounding Sphere, \u90a3\u4e48\u6211\u4eec\u4ec5\u9700\u8981\u786e\u5b9a\u662f\u5426\u547d\u4e2d\u5b83(\u68c0\u67e5\u5224\u522b\u5f0f) \u5c31\u8db3\u591f\u4e86. \u6b64\u5916, \u70b9$\\mathbf{p}$\u5904\u7684\u5355\u4f4d\u6cd5\u5411\u91cf\u4e3a$(\\mathbf{p} \u2212 $$ \\mathbf{c}) \/ R$.<\/p>\n<p><strong>2.2 \u5149\u7ebf\u4e0e\u4e09\u89d2\u5f62\u7684\u76f8\u4ea4\u8ba1\u7b97<\/strong><\/p>\n<p>\u4e3a\u4e86\u6c42\u5f97\u5149\u7ebf$\\mathbf{e} + t\\mathbf{d}$\u4e0e\u53c2\u6570\u66f2\u9762$F(u, v)$\u7684\u4ea4\u70b9, \u6211\u4eec\u53ef\u4ee5\u5efa\u7acb\u4e00\u4e2a\u57fa\u4e8e\u7b1b\u5361\u5c14\u5750\u6807\u7cfb\u7684\u65b9\u7a0b\u7ec4:$$\\left.\\begin{matrix}<br \/>\nx_\\mathbf{e} + tx_\\mathbf{d} = f(u, v) \\\\<br \/>\ny_\\mathbf{e} + ty_\\mathbf{d} = g(u, v) \\\\<br \/>\nz_\\mathbf{e} + tz_\\mathbf{d} = h(u, v)<br \/>\n\\end{matrix}\\right\\} \\ or, \\  \\mathbf{e} + t\\mathbf{d} = F(u, v).$$\u8fd9\u6837\u4e00\u6765, \u6211\u4eec\u5f97\u5230\u4e863\u4e2a\u65b9\u7a0b\u4e0e3\u4e2a\u672a\u77e5\u6570($t$, $u$\u4e0e$v$), \u5f53\u4f7f\u7528\u89e3\u6790\u7684\u65b9\u6cd5\u65e0\u6cd5\u5f97\u5230\u89e3\u6216\u8005\u5f97\u5230\u89e3\u7684\u4ee3\u4ef7\u8f83\u9ad8\u65f6, \u6211\u4eec\u4ea6\u53ef\u4ee5\u4f7f\u7528\u6570\u503c\u65b9\u6cd5\u8fdb\u884c\u6c42\u89e3.<br \/>\n$\\\\$ \u82e5\u4e09\u89d2\u5f62\u7684\u4e09\u4e2a\u9876\u70b9\u5206\u522b\u4e3a$\\mathbf{a}$, $\\mathbf{b}$\u4e0e$\\mathbf{c}$, \u5219\u5176\u4ea4\u70b9\u6ee1\u8db3\u4e0b\u8ff0\u65b9\u7a0b:$$\\mathbf{e} + t\\mathbf{d} = \\mathbf{a} + \\beta(\\mathbf{b} &#8211; \\mathbf{a}) + \\gamma(\\mathbf{c} &#8211; \\mathbf{a}).$$\u6613\u77e5, \u4ea4\u70b9\u5728\u4e09\u89d2\u5f62\u5185\u5f53\u4e14\u4ec5\u5f53$\\beta > 0$, $\\gamma > 0$, \u4e14$\\beta + \\gamma < 1$. \u5426\u5219, \u4ea4\u70b9\u5c06\u5728\u4e09\u89d2\u5f62\u5916\u6216\u4e09\u89d2\u5f62\u8fb9\u754c\u4e0a. \u82e5\u4e0a\u8ff0\u65b9\u7a0b\u65e0\u89e3, \u8981\u4e48\u4e09\u89d2\u5f62\u662f\u9000\u5316\u7684, \u8981\u4e48\u5149\u7ebf\u5e73\u884c\u4e8e\u4e09\u89d2\u5f62\u6240\u5728\u7684\u5e73\u9762.\n$\\\\$ \u4e3a\u4e86\u6c42\u5f97$t$, $\\beta$\u4e0e$\\gamma$, \u6211\u4eec\u5c06\u4e0a\u8ff0\u65b9\u7a0b\u4ece\u5411\u91cf\u5f62\u5f0f\u5c55\u5f00\u4e3a3\u4e2a\u65b9\u7a0b:$$x_\\mathbf{e} + tx_\\mathbf{d} = x_\\mathbf{a} + \\beta(x_\\mathbf{b} - x_\\mathbf{a}) + \\gamma(x_\\mathbf{c} - x_\\mathbf{a}), \\\\ y_\\mathbf{e} + ty_\\mathbf{d} = y_\\mathbf{a} + \\beta(y_\\mathbf{b} - y_\\mathbf{a}) + \\gamma(y_\\mathbf{c} - y_\\mathbf{a}), \\\\ z_\\mathbf{e} + tz_\\mathbf{d} = z_\\mathbf{a} + \\beta(z_\\mathbf{b} - z_\\mathbf{a}) + \\gamma(z_\\mathbf{c} - z_\\mathbf{a}).$$\u4e0a\u8ff0\u65b9\u7a0b\u7ec4\u53ef\u4ee5\u6807\u51c6\u7ebf\u6027\u7cfb\u7edf\u7684\u5f62\u5f0f\u5199\u4e3a:$$\\begin{bmatrix}\nx_\\mathbf{a} - x_\\mathbf{b} &#038; x_\\mathbf{a} - x_\\mathbf{c} &#038; x_\\mathbf{d} \\\\\ny_\\mathbf{a} - y_\\mathbf{b} &#038; y_\\mathbf{a} - y_\\mathbf{c} &#038; y_\\mathbf{d} \\\\\nz_\\mathbf{a} - z_\\mathbf{b} &#038; z_\\mathbf{a} - z_\\mathbf{c} &#038; z_\\mathbf{d} \n\\end{bmatrix} \\begin{bmatrix}\n\\beta \\\\\n\\gamma \\\\\nt\n\\end{bmatrix} = \\begin{bmatrix}\nx_\\mathbf{a} - x_\\mathbf{e} \\\\\ny_\\mathbf{a} - y_\\mathbf{e} \\\\\nz_\\mathbf{a} - z_\\mathbf{e}\n\\end{bmatrix}.$$\u6c42\u89e3\u8fd9\u4e2a$3 \\times 3$\u7684\u7ebf\u6027\u65b9\u7a0b\u7ec4\u6700\u5feb\u7684\u7ecf\u5178\u65b9\u6cd5\u662f\u514b\u83b1\u9ed8\u6cd5\u5219, \u7531\u6b64\u53ef\u5f97$$\\beta = \\frac{\\begin{vmatrix}\nx_\\mathbf{a} - x_\\mathbf{e} &#038; x_\\mathbf{a} - x_\\mathbf{c} &#038; x_\\mathbf{d} \\\\\ny_\\mathbf{a} - y_\\mathbf{e} &#038; y_\\mathbf{a} - y_\\mathbf{c} &#038; y_\\mathbf{d} \\\\\nz_\\mathbf{a} - z_\\mathbf{e} &#038; z_\\mathbf{a} - z_\\mathbf{c} &#038; z_\\mathbf{d} \n\\end{vmatrix}}{|A|}, \\\\ \\gamma= \\frac{\\begin{vmatrix}\nx_\\mathbf{a} - x_\\mathbf{b} &#038; x_\\mathbf{a} - x_\\mathbf{e} &#038; x_\\mathbf{d} \\\\\ny_\\mathbf{a} - y_\\mathbf{b} &#038; y_\\mathbf{a} - y_\\mathbf{e} &#038; y_\\mathbf{d} \\\\\nz_\\mathbf{a} - z_\\mathbf{b} &#038; z_\\mathbf{a} - z_\\mathbf{e} &#038; z_\\mathbf{d} \n\\end{vmatrix}}{|A|}, \\\\ t= \\frac{\\begin{vmatrix}\nx_\\mathbf{a} - x_\\mathbf{b} &#038; x_\\mathbf{a} - x_\\mathbf{c} &#038; x_\\mathbf{a} - x_\\mathbf{e} \\\\\ny_\\mathbf{a} - y_\\mathbf{b} &#038; y_\\mathbf{a} - y_\\mathbf{c} &#038; y_\\mathbf{a} - y_\\mathbf{e} \\\\\nz_\\mathbf{a} - z_\\mathbf{b} &#038; z_\\mathbf{a} - z_\\mathbf{c} &#038; z_\\mathbf{a} - z_\\mathbf{e} \n\\end{vmatrix}}{|A|},$$\u5176\u4e2d, \u77e9\u9635$A$\u4e3a$$A = \\begin{bmatrix}\nx_\\mathbf{a} - x_\\mathbf{b} &#038; x_\\mathbf{a} - x_\\mathbf{c} &#038; x_\\mathbf{d} \\\\\ny_\\mathbf{a} - y_\\mathbf{b} &#038; y_\\mathbf{a} - y_\\mathbf{c} &#038; y_\\mathbf{d} \\\\\nz_\\mathbf{a} - z_\\mathbf{b} &#038; z_\\mathbf{a} - z_\\mathbf{c} &#038; z_\\mathbf{d} \n\\end{bmatrix},$$$|A|$\u8868\u793a\u77e9\u9635$A$\u7684\u884c\u5217\u5f0f. \u6211\u4eec\u53ef\u4ee5\u5c06\u4e0a\u8ff0\u7ebf\u6027\u7cfb\u7edf\u7b80\u8bb0\u4e3a$$\\begin{bmatrix}\na &#038; d &#038; g \\\\\nb &#038; e &#038; h \\\\\nc &#038; f &#038; i\n\\end{bmatrix} \\begin{bmatrix}\n\\beta \\\\\n\\gamma \\\\\nt\n\\end{bmatrix} = \\begin{bmatrix}\nj \\\\\nk \\\\\nl\n\\end{bmatrix},$$\u7531\u514b\u62c9\u9ed8\u6cd5\u5219\u53ef\u5f97$$\\beta = \\frac{j(ei - hf) + k(gf - di) + l(dh - eg)}{M}, \\\\ \\gamma = \\frac{i(ak - jb) + h(jc - al) + g(bl - kc)}{M}, \\\\ t = \\frac{f(ak - jb) + e(jc - al) + d(bl - kc)}{M},$$\u5176\u4e2d,$$M = a(ei - hf) + b(gf - di) + c(dh - eg).$$\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u7f13\u5b58\u91cd\u590d\u8ba1\u7b97\u7684\u5f0f\u5b50\u6765\u51cf\u5c11\u8fd0\u7b97\u91cf, \u5982$ei - hf$.\n\n$\\\\$\n$\\\\$ <strong>2.3 \u5149\u7ebf\u4e0e\u591a\u8fb9\u5f62\u7684\u76f8\u4ea4\u8ba1\u7b97<\/strong><\/p>\n<p>\u7ed9\u5b9a\u4e00\u4e2a\u5e73\u9762\u591a\u8fb9\u5f62, \u6709$m$\u4e2a\u9876\u70b9$\\mathbf{p}_1$\u5230$\\mathbf{p}_m$, \u5176\u9762\u6cd5\u7ebf\u4e3a$\\mathbf{n}$, \u6211\u4eec\u5229\u7528\u9690\u5f0f\u65b9\u7a0b\u8ba1\u7b97\u5c04\u7ebf$\\mathbf{e} + t\\mathbf{d}$\u4e0e\u8be5\u591a\u8fb9\u5f62\u6240\u5728\u7684\u5e73\u9762\u7684\u4ea4\u70b9:$$(\\mathbf{p} &#8211; \\mathbf{p}_1) \\cdot \\mathbf{n} = 0.$$\u8bbe$\\mathbf{p} = \\mathbf{e} + t\\mathbf{d}$, \u6c42\u89e3$t$\u5f97$$t = \\frac{(\\mathbf{p}_1 &#8211; \\mathbf{e}) \\cdot \\mathbf{n}}{\\mathbf{d} \\cdot \\mathbf{n}}.$$\u4ece\u800c\u6211\u4eec\u53ef\u5f97$\\mathbf{p}$. \u82e5$\\mathbf{p}$\u5728\u591a\u8fb9\u5f62\u5185, \u5219\u8bf4\u660e\u5149\u7ebf\u547d\u4e2d\u8be5\u591a\u8fb9\u5f62.<br \/>\n$\\\\$ \u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u5c06\u70b9\u4e0e\u591a\u8fb9\u5f62\u9876\u70b9\u5747\u6295\u5f71\u5230$XOY$\u5e73\u9762\u4e0a\u6765\u5224\u65ad\u70b9$\\mathbf{p}$\u662f\u5426\u5728\u591a\u8fb9\u5f62\u5185. \u6700\u7b80\u5355\u7684\u65b9\u6cd5\u662f\u4ece\u70b9$\\mathbf{p}$\u53d1\u5c04\u4efb\u610f2D\u5c04\u7ebf, \u5e76\u8ba1\u7b97\u8be5\u5c04\u7ebf\u4e0e\u591a\u8fb9\u5f62\u8fb9\u754c\u4e4b\u95f4\u7684\u4ea4\u70b9\u6570. \u82e5\u4ea4\u70b9\u6570\u4e3a\u5947\u6570, \u5219\u8be5\u70b9\u5728\u591a\u8fb9\u5f62\u5185; \u5426\u5219, \u8be5\u70b9\u5728\u591a\u8fb9\u5f62\u5916. \u76f4\u89c2\u4e0a\u7406\u89e3, \u82e5\u5c04\u7ebf\u662f\u4ece\u591a\u8fb9\u5f62\u5916\u53d1\u5c04, \u5219\u5fc5\u4ea7\u751f\u4e00\u5bf9\u4ea4\u70b9, \u4ece\u800c\u5176\u4ea4\u70b9\u6570\u5fc5\u4e3a\u5076\u6570. \u4e3a\u4e86\u7b80\u5316\u8ba1\u7b97, \u6211\u4eec\u901a\u5e38\u76f4\u63a5\u9009\u62e9\u6cbf$x$\u8f74\u65b9\u5411\u53d1\u5c04\u76842D\u5c04\u7ebf:$$\\begin{bmatrix}<br \/>\nx \\\\<br \/>\ny<br \/>\n\\end{bmatrix} = \\begin{bmatrix}<br \/>\nx_\\mathbf{p} \\\\<br \/>\ny_\\mathbf{p}<br \/>\n\\end{bmatrix} + s\\begin{bmatrix}<br \/>\n1 \\\\<br \/>\n0<br \/>\n\\end{bmatrix},$$\u5176\u4e2d, $s \\in (0, +\\infty)$. \u663e\u7136, \u8ba1\u7b97\u8be5\u5c04\u7ebf\u4e0e\u591a\u8fb9\u5f62\u8fb9\u754c\u7684\u4ea4\u70b9\u662f\u6bd4\u8f83\u7b80\u5355\u7684.<\/p>\n<p><strong>3. \u7740\u8272\u6a21\u578b<\/strong><\/p>\n<p><strong>3.1 Lambertian\u7740\u8272\u6a21\u578b<\/strong><\/p>\n<p>\u6700\u7b80\u5355\u7684\u5149\u7167\u6a21\u578b\u662f\u57fa\u4e8eLambertian\u572818\u4e16\u7eaa\u6240\u505a\u7684\u89c2\u5bdf: \u6765\u81ea\u5149\u6e90\u7684\u80fd\u91cf\u843d\u5728\u7269\u4f53\u8868\u9762\u4e0a\u7684\u9762\u79ef\u53d6\u51b3\u4e8e\u7269\u4f53\u8868\u9762\u4e0e\u5149\u7ebf\u7684\u89d2\u5ea6. \u4e00\u4e2a\u5782\u76f4\u4e8e\u5149\u7ebf\u7684\u7269\u4f53\u8868\u9762\u63a5\u6536\u6700\u5927\u5f3a\u5ea6\u7684\u5149\u7167; \u4e0e\u5149\u7ebf\u65b9\u5411\u76f8\u5207(\u6216\u80cc\u5411\u5149\u6e90) \u7684\u7269\u4f53\u8868\u9762\u65e0\u6cd5\u63a5\u6536\u5149\u7167; \u9664\u4e0a\u8ff0\u4e24\u79cd\u60c5\u51b5\u4ee5\u5916, \u7269\u4f53\u8868\u9762\u63a5\u6536\u7684\u5149\u7167\u5f3a\u5ea6\u4e0e\u8868\u9762\u6cd5\u7ebf\u548c\u5149\u7ebf\u4e4b\u95f4\u7684\u5939\u89d2\u7684\u4f59\u5f26\u503c\u6210\u6b63\u6bd4. \u8fd9\u4e5f\u5c31\u5f15\u51fa\u4e86Lambertian\u7740\u8272\u6a21\u578b:$$L = k_d I max(0, \\mathbf{n} \\cdot \\mathbf{l}),$$\u5176\u4e2d, $L$\u4e3a\u50cf\u7d20\u989c\u8272; $k_d$\u4e3a\u6269\u6563\u7cfb\u6570; $I$\u4e3a\u5149\u6e90\u5f3a\u5ea6. \u56e0\u4e3a\u6cd5\u5411\u91cf$\\mathbf{n}$\u4e0e\u5149\u7ebf\u7684\u65b9\u5411\u5411\u91cf$\\mathbf{l}$\u5747\u4e3a\u5355\u4f4d\u5411\u91cf, \u6545$\\mathbf{n} \\cdot \\mathbf{l}$\u5373\u4e3a$cos \\theta$($\\theta$\u4e3a\u6cd5\u5411\u91cf$\\mathbf{n}$\u4e0e\u5149\u7ebf\u7684\u65b9\u5411\u5411\u91cf$\\mathbf{l}$\u4e4b\u95f4\u7684\u5939\u89d2). \u4e0a\u8ff0\u6a21\u578b\u5206\u522b\u9002\u7528\u4e8e3\u4e2a\u989c\u8272\u901a\u9053, \u6545\u50cf\u7d20\u503c\u7684\u7ea2\u8272\u5206\u91cf\u4e3a\u6269\u6563\u7cfb\u6570, \u5149\u6e90\u5f3a\u5ea6\u7684\u7ea2\u8272\u901a\u9053\u503c, \u4e0e\u6cd5\u5411\u91cf\u4e0e\u5149\u7ebf\u7684\u65b9\u5411\u5411\u91cf\u7684\u5185\u79ef\u7684\u4e58\u79ef; \u5bf9\u4e8e\u7eff\u8272\u901a\u9053\u4e0e\u84dd\u8272\u901a\u9053\u4ea6\u662f\u5982\u6b64.<\/p>\n<p><strong>3.2 Blinn-Phong\u7740\u8272\u6a21\u578b<\/strong><\/p>\n<p>Phong\u5149\u7167\u4e0d\u4ec5\u5bf9\u771f\u5b9e\u5149\u7167\u6709\u5f88\u597d\u7684\u8fd1\u4f3c, \u800c\u4e14\u6027\u80fd\u4e5f\u5f88\u9ad8. \u4f46\u662f\u5b83\u7684\u955c\u9762\u53cd\u5c04\u4f1a\u5728\u4e00\u4e9b\u60c5\u51b5\u4e0b\u51fa\u73b0\u95ee\u9898, \u7279\u522b\u662f\u7269\u4f53\u53cd\u5149\u5ea6\u5f88\u4f4e\u65f6, \u4f1a\u5bfc\u81f4\u5927\u7247(\u7c97\u7cd9\u7684) \u9ad8\u5149\u533a\u57df. \u4e0b\u9762\u8fd9\u5f20\u56fe\u5c55\u793a\u4e86\u5f53\u53cd\u5149\u5ea6\u4e3a1.0\u65f6\u5730\u677f\u4f1a\u51fa\u73b0\u7684\u6548\u679c:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.caiqinyi.cn\/wp-content\/uploads\/2023\/03\/advanced_lighting_phong_limit.png\" alt=\"\" width=\"400\" height=\"313\" class=\"aligncenter size-full wp-image-3034\" srcset=\"https:\/\/www.caiqinyi.cn\/wp-content\/uploads\/2023\/03\/advanced_lighting_phong_limit.png 400w, https:\/\/www.caiqinyi.cn\/wp-content\/uploads\/2023\/03\/advanced_lighting_phong_limit-300x235.png 300w\" sizes=\"(max-width: 400px) 100vw, 400px\" \/><\/p>\n<p>\u53ef\u4ee5\u770b\u5230, \u5728\u955c\u9762\u9ad8\u5149\u533a\u57df\u7684\u8fb9\u7f18\u51fa\u73b0\u4e86\u4e00\u9053\u5f88\u660e\u663e\u7684\u65ad\u5c42. \u51fa\u73b0\u8fd9\u4e2a\u95ee\u9898\u7684\u539f\u56e0\u662f\u89c2\u5bdf\u5411\u91cf\u548c\u53cd\u5c04\u5411\u91cf\u95f4\u7684\u5939\u89d2\u4e0d\u80fd\u5927\u4e8e90\u5ea6. \u5982\u679c\u70b9\u79ef\u7684\u7ed3\u679c\u4e3a\u8d1f\u6570, \u955c\u9762\u5149\u5206\u91cf\u4f1a\u53d8\u4e3a0.0. \u4f60\u53ef\u80fd\u4f1a\u89c9\u5f97, \u5f53\u5149\u7ebf\u4e0e\u89c6\u7ebf\u5939\u89d2\u5927\u4e8e90\u5ea6\u65f6\u4f60\u5e94\u8be5\u4e0d\u4f1a\u63a5\u6536\u5230\u4efb\u4f55\u5149\u624d\u5bf9, \u6240\u4ee5\u8fd9\u4e0d\u662f\u4ec0\u4e48\u95ee\u9898.<br \/>\n$\\\\$ \u7136\u800c, \u8fd9\u79cd\u60f3\u6cd5\u4ec5\u4ec5\u53ea\u9002\u7528\u4e8e\u6f2b\u53cd\u5c04\u5206\u91cf. \u5f53\u8003\u8651\u6f2b\u53cd\u5c04\u5149\u7684\u65f6\u5019, \u5982\u679c\u6cd5\u7ebf\u548c\u5149\u6e90\u5939\u89d2\u5927\u4e8e90\u5ea6, \u5149\u6e90\u4f1a\u5904\u4e8e\u88ab\u7167\u8868\u9762\u7684\u4e0b\u65b9, \u8fd9\u4e2a\u65f6\u5019\u5149\u7167\u7684\u6f2b\u53cd\u5c04\u5206\u91cf\u7684\u786e\u662f\u4e3a0.0. \u4f46\u662f, \u5728\u8003\u8651\u955c\u9762\u9ad8\u5149\u65f6, \u6211\u4eec\u6d4b\u91cf\u7684\u89d2\u5ea6\u5e76\u4e0d\u662f\u5149\u6e90\u4e0e\u6cd5\u7ebf\u7684\u5939\u89d2, \u800c\u662f\u89c6\u7ebf\u4e0e\u53cd\u5c04\u5149\u7ebf\u5411\u91cf\u7684\u5939\u89d2. \u770b\u4e00\u4e0b\u4e0b\u9762\u8fd9\u4e24\u5f20\u56fe:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.caiqinyi.cn\/wp-content\/uploads\/2023\/03\/advanced_lighting_over_90.png\" alt=\"\" width=\"800\" height=\"282\" class=\"aligncenter size-full wp-image-3035\" srcset=\"https:\/\/www.caiqinyi.cn\/wp-content\/uploads\/2023\/03\/advanced_lighting_over_90.png 800w, https:\/\/www.caiqinyi.cn\/wp-content\/uploads\/2023\/03\/advanced_lighting_over_90-300x106.png 300w, https:\/\/www.caiqinyi.cn\/wp-content\/uploads\/2023\/03\/advanced_lighting_over_90-768x271.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/p>\n<p>\u73b0\u5728\u95ee\u9898\u5c31\u5e94\u8be5\u5f88\u660e\u663e\u4e86. \u5de6\u56fe\u4e2d\u662f\u6211\u4eec\u719f\u6089\u7684Phong\u5149\u7167\u4e2d\u7684\u53cd\u5c04\u5411\u91cf, \u5176\u4e2d$\\theta$\u89d2\u5c0f\u4e8e90\u5ea6. \u800c\u53f3\u56fe\u4e2d, \u89c6\u7ebf\u4e0e\u53cd\u5c04\u65b9\u5411\u4e4b\u95f4\u7684\u5939\u89d2\u660e\u663e\u5927\u4e8e90\u5ea6, \u8fd9\u79cd\u60c5\u51b5\u4e0b\u955c\u9762\u5149\u5206\u91cf\u4f1a\u53d8\u4e3a0.0. \u8fd9\u5728\u5927\u591a\u6570\u60c5\u51b5\u4e0b\u90fd\u4e0d\u662f\u4ec0\u4e48\u95ee\u9898, \u56e0\u4e3a\u89c2\u5bdf\u65b9\u5411\u79bb\u53cd\u5c04\u65b9\u5411\u90fd\u975e\u5e38\u8fdc. \u7136\u800c, \u5f53\u7269\u4f53\u7684\u53cd\u5149\u5ea6\u975e\u5e38\u5c0f\u65f6, \u5b83\u4ea7\u751f\u7684\u955c\u9762\u9ad8\u5149\u534a\u5f84\u8db3\u4ee5\u8ba9\u8fd9\u4e9b\u76f8\u53cd\u65b9\u5411\u7684\u5149\u7ebf\u5bf9\u4eae\u5ea6\u4ea7\u751f\u8db3\u591f\u5927\u7684\u5f71\u54cd. \u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\u5c31\u4e0d\u80fd\u5ffd\u7565\u5b83\u4eec\u5bf9\u955c\u9762\u5149\u5206\u91cf\u7684\u8d21\u732e\u4e86.<br \/>\n$\\\\$ 1977\u5e74, James F. Blinn\u5728Phong\u7740\u8272\u6a21\u578b\u4e0a\u52a0\u4ee5\u62d3\u5c55, \u5f15\u5165\u4e86Blinn-Phong\u7740\u8272\u6a21\u578b. Blinn-Phong\u6a21\u578b\u4e0ePhong\u6a21\u578b\u975e\u5e38\u76f8\u4f3c, \u4f46\u662f\u5b83\u5bf9\u955c\u9762\u5149\u6a21\u578b\u7684\u5904\u7406\u4e0a\u6709\u4e00\u4e9b\u4e0d\u540c, \u8ba9\u6211\u4eec\u80fd\u591f\u89e3\u51b3\u4e4b\u524d\u63d0\u5230\u7684\u95ee\u9898. Blinn-Phong\u6a21\u578b\u4e0d\u518d\u4f9d\u8d56\u4e8e\u53cd\u5c04\u5411\u91cf, \u800c\u662f\u91c7\u7528\u4e86\u6240\u8c13\u7684\u534a\u7a0b\u5411\u91cf(Halfway Vector), \u5373\u5149\u7ebf\u4e0e\u89c6\u7ebf\u5939\u89d2\u4e00\u534a\u65b9\u5411\u4e0a\u7684\u4e00\u4e2a\u5355\u4f4d\u5411\u91cf. \u5f53\u534a\u7a0b\u5411\u91cf\u4e0e\u6cd5\u7ebf\u5411\u91cf\u8d8a\u63a5\u8fd1\u65f6, \u955c\u9762\u5149\u5206\u91cf\u5c31\u8d8a\u5927.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.caiqinyi.cn\/wp-content\/uploads\/2023\/03\/advanced_lighting_halfway_vector.png\" alt=\"\" width=\"453\" height=\"322\" class=\"aligncenter size-full wp-image-3036\" srcset=\"https:\/\/www.caiqinyi.cn\/wp-content\/uploads\/2023\/03\/advanced_lighting_halfway_vector.png 453w, https:\/\/www.caiqinyi.cn\/wp-content\/uploads\/2023\/03\/advanced_lighting_halfway_vector-300x213.png 300w\" sizes=\"(max-width: 453px) 100vw, 453px\" \/><\/p>\n<p>\u5f53\u89c6\u7ebf\u6b63\u597d\u4e0e(\u73b0\u5728\u4e0d\u9700\u8981\u7684) \u53cd\u5c04\u5411\u91cf\u5bf9\u9f50\u65f6, \u534a\u7a0b\u5411\u91cf\u5c31\u4f1a\u4e0e\u6cd5\u7ebf\u5b8c\u7f8e\u5951\u5408. \u6240\u4ee5\u5f53\u89c2\u5bdf\u8005\u89c6\u7ebf\u8d8a\u63a5\u8fd1\u4e8e\u539f\u672c\u53cd\u5c04\u5149\u7ebf\u7684\u65b9\u5411\u65f6, \u955c\u9762\u9ad8\u5149\u5c31\u4f1a\u8d8a\u5f3a.<br \/>\n$\\\\$ \u73b0\u5728, \u4e0d\u8bba\u89c2\u5bdf\u8005\u5411\u54ea\u4e2a\u65b9\u5411\u770b, \u534a\u7a0b\u5411\u91cf\u4e0e\u8868\u9762\u6cd5\u7ebf\u4e4b\u95f4\u7684\u5939\u89d2\u90fd\u4e0d\u4f1a\u8d85\u8fc790\u5ea6(\u9664\u975e\u5149\u6e90\u5728\u8868\u9762\u4ee5\u4e0b). \u5b83\u4ea7\u751f\u7684\u6548\u679c\u4f1a\u4e0e\u51af\u6c0f\u5149\u7167\u6709\u4e9b\u8bb8\u4e0d\u540c, \u4f46\u662f\u5927\u90e8\u5206\u60c5\u51b5\u4e0b\u770b\u8d77\u6765\u4f1a\u66f4\u81ea\u7136\u4e00\u70b9, \u7279\u522b\u662f\u4f4e\u9ad8\u5149\u7684\u533a\u57df. Blinn-Phong\u7740\u8272\u6a21\u578b\u6b63\u662f\u65e9\u671f\u56fa\u5b9a\u6e32\u67d3\u7ba1\u7ebf\u65f6\u4ee3\u65f6OpenGL\u6240\u91c7\u7528\u7684\u5149\u7167\u6a21\u578b.<br \/>\n$\\\\$ \u83b7\u53d6\u534a\u7a0b\u5411\u91cf\u7684\u65b9\u6cd5\u5f88\u7b80\u5355, \u53ea\u9700\u8981\u5c06\u5149\u7ebf\u7684\u65b9\u5411\u5411\u91cf\u548c\u89c2\u5bdf\u5411\u91cf\u52a0\u5230\u4e00\u8d77, \u5e76\u5c06\u7ed3\u679c\u6b63\u89c4\u5316(Normalize) \u5c31\u53ef\u4ee5\u4e86:$$\\mathbf{h} = \\frac{\\mathbf{v} + \\mathbf{l}}{\\left \\| \\mathbf{v} + \\mathbf{l} \\right \\|}.$$\u63a5\u4e0b\u6765, \u955c\u9762\u5149\u5206\u91cf\u7684\u5b9e\u9645\u8ba1\u7b97\u53ea\u4e0d\u8fc7\u662f\u5bf9\u8868\u9762\u6cd5\u7ebf\u548c\u534a\u7a0b\u5411\u91cf\u8fdb\u884c\u4e00\u6b21\u7ea6\u675f\u70b9\u4e58(Clamped Dot Product), \u8ba9\u70b9\u4e58\u7ed3\u679c\u4e0d\u4e3a\u8d1f, \u4ece\u800c\u83b7\u53d6\u5b83\u4eec\u4e4b\u95f4\u5939\u89d2\u7684\u4f59\u5f26\u503c, \u4e4b\u540e\u6211\u4eec\u5bf9\u8fd9\u4e2a\u503c\u53d6\u53cd\u5149\u5ea6\u6b21\u65b9, \u6545Blinn-Phong\u7740\u8272\u6a21\u578b\u5982\u4e0b\u6240\u793a:$$L = k_d I max(0, \\mathbf{n} \\cdot \\mathbf{l}) + k_s I max(0, \\mathbf{n} \\cdot \\mathbf{h})^p,$$\u5176\u4e2d, $k_s$\u4e3a\u955c\u9762\u9ad8\u5149\u7cfb\u6570. \u9664\u6b64\u4e4b\u5916Blinn-Phong\u6a21\u578b\u5c31\u6ca1\u4ec0\u4e48\u597d\u8bf4\u7684\u4e86, Blinn-Phong\u4e0ePhong\u6a21\u578b\u552f\u4e00\u7684\u533a\u522b\u5c31\u662f, Blinn-Phong\u6d4b\u91cf\u7684\u662f\u6cd5\u7ebf\u4e0e\u534a\u7a0b\u5411\u91cf\u4e4b\u95f4\u7684\u5939\u89d2, \u800cPhong\u6a21\u578b\u6d4b\u91cf\u7684\u662f\u89c2\u5bdf\u65b9\u5411\u4e0e\u53cd\u5c04\u5411\u91cf\u95f4\u7684\u5939\u89d2.<br \/>\n$\\\\$ \u5728\u5f15\u5165\u534a\u7a0b\u5411\u91cf\u4e4b\u540e, \u6211\u4eec\u73b0\u5728\u5e94\u8be5\u5c31\u4e0d\u4f1a\u518d\u770b\u5230Phong\u5149\u7167\u4e2d\u9ad8\u5149\u65ad\u5c42\u7684\u60c5\u51b5\u4e86. \u4e0b\u9762\u4e24\u4e2a\u56fe\u7247\u5c55\u793a\u7684\u662f\u4e24\u79cd\u65b9\u6cd5\u5728\u955c\u9762\u5149\u5206\u91cf\u4e3a0.5\u65f6\u7684\u5bf9\u6bd4:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.caiqinyi.cn\/wp-content\/uploads\/2023\/03\/advanced_lighting_comparrison.png\" alt=\"\" width=\"800\" height=\"315\" class=\"aligncenter size-full wp-image-3037\" srcset=\"https:\/\/www.caiqinyi.cn\/wp-content\/uploads\/2023\/03\/advanced_lighting_comparrison.png 800w, https:\/\/www.caiqinyi.cn\/wp-content\/uploads\/2023\/03\/advanced_lighting_comparrison-300x118.png 300w, https:\/\/www.caiqinyi.cn\/wp-content\/uploads\/2023\/03\/advanced_lighting_comparrison-768x302.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/p>\n<p>\u9664\u6b64\u4e4b\u5916, Phong\u6a21\u578b\u4e0eBlinn-Phong\u6a21\u578b\u4e5f\u6709\u4e00\u4e9b\u7ec6\u5fae\u7684\u5dee\u522b: \u534a\u7a0b\u5411\u91cf\u4e0e\u8868\u9762\u6cd5\u7ebf\u7684\u5939\u89d2\u901a\u5e38\u4f1a\u5c0f\u4e8e\u89c2\u5bdf\u4e0e\u53cd\u5c04\u5411\u91cf\u7684\u5939\u89d2. \u6240\u4ee5, \u5982\u679c\u4f60\u60f3\u83b7\u5f97\u548c\u51af\u6c0f\u7740\u8272\u7c7b\u4f3c\u7684\u6548\u679c, \u5c31\u5fc5\u987b\u5728\u4f7f\u7528Blinn-Phong\u6a21\u578b\u65f6\u5c06\u955c\u9762\u53cd\u5149\u5ea6\u8bbe\u7f6e\u66f4\u9ad8\u4e00\u70b9. \u901a\u5e38\u6211\u4eec\u4f1a\u9009\u62e9Phong\u7740\u8272\u6a21\u578b\u65f6\u53cd\u5149\u5ea6\u5206\u91cf\u76842\u52304\u500d.<br \/>\n$\\\\$ \u4e0b\u9762\u662fPhong\u7740\u8272\u53cd\u5149\u5ea6\u4e3a8.0, Blinn-Phong\u7740\u8272\u53cd\u5149\u5ea6\u4e3a32.0\u65f6\u7684\u4e00\u4e2a\u5bf9\u6bd4:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.caiqinyi.cn\/wp-content\/uploads\/2023\/03\/advanced_lighting_comparrison2.png\" alt=\"\" width=\"800\" height=\"313\" class=\"aligncenter size-full wp-image-3038\" srcset=\"https:\/\/www.caiqinyi.cn\/wp-content\/uploads\/2023\/03\/advanced_lighting_comparrison2.png 800w, https:\/\/www.caiqinyi.cn\/wp-content\/uploads\/2023\/03\/advanced_lighting_comparrison2-300x117.png 300w, https:\/\/www.caiqinyi.cn\/wp-content\/uploads\/2023\/03\/advanced_lighting_comparrison2-768x300.png 768w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/p>\n<p>\u4f60\u53ef\u4ee5\u770b\u5230, Blinn-Phong\u7684\u955c\u9762\u5149\u5206\u91cf\u4f1a\u6bd4Phong\u6a21\u578b\u66f4\u9510\u5229\u4e00\u4e9b. \u4e3a\u4e86\u5f97\u5230\u4e0e\u51af\u6c0f\u6a21\u578b\u7c7b\u4f3c\u7684\u7ed3\u679c, \u4f60\u53ef\u80fd\u4f1a\u9700\u8981\u4e0d\u65ad\u8fdb\u884c\u4e00\u4e9b\u5fae\u8c03, \u4f46Blinn-Phong\u6a21\u578b\u901a\u5e38\u4f1a\u4ea7\u51fa\u66f4\u771f\u5b9e\u7684\u7ed3\u679c.<\/p>\n<p><strong>3.3 \u73af\u5883\u5149\u7740\u8272\u6a21\u578b<\/strong><\/p>\n<p>\u6ca1\u6709\u63a5\u6536\u5230\u76f4\u63a5\u5149\u7167\u7684\u7269\u4f53\u8868\u9762\u5c06\u76f4\u63a5\u88ab\u6e32\u67d3\u4e3a\u9ed1\u8272, \u8fd9\u901a\u5e38\u662f\u4e0d\u53ef\u53d6\u7684. \u5728\u5b9e\u9645\u5e94\u7528\u4e2d, \u4e3a\u4e86\u907f\u514d\u6e32\u67d3\u7eaf\u9ed1\u7684\u7269\u4f53\u8868\u9762, \u901a\u5e38\u662f\u5411\u7740\u8272\u6a21\u578b\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u5e38\u91cf\u9879, \u8be5\u9879\u5b8c\u5168\u4e0d\u4f9d\u8d56\u4e8e\u7269\u4f53\u8868\u9762\u7684\u51e0\u4f55\u4fe1\u606f. \u8fd9\u5c31\u662f\u6240\u8c13\u7684\u73af\u5883\u5149\u7740\u8272\u2014\u2014\u5c31\u597d\u50cf\u7269\u4f53\u8868\u9762\u88ab\u6765\u81ea\u5404\u4e2a\u5730\u65b9\u7684&#8221;\u73af\u5883&#8221;\u5149\u7167\u4eae. \u4e3a\u4e86\u65b9\u4fbf\u8c03\u6574\u53c2\u6570, \u73af\u5883\u5149\u7740\u8272\u6a21\u578b\u901a\u5e38\u8868\u793a\u4e3a\u7269\u4f53\u8868\u9762\u7684\u73af\u5883\u5149\u7cfb\u6570\u4e0e\u73af\u5883\u5149\u5f3a\u5ea6\u7684\u4e58\u79ef\u7684\u5f62\u5f0f, \u56e0\u6b64\u73af\u5883\u5149\u7740\u8272\u6a21\u578b\u53ef\u4ee5\u4e3a\u5355\u4e2a\u7269\u4f53\u8868\u9762\u8fdb\u884c\u8c03\u6574, \u4ea6\u53ef\u4ee5\u4e3a\u6240\u6709\u7684\u7269\u4f53\u8868\u9762\u4e00\u5e76\u8c03\u6574. \u4e0eBlinn-Phong\u7740\u8272\u6a21\u578b\u8fdb\u884c\u7ec4\u5408, \u4fbf\u5f97\u5230\u4e86\u4e00\u4e2a\u7b80\u5355\u4e14\u6709\u7528\u7684\u7740\u8272\u6a21\u578b\u7684\u5b8c\u6574\u7248\u672c:$$L = k_a I_a + k_d I max(0, \\mathbf{n} \\cdot \\mathbf{l}) + k_s I max(0, \\mathbf{n} \\cdot \\mathbf{h})^n,$$\u5176\u4e2d, $k_a$\u4e3a\u73af\u5883\u5149\u7cfb\u6570, $I_a$\u4e3a\u73af\u5883\u5149\u5f3a\u5ea6.<\/p>\n<p><strong>3.4 \u591a\u4e2a\u70b9\u5149\u6e90<\/strong><\/p>\n<p>\u5149\u5177\u6709\u6ce2\u548c\u7c92\u5b50\u7684\u7279\u6027. \u5f53\u4e24\u675f\u5149\u5728\u7a7a\u95f4\u4e2d\u76f8\u9047, \u5149\u7684\u53e0\u52a0\u4e0d\u662f\u5f3a\u5ea6\u7684\u53e0\u52a0. \u7136\u800c\u5728\u5b9e\u9645\u5e94\u7528\u4e2d, \u6211\u4eec\u4f1a\u5c06\u7740\u8272\u6a21\u578b\u7b80\u5355\u5730\u6269\u5c55\u5230$N$\u4e2a\u5149\u6e90\u7684\u60c5\u5f62:$$L = k_a I_a + \\sum_{i = 1}^{N}[k_d I_i max(0, \\mathbf{n} \\cdot \\mathbf{l_i}) + k_s I_i max(0, \\mathbf{n} \\cdot \\mathbf{h_i})^p],$$\u5176\u4e2d, $I_i$, $\\mathbf{l_i}$\u4e0e$\\mathbf{h_i}$\u5206\u522b\u4e3a\u7b2c$i$\u4e2a\u5149\u6e90\u7684\u5f3a\u5ea6, \u5bf9\u5e94\u7684\u5149\u7ebf\u7684\u65b9\u5411\u5411\u91cf\u4e0e\u5bf9\u5e94\u7684\u534a\u7a0b\u5411\u91cf.<\/p>\n<p><strong>4. \u7406\u60f3\u7684\u955c\u9762\u53cd\u5c04<\/strong><\/p>\n<p>\u5728\u5149\u7ebf\u8ffd\u8e2a\u7684\u4ee3\u7801\u4e2d\u52a0\u5165\u7406\u60f3\u7684\u955c\u9762\u53cd\u5c04\u662f\u6bd4\u8f83\u7b80\u5355\u7684. \u6613\u77e5, \u5f53\u89c2\u5bdf\u8005\u4ece\u65b9\u5411$\\mathbf{e}$\u770b\u5411\u4e00\u4e2a\u7269\u4f53\u65f6, \u5176\u7406\u60f3\u7684\u955c\u9762\u53cd\u5c04\u5411\u91cf$\\mathbf{r}$\u4e3a:$$\\mathbf{r} = \\mathbf{d} &#8211; 2(\\mathbf{d} \\cdot \\mathbf{n})\\mathbf{n},$$\u5176\u4e2d, $\\mathbf{d} = -\\mathbf{e}$\u4e3a\u6307\u5411\u7269\u4f53\u8868\u9762\u7684\u5411\u91cf.<br \/>\n$\\\\$ \u5728\u73b0\u5b9e\u4e16\u754c\u4e2d, \u5f53\u5149\u7ebf\u7ecf\u7269\u4f53\u8868\u9762\u53cd\u5c04\u540e, \u4f1a\u635f\u5931\u4e00\u4e9b\u80fd\u91cf. \u8fd9\u79cd\u635f\u5931\u5bf9\u4e8e\u4e0d\u540c\u989c\u8272\u7684\u7269\u4f53\u8868\u9762\u53ef\u80fd\u662f\u4e0d\u540c\u7684. \u4f8b\u5982, \u91d1\u8272\u7269\u4f53\u6bd4\u84dd\u8272\u7269\u4f53\u80fd\u591f\u66f4\u6709\u6548\u5730\u53cd\u5c04\u9ec4\u8272\u5149\u7ebf. \u8fd9\u53ef\u4ee5\u901a\u8fc7\u5728\u5149\u7ebf\u8ffd\u8e2a\u7684\u4ee3\u7801\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u9012\u5f52\u8c03\u7528\u6765\u5b9e\u73b0:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"C++\" data-enlighter-theme=\"monokai\">\r\n\r\ncolor c = c + k_m * raycolor(p + s * r, varepsilon, infty)\r\n\r\n<\/pre>\n<p>\u5176\u4e2d, $k_m$\u4e3a\u955c\u9762\u53cd\u5c04\u7cfb\u6570. \u4e3a\u4e86\u907f\u514d\u6211\u4eec\u53cd\u5c04\u5149\u7ebf\u51fb\u4e2d\u4ea7\u751f\u5b83\u7684\u7269\u4f53, \u6211\u4eec\u9700\u8981\u786e\u4fdd$s \\in [\\varepsilon, +\\infty]$.<br \/>\n$\\\\$ \u4e0a\u9762\u7684\u9012\u5f52\u8c03\u7528\u7684\u95ee\u9898\u662f\u5b83\u53ef\u80fd\u6c38\u8fdc\u4e0d\u4f1a\u7ec8\u6b62. \u4f8b\u5982, \u5982\u679c\u4e00\u675f\u5149\u7ebf\u4ece\u623f\u95f4\u5185\u67d0\u5904\u5f00\u59cb, \u5b83\u5c06\u6c38\u8fdc\u53cd\u5f39\u4e0b\u53bb. \u56e0\u6b64, \u5728\u5b9e\u9645\u5e94\u7528\u4e2d, \u6211\u4eec\u9700\u8981\u901a\u8fc7\u9650\u5236\u6700\u5927\u7684\u9012\u5f52\u6df1\u5ea6\u6765\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898. \u6b64\u5916, \u82e5$k_m = 0$, \u5219\u4e0d\u5e94\u8be5\u751f\u6210\u53cd\u5c04\u5149\u7ebf.<\/p>\n<p><strong>5. \u5e38\u89c1\u95ee\u9898<\/strong><\/p>\n<p><strong>\u95ee1:<\/strong> \u4e3a\u4ec0\u4e48\u5728\u5149\u7ebf\u8ffd\u8e2a\u4e2d\u6ca1\u6709\u900f\u89c6\u77e9\u9635?<br \/>\n$\\\\$ <strong>\u7b541:<\/strong> \u901a\u8fc7\u4ece\u89c2\u5bdf\u70b9\u5411\u5916\u53d1\u5c04\u5149\u7ebf\u672c\u8eab\u5c31\u662f\u4e00\u4e2a\u6a21\u62df\u900f\u89c6\u6295\u5f71\u7684\u8fc7\u7a0b.<\/p>\n<p><strong>\u95ee2:<\/strong> \u5149\u7ebf\u8ffd\u8e2a\u53ef\u4ee5\u5e94\u7528\u5728\u6e38\u620f\u4e2d\u5417?<br \/>\n$\\\\$ <strong>\u7b542:<\/strong> \u968f\u7740\u8ba1\u7b97\u673a\u7b97\u529b\u8d8a\u6765\u8d8a\u5f3a, \u5bf9\u4e8e\u573a\u666f\u8f83\u7b80\u5355\u7684\u6e38\u620f, \u5df2\u7ecf\u53ef\u4ee5\u5b9e\u73b0\u5149\u7ebf\u8ffd\u8e2a\u4e86. \u5b9e\u9645\u4e0a, \u8ba1\u7b97\u673a\u6027\u80fd\u7684\u589e\u957f\u901f\u5ea6\u8fdc\u8fdc\u5feb\u4e8e\u5c4f\u5e55\u5206\u8fa8\u7387\u7684\u589e\u957f\u901f\u5ea6, \u4f20\u7edfPC\u5b9e\u73b0\u590d\u6742\u573a\u666f\u7684\u5149\u7ebf\u8ffd\u8e2a\u53ea\u662f\u65f6\u95f4\u95ee\u9898.<\/p>\n<p><strong>\u95ee3:<\/strong> \u5149\u7ebf\u8ffd\u8e2a\u76ee\u524d\u6709\u4ec0\u4e48\u6210\u719f\u7684\u5e94\u7528\u573a\u666f\u5417?<br \/>\n$\\\\$ <strong>\u7b543:<\/strong> \u5149\u7ebf\u8ffd\u8e2a\u7ecf\u5e38\u7528\u4e8e\u62fe\u53d6\u5bf9\u8c61\u7684\u83b7\u53d6. \u5f53\u7528\u6237\u57283D\u56fe\u5f62\u7a0b\u5e8f\u7684\u754c\u9762\u4e0a\u70b9\u51fb\u9f20\u6807\u65f6, \u7a0b\u5e8f\u9700\u8981\u786e\u5b9a\u5728\u8be5\u50cf\u7d20\u5185\u54ea\u4e2a\u5bf9\u8c61\u662f\u53ef\u89c1\u7684, \u800c\u5149\u7ebf\u8ffd\u8e2a\u662f\u786e\u5b9a\u8fd9\u4e00\u70b9\u7684\u7406\u60f3\u65b9\u6cd5.<\/p>\n<p><strong>6. \u76f8\u5173\u4e60\u9898<\/strong><\/p>\n<p><strong>6.1<\/strong> \u6c42\u4f7f\u5f97\u5c04\u7ebf$(1, 1, 1)^T + t(-1, -1, -1)^T$\u4e0e\u7403\u5fc3\u4e3a\u539f\u70b9\u7684\u5355\u4f4d\u7403\u76f8\u4ea4\u7684$t$\u7684\u503c.<br \/>\n$\\\\$ <strong>\u89e3:<\/strong> \u5148\u8ba1\u7b97\u76f8\u4ea4\u7684\u5224\u522b\u5f0f, \u75312.1\u5c0f\u8282\u7684\u8ba1\u7b97\u516c\u5f0f\u53ef\u5f97$\\triangle = 3 > 0$, \u6545\u8be5\u5c04\u7ebf\u4e0e\u5355\u4f4d\u7403\u4e4b\u95f4\u5b58\u5728\u4e24\u4e2a\u4ea4\u70b9\u5bf9\u5e94\u7684$t$\u7684\u503c: $t = \\frac{3 \\pm \\sqrt{3}}{3}$.<\/p>\n<p><strong>6.2<\/strong> \u6c42\u4f7f\u5f97\u5c04\u7ebf$(1, 1, 1)^T + t(-1, -1, -1)^T$\u4e0e\u4e09\u4e2a\u9876\u70b9\u5206\u522b\u4e3a$(1, 0, 0)^T$, $(0, 1, 0)^T$\u4e0e$(0, 0, 1)^T$\u7684\u4e09\u89d2\u5f62\u76f8\u4ea4\u7684$t$\u7684\u503c, \u5e76\u6c42\u51fa\u4ea4\u70b9\u5173\u4e8e\u8be5\u4e09\u89d2\u5f62\u7684\u91cd\u5fc3\u5750\u6807.<br \/>\n$\\\\$ <strong>\u89e3:<\/strong> \u5148\u8ba1\u7b97\u5bf9\u5e94\u7684\u7ebf\u6027\u7cfb\u7edf\u7684\u7cfb\u6570\u77e9\u9635\u7684\u884c\u5217\u5f0f, \u75312.2\u5c0f\u8282\u7684\u8ba1\u7b97\u516c\u5f0f\u53ef\u5f97$|A| = -2 \\ne 0$, \u6545\u8be5\u5c04\u7ebf\u4e0e\u8be5\u4e09\u89d2\u5f62\u6240\u5728\u7684\u5e73\u9762\u5b58\u5728\u552f\u4e00\u4ea4\u70b9. \u63a5\u4e0b\u6765\u8ba1\u7b97\u8be5\u4ea4\u70b9\u662f\u5426\u5728\u4e09\u89d2\u5f62\u5185.<br \/>\n$\\\\$ \u6613\u77e5, $\\beta = 0.5$, $\\gamma = 0.5$, $t = 0.5$, \u4ece\u800c\u4ea4\u70b9\u5173\u4e8e\u8be5\u4e09\u89d2\u5f62\u7684\u91cd\u5fc3\u5750\u6807\u4e3a$(0, 0.5 $$ , 0.5)^T$, \u5373\u8be5\u4ea4\u70b9\u4f4d\u4e8e\u4e09\u89d2\u5f62\u7684\u8fb9\u754c\u4e0a.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u4e2a\u5468\u672b\u5e94\u8be5\u662f\u8eab\u4e3a\u7f51\u6613\u5458\u5de5\u7684\u6700\u540e\u4e00\u4e2a\u5468\u672b\u4e86, \u76ee\u524d\u7684\u5fc3\u6001\u597d\u4f3c\u65e9\u5df2\u4e22\u6389\u4e86\u4e0d\u5b89\u7684\u90e8\u5206, \u53ea\u5269\u4e0b\u5bf9\u4e0b\u5468\u4e09\u79bb\u804c\u7684\u5766\u7136, &hellip; <a href=\"https:\/\/www.caiqinyi.cn\/index.php\/2023\/03\/05\/ray_tracing_mark\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u5149\u7ebf\u8ffd\u8e2a\u6ce8\u8bb0<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10],"tags":[],"_links":{"self":[{"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/posts\/2976"}],"collection":[{"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/comments?post=2976"}],"version-history":[{"count":68,"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/posts\/2976\/revisions"}],"predecessor-version":[{"id":3618,"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/posts\/2976\/revisions\/3618"}],"wp:attachment":[{"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/media?parent=2976"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/categories?post=2976"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.caiqinyi.cn\/index.php\/wp-json\/wp\/v2\/tags?post=2976"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}