介绍
光栅化可更快创建 3D 图像,但会牺牲画面品质,一般实时渲染。光线追踪需要大量的计算,更适合于质量比快速交互更重要的场景,一般是离线渲染。
Whitted-Style(比较生硬)
![](https://i-blog.csdnimg.cn/blog_migrate/c8643f705ed3873cbed43790a646a420.png)
光线方程
![](https://i-blog.csdnimg.cn/blog_migrate/1bbc2e759faad984a52b8b221a31f87a.png)
![](https://i-blog.csdnimg.cn/blog_migrate/98d353884eb1d4022223b248ec0ea01d.png)
光线与平面相交方程
![](https://i-blog.csdnimg.cn/blog_migrate/31a8aa0ac98eea557d785063ea6b1020.png)
光线与长方体相交(AABB)
![](https://i-blog.csdnimg.cn/blog_migrate/100a3a5e2fda059d24175903a2a8db7f.png)
计算每个对面的相交的最小时间和最大时间,然后取3个对面的进出时间
![](https://i-blog.csdnimg.cn/blog_migrate/66d07d4b2dc827214b250ec604cb8cb5.png)
![](https://i-blog.csdnimg.cn/blog_migrate/361dd5e7728b1f93cb30893b7e611d85.png)
空间划分(加速光线追踪的计算)
![](https://i-blog.csdnimg.cn/blog_migrate/042a92018356d9d36948fd55a0ebda54.png)
KD-Tree
1.分割轴:沿x、y或z轴
2.分割位置:分割平面沿轴的坐标
![](https://i-blog.csdnimg.cn/blog_migrate/44510a0a6f27d9dfa2ecad24818c4ce7.png)
物体划分(BVH)
始终选择节点中的最长轴切割
在中间物体的位置处分割节点
当节点包含少量元素时停止
![](https://i-blog.csdnimg.cn/blog_migrate/f1eb2617d1e8363499b78899492d2d38.png)