本篇論文主要的貢獻是提出光線追蹤應用程式介面整合 OpenGL 程式設計,
讓開發者快速地獲得光線追蹤帶來的好處,並且印證光線追蹤應用程式已經可以
接近即時的速度。但此系統仍有相當大進步空間,像是讓光線追蹤改成路徑追蹤
並增加全域照明技術,使得畫面可以更逼真以及光影效果更接近現實世界,或是
支援其他的OpenGL 函式,讓此系統的整合功能趨近完整。
最後效能實驗的結果畫面解析度 800×600 和 Sponza 場景,呈現出光線追蹤
方法約11 fps 左右和光柵化方法 2612 fps 左右兩者計算速度上仍有極大的差距,
雖然已透過 GPU 加速但光線追蹤卻僅僅是達到互動性門檻而已,其中本系統未
使用到 OpenCL 內記憶體架構中的局部共享記憶體,或許改善這方面可能可以帶
來些許的效能提升。
隨著 GPU 運算能力越來越強大,即時速度的光線追蹤一定能獲得更好的效
能提升,像是 Wu, et al. [11]曾嘗試將加速結構讓 GPU 來計算希望突破靜態場景
的限制,或是Keller, et al. [12]在 ACM SIGGRAPH 2012 課程中提到更進階的蒙地
卡羅路徑追蹤相關技術,這些增進畫面品質的作法在現在幾乎沒辦法實作到即時
效果的光線追蹤或路徑追蹤演算法裡,但在未來或許能因為 GPU 硬體的提升而
讓即時速度的光線追蹤能獲得這些技術所帶來的益處。
30
附錄 A
以下是Möller and Trumbore [9]提出的光線與三角形交點測試程式碼,並且為了 應用在本論文的光線追蹤改寫成OpenCL 語言實作:
// Triangle Intersection
bool TriINTXN(Record* rec, const Ray* ray, const Triangle* tri, uint ID) {
if(rec->primID == ID) return false;
float4 e1, e2, P, Q, T;
float det, tt, uu, vv, inv_det;
e1 = tri->v1 - tri->v0;
e2 = tri->v2 - tri->v0;
P = cross(ray->dir, e2);
det = dot(e1, P);
if (det > -FLT_EPSILON && det < FLT_EPSILON) return false;
inv_det = native_recip(det);
T = ray->ori - tri->v0;
uu = dot(T, P) * inv_det;
if (uu < 0.0f || uu > 1.0f) return false;
Q = cross(T, e1);
vv = dot(ray->dir, Q) * inv_det;
if (vv < 0.0f || (uu + vv) > 1.0f) return false;
tt = dot(e2, Q) * inv_det;
if (tt > 0.0f && tt < rec->t) { rec->primID = ID;
rec->type = TRI;
rec->uv = (float2)(uu, vv);
rec->t = tt;
return true;
}
return false;
}
31
圖片引用來源
(1) 圖 1: OpenR 架構 來自以下網站:
Imagination Technologies, OpenRL SDK - Imagination Community.
Available: https://community.imgtec.com/developers/powervr/openrl-sdk/
(2) 圖 2: OpenCL Memory model 來自以下書籍篇章:
Chapter 2, Page 29 Figure 2.3 B. Gaster, L. Howes, D. R. Kaeli, P. Mistry, and D. Schaa, Heterogeneous Computing with OpenCL: Revised OpenCL 1: Newnes, 2012.
(3) 圖 5: Projection 矩陣影響視景體(左圖) 來自以下網站:
Free tutorials for modern Opengl (3.3 and later) in C/C++ Tutorial 3 : Matrices.
Available: http://www.opengl-tutorial.org/beginners-tutorials/tutorial-3-matrices/
(4) 圖 5: Projection 矩陣影響視景體(右圖) 來自以下網站:
Free tutorials for modern Opengl (3.3 and later) in C/C++ Tutorial 3 : Matrices.
Available: http://www.opengl-tutorial.org/beginners-tutorials/tutorial-3-matrices/
32
參考文獻
[1] Imagination Technologies, OpenRL SDK - Imagination Community. Available:
https://community.imgtec.com/developers/powervr/openrl-sdk/
[2] NVIDIA® OptiX™ Ray Tracing Engine | NVIDIA Developer. Available:
https://developer.nvidia.com/optix
[3] B. Paul. The Mesa 3D Graphics Library. Available: http://www.mesa3d.org/
[4] M. Pharr and G. Humphreys, Physically based rendering: From theory to implementation: Morgan Kaufmann, 2004.
[5] Khronos Group, OpenCL - The open standard for parallel programming of heterogeneous systems. Available: https://www.khronos.org/opencl/
[6] B. Gaster, L. Howes, D. R. Kaeli, P. Mistry, and D. Schaa, Heterogeneous Computing with OpenCL: Revised OpenCL 1: Newnes, 2012.
[7] Khronos Group, OpenGL - The Industry Standard for High Performance Graphics. Available: https://www.opengl.org/registry/
[8] T. Whitted, "An improved illumination model for shaded display," presented at the Proceedings of the 6th annual conference on Computer graphics and interactive techniques, Chicago, Illinois, USA, 1979.
[9] T. Möller and B. Trumbore, "Fast, minimum storage ray/triangle intersection,"
presented at the ACM SIGGRAPH 2005 Courses, Los Angeles, California, 2005.
[10] B. T. Phong, "Illumination for computer generated pictures," Commun. ACM, vol.
18, pp. 311-317, 1975.
[11] Z. Wu, F. Zhao, and X. Liu, "SAH KD-tree construction on GPU," presented at the Proceedings of the ACM SIGGRAPH Symposium on High Performance Graphics, Vancouver, British Columbia, Canada, 2011.
[12] A. Keller, S. Premoze, and M. Raab, "Advanced (quasi) Monte Carlo methods for image synthesis," in ACM SIGGRAPH 2012 Courses, 2012, p. 21.