• 沒有找到結果。

本篇論文主要貢獻為將光線追蹤技術移植到 Shader 一般化,不必再侷限於特 殊硬體,且提出兩種不同的演算法:One Pass Rendering Algorithm 和 Hybrid Rendering Algorithm。兩種演算法在第一輪上光線追蹤上並沒有什麼差別,主要 差別在於第二輪之後,Hybrid Rendering Algorithm 可由第一輪所產生的

intersection 點與事先計算儲存在 Texture Memory 的資訊做近似值的計算,用以節 省多次光線追蹤的時間成本。其次,我們將實驗分成只有單純一輪光線追蹤的 Phong 效果以及需要兩輪光線追蹤的 Environment Mapping 效果,分別跟對應 Rasterization 版本做畫面以及速度上的比較。

在這次比較中,我們在第一輪的 Phong 效果,可以得知我們的 Shader based ray tracing 因為沒有加速結構,加上 Shader based rasterization 會隨著硬體以及 Shader 管線的一些優勢,導致兩者之間的差距會隨著三角片數而加大,但畫面是沒什麼 差異的。在第二輪的 Environment Mapping 效果實驗中,我們得知再加效果上去,

畫面差異會漸漸出來,且 Shader based ray tracing 品質會比較好,而速度雖然還是 會隨著三角片數增加而差距變大,但會發現兩者的距離已經拉近許多。而 Shader based ray tracing 的方法中,結果呈現 Hybrid Rendering Algorithm 雖然畫面品質會 比 One Pass Rendering Algorithm 差一點,但速度會快許多。

然而,我們未來還要針對兩個部分下研究,才能提供一個更完整的成果說明。

第一,我們必須研究如何有效地在 Shader 上建構加速結構;第二,我們必須做更 多更複雜的效果來測試討論 One Pass Rendering Algorithm 及 Hybrid Rendering Algorithm 的使用時機,用以做更多方面的測試,訂定一套使用的標準。

36

參考文獻

相關研究論文

[CHR 05] Christen, M. (2005). Ray Tracing on GPU. Master's thesis, Univ.

Applied Sciences Basel(FHBB).

[FER 03] Fernando, R., & Kilgard, M. J. (2003). The Cg Tutorial: The definitive guide to programmable real-time graphics.

Addison-Wesley Longman Publishing Co., Inc.

[GRE 86] Greene, N.(1986)Environment mapping and other applications of world projections.

[KEP 08] KEPLER, J. (2008)Real–time Ray Tracing of Dynamic Scenes.

[MIC 07] Michael, B. (2007). Shadow Map Antialiasing. GPU Gems.

[MOL 05] Möller, T., & Trumbore, B. (2005, July). Fast, minimum storage ray/triangle intersection. In ACM SIGGRAPH 2005 Courses (p. 7).

ACM.

[PHO 75] Phong, B. T. (1975). Illumination for computer generated pictures.

Communications of the ACM, 18(6), 311-317.

[PUR 02] Purcell, T. J., Buck, I., Mark, W. R., & Hanrahan, P. (2002, July).

Ray tracing on programmable graphics hardware. In ACM Transactions on Graphics (TOG) (Vol. 21, No. 3, pp. 703-712).

ACM.

37

[PUR 04] Purcell, T. J. (2004). Ray tracing on a stream processor (Doctoral dissertation, stanford university).

[SAN 10] Sanders, J., & Kandrot, E. (2010). CUDA by example: an introduction to general-purpose GPU programming.

Addison-Wesley Professional.

[WHI 79] Whitted, T. (1979). An improved illumination model for shaded display. Proceedings of the 6th annual conference on Computer graphics and interactive techniques.

相關研究網頁文獻

[1] Evan Wallace(2010),WebGL Path Tracing, Retrieved from : http://madebyevan.com/webgl-path-tracing/

[2] Emmanuel Agu.(2013). Lecture 9(Part1): Environment Mapping(Reflections and Refractions),Retrieved from WPI Computer Graphics(CS 543) Courses:

http://web.cs.wpi.edu/~emmanuel/courses/cs543/f13/slides/lecture09_p1.pdf

[3] Friendrich A. Lohmuller(2013). Cubic Environment Mapping A Skybox with cube mapping.

Retrieved from POV-Ray Tutorial: http://www.f-lohmueller.de/pov_tut/backgrnd/p_sky9.htm

[4] Favien Sanglard(2009) Soft shadow with GLUT, GLSL and VSM. Retrieved from Favien Sanglard’s website: http://fabiensanglard.net/shadowmappingVSM/index.php

[5] GLSL Tutorial(n.d.), Retrieved from lighthouse3D: http://www.lighthouse3d.com/tutorials/

[6] GPU Ray Tracing(n.d.), (2013) Retrieved from :

http://micah-d-lamb.com/blog/opengl-tutorials/gpu-ray-tracing-2/

[7] Jerome Guinot.(2006).Environment Mapping, The Art of Texturing Using The OpenGL Shading

Language, Retrieved from oZone3D.Net: http://www.ozone3d.net/tutorials/glsl_texturing_p04.php [8] Khrons group(2013)OpenGL 4 Reference API Card, Retrieved from

38

http://www.khronos.org/files/opengl44-quick-reference-card.pdf.

[9] Resle(2010)Shadow mapping on GLSL 1.5 avoid deprecation. Retrieved from gamedev.net:

http://www.gamedev.net/topic/573885-shadowmapping-on-glsl-15-avoiding-deprecation/

[10] NVIDIA Corporation. (1999). OpenGL Cube Map Texturing. Retrieved from NVIDIA:

http://www.nvidia.com/object/cube_map_ogl_tutorial.html

相關圖片來源

(1) 圖 2.1 圖片來源:"Figure2 A streaming ray tracer" Licensed under Creative Commons

Attribution-Share Alike 3.0 via Purcell, T. J., Buck, I., Mark, W. R., & Hanrahan, P. (2002, July).

Ray tracing on programmable graphics hardware. In ACM Transactions on Graphics (TOG) (Vol.

21, No. 3, pp. 703-712). ACM.

(2) 圖 2.2 圖片來源:" Figure 4: The grid and triangle data structures stored in texture

memory. " Licensed under Creative Commons Attribution-Share Alike 3.0 via Purcell, T. J., Buck,

I., Mark, W. R., & Hanrahan, P. (2002, July). Ray tracing on programmable graphics hardware. In ACM Transactions on Graphics (TOG) (Vol. 21, No. 3, pp. 703-712). ACM.

(3) 圖 4.3 的圖片來源:"Phong components version 4". Licensed under Creative Commons

Attribution-Share Alike 3.0 via Wikimedia Commons -

http://commons.wikimedia.org/wiki/File:Phong_components_version_4.png#mediaviewer/File:Ph

ong_components_version_4.png

(4) 圖 5.8 以及圖 5.12 的圖片來源:" Långholmen ". Licensed under a Creative Commons Attribution 3.0 Unported License via Emil Persson, aka Humus

-http://www.humus.name/index.php?page=Textures&ID=48.

39

附錄 A: Möller intersection 程式碼

演算法 浮點運算次數

float triangleIntersection(vec3 rayOrgin,vec3 rayDir, int i)

{

40

else return EPS;

}//end triangleIntersection 總共 91 次

附錄 B: Phong 效果程式碼

程式碼 浮點數運算次數

vec3 lightDir = vec3(lightPos - vertex);

3 維*1 次減法,總共 3 次

vec3 halfVector=

normalize((eyePos+lightPos)/2-vertex);

正規化 1 次+3 維*(+,-)+”/”,

總共 16 次

vec3 N = normalize(Normal);

正規化 *1,總共 9 次

vec3 L = normalize(lightDir);/

正規化 *1,總共 9 次

float nl=dot(N, L);

內積*1,總共 5 次

float nhv = max(dot(N, normalize(halfVector)), 0.0); Max(1), normal(9),dot(5),總

共 15 次

if (nl> 0.0)

>,總共 1 次

{

outcolor +=0.5* pow(nhv, 70.0)* SpecularColor; (pow,*)+4 維(*,+),總共 10

outcolor +=0.5 * nl* vec4(Color,1.0); (*)+4 維(*,+),總共 9 次

} 總共 77 次

相關文件