@@ -21,22 +21,92 @@ glossy 表示有点反光, 但是又有些粗糙的物体 (铜镜)
21
21
22
22
光线的一个性质: 光路可逆 (也就是追踪的意思)
23
23
24
+ ![ image] ( https://github.com/lumixraku/NotesForGraphics/raw/master/images/raytracing4.png )
25
+
26
+
27
+ 沿着一根光线, 记录最近的交点
28
+
24
29
![ image] ( https://github.com/lumixraku/NotesForGraphics/raw/master/images/raytracing.png )
25
30
26
31
光线追踪因为 ray 是从眼睛( 摄像机 ) 发出, 因此天然的解决了遮挡(深度测试)的问题,
27
32
33
+
34
+
28
35
## Whitted Style Ray tracing
29
36
37
+ Whitted Style: 多次递归反射, 就是在模拟光线在不断弹射的过程.
38
+
30
39
![ image] ( https://github.com/lumixraku/NotesForGraphics/raw/master/images/raytracing2.png )
31
40
41
+ 下面是一个玻璃球, 既有折射, 又有反射. 同时还要计算和光源的情况.
42
+
43
+ ![ image] ( https://github.com/lumixraku/NotesForGraphics/raw/master/images/raytracing5.png )
44
+
45
+ 其实从这个图可以看到 光路有很多条, 最终我们要计算的是他们的和 (每条光路存在能量损失, 不然加起来光线亮度就很亮了)
46
+
47
+
48
+ ![ image] ( https://github.com/lumixraku/NotesForGraphics/raw/master/images/raytracing6.png )
49
+
50
+
51
+
52
+ ### 和球的交点
53
+
54
+ ![ image] ( https://github.com/lumixraku/NotesForGraphics/raw/master/images/raytracing7.png )
55
+
56
+ ### 和显式表面怎么做呢?
57
+ 刚才 f(xx) = 0 是一个隐式表面的几何表达形式.
58
+
59
+ 显式表面其实是求光线和三角形面的交点.
60
+
61
+ PS
62
+
63
+ 如果一个点在封闭物体内部, 不论物体形状如何, 从这个点出发任意一条射线, 与物体的交点一定是奇数
64
+
65
+ ### 和三角形面的交点
66
+
67
+ 先判断和平面相交, 再判断交点是否在三角形中.
68
+
69
+ 如何判断和平面是否相交呢?
70
+ 光线的定义已经有了 o + td 那么如何定义平面呢?
71
+
72
+ 通过法线 和某一个点 其实就定义了平面
73
+
74
+ ![ image] ( https://github.com/lumixraku/NotesForGraphics/raw/master/images/raytracing8.png )
75
+
76
+ 两个向量点乘是0 表示相互垂直 (p' 是平面上任意一个点)
77
+
78
+
79
+ 和前面和球球交点问题一样, 交点即在平面上 有在光线上. 因此两个公式都满足.
80
+ ![ image] ( https://github.com/lumixraku/NotesForGraphics/raw/master/images/raytracing9.png )
81
+
82
+ ### 上面的方式是先和平面求交点, 再判断是否在三角形内. 有么有更加直接的办法呢?
83
+ ![ image] ( https://github.com/lumixraku/NotesForGraphics/raw/master/images/raytracing10.png )
84
+
85
+ 注意公式中的 1 - b1 -b2 , 点既然在三角形内, 那么这个点可以使用中心坐标去表示. (重心坐标的一个性质就是 b1+ b2 + b3 = 1)
86
+
87
+ 剩下的部分就是接方程组了
88
+
89
+
32
90
## AABB 轴对齐包围盒
33
91
用来减少没有必要的计算
34
92
35
- 基于这么一条结论: 如果光线都不和包
36
- \围盒相交, 那么光线更不和可能和包围盒中的物体相交.
93
+ 我们的摄像机, 也就是你所看到的屏幕. 每个像素都要发出一条光线, 和场景中所有的三角形求交点, 然后光线还要不断反射. 这样太慢了 怎么帮
37
94
38
- ![ image] ( https://github.com/lumixraku/NotesForGraphics/raw/master/images/aabb1.png )
39
95
40
- 最终的包围盒中的射线, 是这三者求交集
96
+
97
+ 基于这么一条结论: 如果光线都不和包围盒相交, 那么光线更不和可能和包围盒中的物体相交. 所以可以利用包围盒做加速
98
+
99
+ 上下左右前后 3对对面, 形成一个包围盒.
100
+
101
+ ![ image] ( https://github.com/lumixraku/NotesForGraphics/raw/master/images/aabb3.png )
102
+
103
+
104
+ 先看2D 情况下的包围盒
105
+
106
+ 光线射入, 记录下碰到对面1 的时间 和 离开对面2 的时间.
107
+
108
+ ![ image] ( https://github.com/lumixraku/NotesForGraphics/raw/master/images/aabb1.png )
41
109
42
110
![ image] ( https://github.com/lumixraku/NotesForGraphics/raw/master/images/aabb2.png )
111
+
112
+ 最终的包围盒中的射线, 是这三者求交集
0 commit comments