OpenCascade Ray Tracing Rendering
eryar@163.com
摘要Abstract:OpenCascade6.7.0中引入了光線跟蹤算法的實現。使用光線跟蹤算法可實現高質量的渲染效果,且可以使用GPU提升渲染效率。
關鍵字Key Words:OpenCascade, Ray Tracing
參考鏈接:Ray tracing as alternative rendering method for OCCT visualization component
http://dev.opencascade.org/index.php?q=node/898
OpenCascade 6.7.0對顯示部分做了些重大改進,其中突破性的改變是使用OpenCL實現了光線跟蹤算法。作為庫TKOpenGl的一部分,光線跟蹤算法與標準的顯示模塊完全集成。從此,光線跟蹤也可以作為顯示的一種方法。與其他第三方庫的光線跟蹤庫的區別是,內置的光線跟蹤算法確保了實時渲染時的性能,性能與OpenGL的性能相近,在有大量模型時性能比OpenGL的還要好。
光線跟蹤功能如下:
l High-quality shading by interpolating normal across the triangle pixels and using advanced illumination model (Phong shading);
l Depth-correct order-independent transparency for any number of overlapped objects;
l Sharp shadows from isotropic point and directional lights without any approximation – greatly improve visual appearance;
l Specular reflections and environment mapping – for high-quality rendering of metallic surfaces;
l Low-cost adaptive anti-aliasing allows to improve image quality by removing jagged edges from the image;
l Based on cross-platform OpenCL framework – runs on GPUs of major vendors (NVIDIA and AMD/ATI);
l Makes the most of the mid-/top-range GPUs but also runs successfully on low-end GPUs that support OpenCL。
只要OpenCascade編譯時啟用OpenCL支持,光線跟蹤的使用是相當簡單,只需要調用函數V3d_View::SetRaytracingMode()就可以把3D view切換成光線跟蹤渲染啦。參考V3d_View和文檔或者Draw Test Harness的vraytrace和vsetraytracemode命令實現的源程序去詳細了解如何設置光線跟蹤的一些選項。
最簡單的測試光線跟蹤的方式是在Draw Test Harness中輸入如下命令:
Draw[2]> source samples/tcl/bottle.tcl
生成效果如下圖所示:
Figure 1.1 Render bottle and text with ray tracing
Figure 1.2 Render pipe and equipment models with ray tracing
Figure 1.3 Render pipe and equipment models with ray tracing
從上圖可知,使用光線跟蹤效果很不錯,可以看到鏡面效果,很Cool!