计算机图形学:光线追踪加速

Ray Tracing Acceleration

1.Hierarchical (层次性) Bounding Volumes (包围盒)

1.1 Axis-Aligned Bounding Box Creation(AABB)

计算机图形学:光线追踪加速_第1张图片

the box is parallel to the x,y,z axis of the world coordinate system

Creation

  • For each axis direction (x,y,z), calculate x_min, x_max, (y_min,y_max;z_min,z_max) of the object
  • The box (x_min,x_max,y_min,y_max,z_min, z_max) is the resulting axis-aligned bounding box

1.2 Non-Axis-Aligned bounding box(OBB)

计算机图形学:光线追踪加速_第2张图片

1.3 Bounding Sphere

计算机图形学:光线追踪加速_第3张图片

Creation

  • 遍历所有点,找到包含最小x,最大x,最小y,最大y,最小z,最大z的点组
  • 计算这3组点间的最大距离作为直径,创建球体S
  • 再次遍历所有点,如果发现有点不在S内,则更新直径,创建新的球体S’,再进行遍历,直到所有点都包含在内

1.4 Hierarchical Bounding Volume(层次包围盒)

计算机图形学:光线追踪加速_第4张图片

  • Should give O(logn) time complexity rather than O(n) complexity (n = number of objects)

2.Uniform Grids (均匀格点)

计算机图形学:光线追踪加速_第5张图片

3.Quadtree/Octree (四叉树/八叉树)

计算机图形学:光线追踪加速_第6张图片

八叉树编码:

计算机图形学:光线追踪加速_第7张图片

计算机图形学:光线追踪加速_第8张图片

  • 节点编码为 q 1 q 2 . . . F F . . . F , q ∈ { 0 , 1 , . . . 7 } q_1q_2...FF...F, q\in \{0,1,...7\} q1q2...FF...F,q{0,1,...7}
  • 每个轴向代表二进制8中的一位
  • P(x, y, z)为空间一点,可将x, y, z转换成二进制编码,与八叉树的编码转换关系如下(反过来也可以)

x = i 1 i 2 . . . i N   y = j 1 j 2 . . . j N   z = k 1 k 2 . . . k N   i l , j l , k l ∈ { 0 , 1 } , l = 1 , 2 , . . . , N   q l = i l + 2 j l + 4 k l x = i_1i_2...i_N \\ \ \\ y = j_1j_2...j_N \\ \ \\ z = k_1k_2...k_N \\ \ \\ i_l,j_l,k_l \in \{0, 1\}, l = 1, 2, ..., N \\ \ \\ q_l = i_l + 2j_l + 4k_l \\ x=i1i2...iN y=j1j2...jN z=k1k2...kN il,jl,kl{0,1},l=1,2,...,N ql=il+2jl+4kl

光线跟踪过程

  • 1.首先求光所在起点 R o \bm{R_o} Ro所在单位立方体网格的八叉树编码Q: q 1 q 2 . . . q N q_1q_2...q_N q1q2...qN
  • 2.根据Q判断是否有编码前缀 q 1 q 2 . . . F F . . . F q_1q_2...FF...F q1q2...FF...F的节点在树中,如果有则计算 R o \bm{R_o} Ro与该节点中物体的交点,如果无则结束
  • 3.如果与前缀节点有交点,则计算完成后计算新的射线,如果没有交点则射线不变;然后计算射线与节点所在立方体的交点,并在射线方向添加一个扰动量(offset),回到步骤1开始新的一次追踪

4.K-d tree / BSP tree (空间二分树)

4.1 BSP (Binary Space Partition)

4.2 Polygon-aligned BSP tree

基于平面的剖分

4.3 Axis-aligned BSP tree

基于轴线的剖分

计算机图形学:光线追踪加速_第9张图片

  • A splitting plane (perpendicular to axis x or y or z) is selected to subdivide a current leaf node into two equal-size sub-nodes. Then the leaf becomes an interior node, with two new descendant leaves.
  • The process is repeated recursively until certain termination criteria are reached.
  • Traditionally, the splitting plane is positioned at the mid-point of the chosen axis, and the order of axes (x,y,z) is regularly changed on successive levels of the hierarchy (for example, first x, next y, next z, next x, …). This makes the hierarchical structure more regular.

计算机图形学:光线追踪加速_第10张图片

计算机图形学:光线追踪加速_第11张图片

4.4 Difference between kd-tree and BSP tree

Distinguished by the positioning of the splitting plane.

Conceptually, BSP tree and kd-tree are equivalent. The only difference is: in BSP-tree, the splitting plane always lies at the mid-point of the current node, resulting in two children nodes with equal size; the kd-tree can have arbitrarily positioning of the splitting planes.

Thus, any BSP tree is a kd-tree, but not vice versa.

计算机图形学:光线追踪加速_第12张图片

你可能感兴趣的:(计算机图形学)