opengl光线跟踪算法_计算机图形中的光线追踪(ray tracing)概念

这是对MIT Foundation of 3D Computer Graphics第20章的翻译,本章讲解了光线追踪(ray tracing)技术的基础知识。本书内容仍在不断的学习中,因此本文内容会不断的改进。若有任何建议,请不吝赐教nintymiles@icloud.com。

注:文章中相关内容归原作者所有,翻译内容仅供学习参考。
另:Github项目CGLearning中拥有相关翻译的完整资料、内容整理、课程项目实现。

什么是光线追踪(What is Ray Tracing)

光线追踪表达了一种不同于标准OpenGL管线的渲染方式。这种技术原理的大部分超越了本书的范围,但是我们会给出基础概念的概要。关于这个主题在本书中要参考更多,请查看本书课后练习[23]或[56]。

20.1 循环排序(Loop Ordering)

从最基本的视角,我们可以将OpenGL基于光栅化的渲染看作下面的算法形式

//psuedo code
initialize z-buffer  //启动z-buffer
for all triangles    //遍历所有三角形
	for all pixels covered by the triangle  //遍历三角形所覆盖的像素
		compute color and z    //计算像素的色彩和z值
			if z is closer than what is already in the z-buffer  //如果z比z-buffer中所见的更接近
				update the color and z of the pixel //更新这个像素的色彩和z值


这种算法具有每个场景中的三角形仅被接触一次的良好特性,并且以一种可预测的顺序。例如,正是这个原因,甚至离线的皮克斯(Pixar)的RenderMan软件也使用了这种基本算法。另一种好的特性是,在三角形处理期间,设置计算仅被完成一次并且可以在其中所有像素上平摊。正如我们已经看到的,基于光栅化的渲染可以使用迷人的着色计算甚至使用多通道算法来增强。也存在诸如遮挡剔除(参考课后例子[11])等高级算法,这些算法尝试避免渲染那些在场景中我们知道其会被其它物体所遮挡的三角形。
在基本的光线追踪中,我们反转循环顺序以获得如下的算法

//psuedo code
for all pixels on the screen
    for all objects seen in this pixel  //对于在这个像素被看到的所有物体
        if this is the closest object seen at the pixel  //如果其是在像素上被看到的最近的物体
            compute color and z  //计算色彩和z值
            set the color of the pixel //设置这个像素的色彩

在第二行中,我们需要计算沿着一个像素的

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
For those that do not know me: My name is Jacco Bikker, also known as 'Phantom'. I work as '3D tech guy' at Overloaded, a company that develops and distributes games for mobile phones. I specialize at 3D Symbian games, which require highly optimized fixed-point, non-HW-accelerated 3D engines, crammed into 250Kb installers. So basically I'm having fun. As software rendering used to be my spare time activity, I was looking for something else. I tried some AI, which was great fun, and recently I dove into a huge pile of research papers on raytracing and related topics; such as global illumination, image based lighting, photon maps and so on. One document especially grabbed my attention. It's titled: "State-of-the-Art in Interactive Ray Tracing", and was written by Wald & Slusallek. I highly recommend this paper. Basically, it summarizes recent efforts to improve the speed of raytracing, and adds a couple of tricks too. But it starts with a list of benefits of raytracing over rasterization-based algorithms. And one of those benefits is that when you go to extremes, raytracing is actually faster than rasterizing. And they prove it: Imagine a huge scene, consisting of, say, 50 million triangles. Toss it at a recent GeForce with enough memory to store all those triangles, and write down the frame rate. It will be in the vicinity of 2-5. If it isn't, double the triangle count. Now, raytrace the same scene. These guys report 8 frames per second on a dual PIII/800. Make that a quad PIII/800 and the speed doubles. Raytracing scales linearly with processing power, but only logarithmically with scene complexity. Now that I got your attention, I would like to move on to the intended contents of this crash course in raytracing.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值