﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-寂静岭</title><link>http://www.cppblog.com/yaoming/</link><description>图形学专业空间</description><language>zh-cn</language><lastBuildDate>Sun, 05 Apr 2026 05:15:11 GMT</lastBuildDate><pubDate>Sun, 05 Apr 2026 05:15:11 GMT</pubDate><ttl>60</ttl><item><title>经典理论教程 光与材质的艺术解析</title><link>http://www.cppblog.com/yaoming/archive/2008/07/07/55521.html</link><dc:creator>姚明</dc:creator><author>姚明</author><pubDate>Mon, 07 Jul 2008 04:18:00 GMT</pubDate><guid>http://www.cppblog.com/yaoming/archive/2008/07/07/55521.html</guid><wfw:comment>http://www.cppblog.com/yaoming/comments/55521.html</wfw:comment><comments>http://www.cppblog.com/yaoming/archive/2008/07/07/55521.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/yaoming/comments/commentRss/55521.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/yaoming/services/trackbacks/55521.html</trackback:ping><description><![CDATA[<p>渲染的概念</p>
<p>渲染，英文为Render,也有的把它称为着色，但我更习惯把Shade称为着色，把Render称为渲染。因为Render和Shade值两个词在三维软件中是截然不同的两个概念，虽然它们的功能很相似，但却有不同。Shade是一种显示方案，一般出现在三维软件的主要窗口中，和三维模型的线框图一样起到辅助观察模型的作用。很明显，着色模式比线框模式更容易让我们理解模型的结构，但它只是简单的显示而已，数字图像中把它称为明暗着色法。在像<a title="" href="http://www.86vr.com/cg/tutorials/200511/topicnews.aspx?topicid=6"><font color=#0000ff>maya</font></a>这样的高级三维软件中，还可以用Shade显示出简单的灯光效果、阴影效果和表面纹理效果，当然，高质量的着色效果是需要专业三维图形显示卡来支持的，它可以加速和优化三维图形的显示。但无论怎样优化，它都无法把显示出来的三维图形变成高质量的图像，这时因为Shade采用的是一种实时显示技术，硬件的速度限制它无法实时地反馈出场景中的反射、折射等光线追踪效果。而现实工作中我们往往要把模型或者场景输出成图像文件、视频信号或者电影胶片，这就必须经过Render程序。<br>Shade视窗，提供了非常直观、实时的表面基本着色效果，根据硬件的能力，还能显示出纹理贴图、光源影响甚至阴影效果，但这一切都是粗糙的，特别是在没有硬件支持的情况下，它的显示甚至会是无理无序的。Render效果就不同了，它是基于一套完整的程序计算出来的，硬件对它的影响只是一个速度问题，而不会改变渲染的结果，影响结果的是看它是基于什么程序渲染的，比如是光影追踪还是光能传递。</p>
<p><br>渲染的基本过程</p>
<p>首先，必须定位三维场景中的摄像机，这和真实的摄影是一样的。一般来说，三维软件已经提供了四个默认的摄像机，那就是软件中四个主要的窗口，分为顶视图、正视图、侧视图和透视图。我们大多数时候渲染的是透视图而不是其他视图，透视图的摄像机基本遵循真实摄像机的原理，所以我们看到的结果才会和真实的三维世界一样，具备立体感。接下来，为了体现空间感，渲染程序要做一些&#8220;特殊&#8221;的工作，就是决定哪些物体在前面、哪些物体在后面和那些物体被遮挡等。空间感仅通过物体的遮挡关系是不能完美再现的，很多初学三维的人只注意立体感的塑造而忽略了空间感。要知道空间感和光源的衰减、环境雾、景深效果都是有着密切联系的。<br>渲染程序通过摄像机获取了需要渲染的范围之后，就要计算光源对物体的影响，这和真实世界的情况又是一样的。许多三维软件都有默认的光源，否则，我们是看不到透视图中的着色效果的，更不要说渲染了。因此，渲染程序就是要计算我们在场景中添加的每一个光源对物体的影响。和真实世界中光源不同的是，渲染程序往往要计算大量的辅助光源。在场景中，有的光源会照射所有的物体，而有的光源只照射某个物体，这样使得原本简单的事情又变得复杂起来。在这之后，还要是使用深度贴图阴影还是使用光线追踪阴影？这往往取决于在场景中是否使用了透明材质的物体计算光源投射出来的阴影。另外，使用了面积光源之后，渲染程序还要计算一种特殊的阴影－－软阴影（只能使用光线追踪），场景中的光源如果使用了光源特效，渲染程序还将花费更多的系统资源来计算特效的结果，特别是体积光，也称为灯光雾，它会占用代量的系统资源，使用的时候一定要注意。<br>在这之后，渲染程序还要根据物体的材质来计算物体表面的颜色，材质的类型不同，属性不同，纹理不同都会产生各种不同的效果。而且，这个结果不是独立存在的，它必须和前面所说的光源结合起来。如果场景中有粒子系统，比如火焰、烟雾等，渲染程序都要加以&#8220;考虑&#8221;。</p>
<p><br>智能光</p>
<p>我一直认为，自然界的光是具有智慧的，它像一个魔法师，把世界变得缤纷绚丽，甚至离奇古怪，而渲染程序中的光就显得笨拙的得多了，程序虽然提供了足够多的光源类型来让我们模拟真实世界的光源，但就其本质来说，都只解决了光源的直接照射问题，而真实世界中的照明不是这样的，它还存在再次反射的现象，也就是通常所说的的光能传递，现在流行的叫法是Global Illumination，即全局照明。不要把它跟Lightscape的光能传递相混淆，他们虽然在原理和结果上非常相似，但是算方式却不一样。<br>光的&#8220;智能&#8221;还体现在它的反射和折射质量上，这个质量并不是指渲染图像的质量或者光线追踪的正确与否，而是指是否能自动完成与光线的反射和折射有关的所有效果。Caustic特效的产生成为了高级渲染程序的一个重要标志。Cau-stic是一种光学特效，通常出现在有反射和折射属性的物体上，比如透明的圆球、凸透镜、镜子、水面等，它包含聚焦和散焦两个方面的效果。<br>就目前的情况来说，衡量一个渲染程序里的光源是否具有&#8220;智能&#8221;，不是看它的光源类型有多么丰富，或者说，已经与直接照明没有什么关系了（所有的渲染程序都能很好的解决直接照明的问题），而是与光源的间接照明有密切的关系。无论是天空光还是全局照明，或者是Caustic特效，都不是光源直接照射到物体上产生的效果，它们是光线的Diffu-se、Radiosity、Reflection和Refraction产生的结果，产生这些结果的自动化程度越高，即不需借助任何辅助光源，我们就可以把该渲染程序的光源看成是有&#8220;智能&#8221;的。需要注意的是，并不是说不能自动产生间接照明效果的渲染程序就是低级的。我们依然可以使用辅助光源来模拟那些间接照明的效果，作为渲染的图像来说，我们关心的仍然是图像所显示的效果，而不是产生结果的方法，所谓条条大路通罗马，目的才是最重要的。我们不要迷失其中。<br>［说明：天空光是一种很特殊的光源。准确的说天空光不应该称为光源，它是由于大气漫反射太阳光形成的，所以，它也可以看成是太阳光的间接照明。］</p>
<p><br>材质的真相</p>
<p>材质是什么？简单的说就是物体看起来是什么质地。材质可以看成是材料和质感的结合。在渲染程序中，它是表面各可视属性的结合，这些可视属性是指表面的色彩、纹理、光滑度、透明度、反射率、折射率、发光度等。正是有了这些属性，才能让我们识别三维中的模型是什么做成的，也正是有了这些属性，我们计算机三维的虚拟世界才会和真实世界一样缤纷多彩。<br>这就是材质的真相吗？答案是否定的。不要奇怪，我们必须仔细分析产生不同材质的原因，才能让我们更好的把握质感。那么，材质的真相到底是什么呢？仍然是光，离开光材质是无法体现的。举例来说，借助夜晚微弱的天空光，我们往往很难分辨物体的材质，而在正常的照明条件下，则很容易分辨。另外，在彩色光源的照射下，我们也很难分辨物体表面的颜色，在白色光源的照射下则很容易。这种情况表明了物体的材质与光的微妙关系。下面，我们将具体分析两者间的相互作用。</p>
<p><br>色彩（包括纹理）</p>
<p>色彩是光的一种特性，我们通常看到的色彩是光作用于眼睛的结果。但光线照射到物体上的时候，物体会吸收一些光色，同时也会漫反射一些光色，这些漫反射出来的光色到达我们的的眼睛之后，就决定物体看起来是什么颜色，这种颜色在绘画中称为&#8220;固有色&#8221;。这些被漫反射出来的光色除了会影响我们的视觉之外，还会影响它周围的物体，这就是光能传递。当然，影响的范围不会像我们的视觉范围那么大，它要遵循光能衰减的原理。另外，有很多资料把Radiosity翻译成&#8220;热辐射&#8221;，其实这也蛮贴切的，因为物体在反射光色的时候，光色就是以辐射的形式发散出去的，所以，它周围的物体才会出现&#8220;染色&#8221;现象。</p>
<p><br>光滑与反射</p>
<p>一个物体是否有光滑的表面，往往不需要用手去触摸，视觉就会告诉我们结果。因为光滑的物体，总会出现明显的高光，比如玻璃、瓷器、金属&#8230;&#8230;&#8230;而没有明显高光的物体，通常都是比较粗糙的，比如砖头、瓦片、泥土&#8230;&#8230;&#8230;这种差异在自然界无处不在，但它是怎么产生的呢？依然是光线的反射作用，但和上面&#8220;固有色&#8221;的漫反射方式不同，光滑的物体有一种类似&#8220;镜子&#8221;的效果，在物体的表面还没有光滑到可以镜像反射出周围的物体的时候，它对光源的位置和颜色是非常敏感的。所以，光滑的物体表面只&#8220;镜射&#8221;出光源，这就是物体表面的高光区，它的颜色是由照射它的光源颜色决定的（金属除外），随着物体表面光滑度的提高，对光源的反射会越来越清晰，这就是在三维材质编辑中，越是光滑的物体高光范围越小，强度越高。当高光的清晰程度已经接近光源本身后，物体表面通常就要呈现出另一种面貌了，这就是Reflection材质产生的原因，也是古人磨铜为镜的原理。但必须注意的是，不是任何材质都可以在不断的&#8220;磨练&#8221;中提高自己的光滑程度。比如我们很清楚瓦片是不可能磨成镜的，为什么呢？原因是瓦片是很粗糙的，这个粗糙不单指它的外观，也指它内部的微观结构。瓦片质地粗糙里面充满了气孔，无论怎样磨它，也只能使它的表面看起来整齐，而不能填补这些气孔，所以无法成镜。我们在编辑材质的时候，一定不能忽视材质光滑度的上限，有很多初学者作品中的物体看起来都像是塑料做的就是这个原因。</p>
<p><br>透明与折射</p>
<p>自然界的大多数物体通常会遮挡光线，当光线可以自由的穿过物体时，这个物体肯定就是透明的。这里所指的&#8220;穿过&#8221;，不单指光源的光线穿过透明物体，还指透明物体背后的物体反射出来的光线也要再次穿过透明物体，这样使我们可以看见透明物体背后的东西。由于透明物体的密度不同，光线射入后会发生偏转现象，这就是折射。比如插进水里的筷子，看起来就是弯的。不同的透明物质其折射率也不一样，即使同一种透明的物质，温度的不同也会影响其折射率，比如当我们穿过火焰上方的热空气观察对面的景象，会发现有明显的扭曲现象。这就是因为温度改变了空气的密度，不同的密度产生了不同的折射率。正确的使用折射率是真实再现透明物体的重要手段。<br>在自然界中还存在另一种形式的透明，在三维软件的材质编辑中把这种属性称之为&#8220;半透明&#8221;，比如纸张、塑料、植物的叶子、还有蜡烛等等。它们原本不是透明的物体，但在强光的照射下背光部分会出现&#8220;透光&#8221;现象。<br>通过上面简单的描述，相信大家已经进一步了解了光和材质的关系，如果在编辑材质时忽略了光的作用，是很难调出有真实感的材质的。因此，在材质编辑器中调节各种属性时，必须考虑到场景中的光源，并参考基础光学现象，最终以达到良好的视觉效果为目的，而不是孤立的调节它们。当然，也不能一味的照搬物理现象，毕竟艺术和科学之间还是存在差距的，真实与唯美也不是同一个概念。</p>
<p>关于摄像机</p>
<p>一幅渲染出来的图像其实就是一幅画面。在模型定位之后，光源和材质决定了画面的色调，而摄像机就决定了画面的构图。在确定摄像机的位置时，总是考虑到大众的视觉习惯，在大多数情况下视点不应高于正常人的身高，也会根据室内的空间结构，选择是采用人蹲着的视点高度、坐着的视点高度或是站立时的视点高度，这样渲染出来的图像就会符合人的视觉习惯，看起来也会很舒服。在使用站立时的视点高度时，目标点一般都会在视点的同一高度，也就是平视。这样墙体和柱子的垂直*廓线才不会产生透视变形，给人稳定的感觉，这种稳定感和舒适感就是靠摄像机营造出来的。<br>当然，这种放置摄像机的方法不见得也适合表现室外的建筑，我想说的是，摄像机的位置必须考虑观察者所处的位置和习惯，否则画面会看起来很别扭。在影视作品中，摄影机的自由度会大得多，为了表现特殊的情感效果。有时会故意使用一些夸张、甚至极端的镜头，要注意区别对待。<br>那么，在三维软件中的摄像机除了影响构图之外，还有什么其他的作用呢？当然有，这就是景深效果和运动模糊。应该说这两种特效都是和摄像机密不可分的，因为摄像机（或照相机）都有光圈和快门，而光圈和快门就是产生景深效果和运动模糊的直接原因，所以，运用好这两种特效是再现真实摄像效果的必要手段。<br>三维软件里的摄像机，除了上面提到的内容外，还有更复杂的部分，那就是摄像机的运动。如果你的工作不会涉及到动画制作，可以忽略与摄像机运动有关的内容，但不论怎样，花点时间看看摄像方面的书籍是很有帮助的。要知道影视作品和我们平时照相不同，照相注重构图和用光，影视作品更讲究镜头的运动和镜头的切换。所以，如果你要运用好你的&#8220;虚拟摄像机&#8221;，就必须参考专业类的书籍，千万不要再凭自己的想象，否则，费了好大的劲儿制作好了模型，设置好了光源，把最难调的材质也调好了，还设置了动画关键帧，本来应该有个好的渲染结果了，却因为使用了&#8220;蹩脚&#8221;的摄像机镜头和运动方法而导致剪辑师无从下手，结果前功尽弃。当然，这种结果在三维动画制作中并不多见，原因是三维动画制作通常都是先有了分镜头脚本（也叫故事板）才开始制作的。每个分镜头脚本中都注明了该用什么样的镜头以及如何运用镜头，但这并不表示我们可以不用去学习镜头语言，假如你对镜头一无所知，那该怎样才能看懂分镜头脚本呢？也就更谈不上制作了吧。<br></p>
<img src ="http://www.cppblog.com/yaoming/aggbug/55521.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/yaoming/" target="_blank">姚明</a> 2008-07-07 12:18 <a href="http://www.cppblog.com/yaoming/archive/2008/07/07/55521.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>硬盘保护卡破解--小哨兵篇</title><link>http://www.cppblog.com/yaoming/archive/2008/01/10/40895.html</link><dc:creator>姚明</dc:creator><author>姚明</author><pubDate>Thu, 10 Jan 2008 06:19:00 GMT</pubDate><guid>http://www.cppblog.com/yaoming/archive/2008/01/10/40895.html</guid><wfw:comment>http://www.cppblog.com/yaoming/comments/40895.html</wfw:comment><comments>http://www.cppblog.com/yaoming/archive/2008/01/10/40895.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.cppblog.com/yaoming/comments/commentRss/40895.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/yaoming/services/trackbacks/40895.html</trackback:ping><description><![CDATA[<span style="COLOR: #3366ff">六年前研究保护卡的时候，写下的一堆文字，最先被《看雪》论坛收录，至今仍然能在网上搜索到，自己写的东西，被流传开来，真的很有成就感的事情！怀恋一下，呵呵！（<span style="COLOR: #ff0000">当时还是小屁孩，</span><span style="COLOR: #ff0000">文字略显稚嫩</span>）</span><br><br>硬盘保护卡破解--小哨兵篇 &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 作者:Ym &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 2002.6.15 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 23:43:50 &nbsp; &nbsp; &nbsp; &nbsp; email:yaomingmail@sina.com &nbsp; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 现在硬盘保护卡日益盛行,网吧,学校随处可见,本人就遇到几种类型和品牌的,小哨兵是其中技术比较完善的一种.早期在学校机房遇到的看门狗,就存在严重的技术缺陷,只要修改cmos中的硬盘参数即可破解,所以这里我想着重谈谈小哨兵的解法,当然对付看门狗的方法在这里是行不通的,为此我琢磨了很长时间,直到我前几天在网上看到一篇破解硬盘保护卡的文章,给我一个崭新的破解思路,但事实上按原文的方法还是不可破解小哨兵,但离成功仅一步之遥,这篇文章就算是一个补充说明,希望能对大家有点帮助. &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; 首先本人通过阅读那篇文章后,得知保护卡是通过修改中断向量来达到保护硬盘不被真正写入的,其中int13是关键,同时还修改了时钟中断来达到反跟踪,恢复中断向量表的目的.小哨兵拦截了int13的处理程序,将自己的程序挂到上面,这也是无法写进数据的原因所在,知道了这个,你一定会说我们只要把bios的int13的程序地址,在dos下填入中断向量表不就大功告成了,其实不然,小哨兵早以想到了这一点,它会利用早以被它修改过的时钟中断定时检查中断向量表,它一旦发现0000:4c+3处为f0即会修改为别的值.原文章的建议是将时钟中断一一还原,本人觉得太过烦琐,而且出错的可能性大,不可取.经过尝试将原中断处理程序的第一条语句改为0255:0148(此不一定) &nbsp; jmp &nbsp; f000:xxxx即可. &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; 这里还要谈谈xxxx的获取,这一步也是关键,我一开始用debug &nbsp; t跟踪了几次都出现了死机,通过观察每次死机地址都不同,怀疑小哨兵利用时钟中断反跟踪,但每次跟踪都给了一段时间后才死机,所以在进入int13后你要在这段时间内,以最快的速度,t到f000:xxxx &nbsp; <br>&nbsp; 处,当屏幕上t出第一个f000为段的地方时,后面的偏移量即为我们要找的xxxx.记住它,相信这时你已经死机了,重新启动,f8进dos. &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; debug &nbsp; <br>&nbsp; -d &nbsp; 0:4c &nbsp; <br>&nbsp; 0000:004c &nbsp; 48 &nbsp; 01 &nbsp; 55 &nbsp; 02 &nbsp; <br>&nbsp; -a &nbsp; 0255:0148 &nbsp; <br>&nbsp; -0255:0148 &nbsp; jmp &nbsp; f000:xxxx &nbsp; <br>&nbsp; -q &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; c:\&gt;cd &nbsp; windows &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; c:\windows&gt;win &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; OK,现在改个桌面,拷个游戏进去,再重新启动试一下,还在吧,游戏可要藏好哟,祝你愉快! 
<img src ="http://www.cppblog.com/yaoming/aggbug/40895.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/yaoming/" target="_blank">姚明</a> 2008-01-10 14:19 <a href="http://www.cppblog.com/yaoming/archive/2008/01/10/40895.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>3D工具軟體介紹 (含影音後製、AutoCAD替代軟體)</title><link>http://www.cppblog.com/yaoming/archive/2008/01/02/40200.html</link><dc:creator>姚明</dc:creator><author>姚明</author><pubDate>Tue, 01 Jan 2008 18:09:00 GMT</pubDate><guid>http://www.cppblog.com/yaoming/archive/2008/01/02/40200.html</guid><wfw:comment>http://www.cppblog.com/yaoming/comments/40200.html</wfw:comment><comments>http://www.cppblog.com/yaoming/archive/2008/01/02/40200.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/yaoming/comments/commentRss/40200.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/yaoming/services/trackbacks/40200.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 隨著新學期的開始，新課程所須使用到的軟體類型也有所不同，之前曾對 2D 繪圖的相關軟體做一番小整理，這次則是來整理跨平台的 3D 工具軟體，不過由於平常對 3D 的處理需求非常少 (就是沒啥接觸啦！加上 3D 的運算通常都需要有較高的電腦硬體來處理會比較合適，以我的硬體配備來說很明顯是跑不順的 Orz，這也是降低我去接觸的原因之一)，而且 3D 動畫模型在處理各個不同層面的運算分類還蠻多樣、詳細的...&nbsp;&nbsp;<a href='http://www.cppblog.com/yaoming/archive/2008/01/02/40200.html'>阅读全文</a><img src ="http://www.cppblog.com/yaoming/aggbug/40200.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/yaoming/" target="_blank">姚明</a> 2008-01-02 02:09 <a href="http://www.cppblog.com/yaoming/archive/2008/01/02/40200.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>反射映射</title><link>http://www.cppblog.com/yaoming/archive/2008/01/01/40141.html</link><dc:creator>姚明</dc:creator><author>姚明</author><pubDate>Tue, 01 Jan 2008 00:59:00 GMT</pubDate><guid>http://www.cppblog.com/yaoming/archive/2008/01/01/40141.html</guid><wfw:comment>http://www.cppblog.com/yaoming/comments/40141.html</wfw:comment><comments>http://www.cppblog.com/yaoming/archive/2008/01/01/40141.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/yaoming/comments/commentRss/40141.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/yaoming/services/trackbacks/40141.html</trackback:ping><description><![CDATA[<h1 class=firstHeading>反射映射</h1>
<div id=bodyContent>
<h3 id=siteSub>&nbsp;</h3>
<div id=contentSub></div>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 182px"><a class=image title=反射映射实例 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Spoon_fi.jpg'))"><img class=thumbimage height=140 alt=反射映射实例 src="http://upload.wikimedia.org/wikipedia/commons/thumb/5/5c/Spoon_fi.jpg/180px-Spoon_fi.jpg" width=180 border=0></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=放大 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Spoon_fi.jpg'))"><img height=11 alt="" src="http://zh.wikipedia.org/skins-1.5/common/images/magnify-clip.png" width=15></a></div>
反射映射实例</div>
</div>
</div>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 182px"><a class=image title="环境映射是基于图像照明的基础，看这里 rthdribl 中的一个截屏图像" href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Tj_silverteapot_stpeters.jpg'))"><img class=thumbimage height=135 alt="环境映射是基于图像照明的基础，看这里 rthdribl 中的一个截屏图像" src="http://upload.wikimedia.org/wikipedia/zh/thumb/e/e6/Tj_silverteapot_stpeters.jpg/180px-Tj_silverteapot_stpeters.jpg" width=180 border=0></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=放大 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Tj_silverteapot_stpeters.jpg'))"><img height=11 alt="" src="http://zh.wikipedia.org/skins-1.5/common/images/magnify-clip.png" width=15></a></div>
环境映射是<a class=new title=基于图像照明 href="http://zh.wikipedia.org/w/index.php?title=%E5%9F%BA%E4%BA%8E%E5%9B%BE%E5%83%8F%E7%85%A7%E6%98%8E&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>基于图像照明</font></u></a>的基础，看这里 <a class="external text" title=http://www.daionet.gr.jp/~masa/rthdribl/ href="http://www.daionet.gr.jp/%7Emasa/rthdribl/" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>rthdribl</font></u></a> 中的一个截屏图像</div>
</div>
</div>
<p>在<a title=计算机图形学 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9B%BE%E5%BD%A2%E5%AD%A6'))"><u><font color=#0000ff>计算机图形学</font></u></a>领域，<strong>反射映射</strong>是用预先计算的纹理图像模拟复杂镜面的一种高效方法。纹理用来储存被渲染物体周围环境的图像。有几种不同的方法可以用来保存周围环境，其中最常用的方法之一是<strong>标准环境映射</strong>，在这种方法中周围环境在一个镜面球体上反射得到单一纹理图像。另外一种常用方法是<strong>立方环境映射</strong>，在这种方法中环境在立方体的六个表面上<em>显现</em>出来，所以需要保存为六个正方形的纹理。</p>
<p>这种实现方法比传统的<a title=光线跟踪 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%85%89%E7%BA%BF%E8%B7%9F%E8%B8%AA'))"><u><font color=#0000ff>光线跟踪</font></u></a>（光线跟踪通过射出一束光线并且跟踪光线的传输路径来计算反射）算法效率更高，但是需要注意的是这种方法是实际反射的一种近似，有时甚至是非常粗糙的近似。这种技术的一个典型的缺点是没有考虑自反射，即无法看到物体反射的物体自身的某一部分。</p>
<table class=toc id=toc summary=目录>
    <tbody>
        <tr>
            <td>
            <div id=toctitle>
            <h2>目录</h2>
            </div>
            <ul>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.85.B8.E5.9E.8B.E7.9A.84.E5.8F.8D.E5.B0.84.E6.98.A0.E5.B0.84"><font color=#800080><u><span class=tocnumber>1</span><span class=toctext>典型的反射映射</span></u></font></a>
                <ul>
                    <li class=toclevel-2><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E6.A0.87.E5.87.86.E7.8E.AF.E5.A2.83.E6.98.A0.E5.B0.84"><font color=#800080><u><span class=tocnumber>1.1</span><span class=toctext>标准环境映射</span></u></font></a></li>
                    <li class=toclevel-2><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E7.AB.8B.E6.96.B9.E7.8E.AF.E5.A2.83.E6.98.A0.E5.B0.84"><font color=#800080><u><span class=tocnumber>1.2</span><span class=toctext>立方环境映射</span></u></font></a></li>
                </ul>
                </li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.9C.A8.E5.AE.9E.E6.97.B6.E4.B8.89.E7.BB.B4.E8.AE.A1.E7.AE.97.E6.9C.BA.E5.9B.BE.E5.BD.A2.E4.B8.AD.E7.9A.84.E5.BA.94.E7.94.A8"><font color=#800080><u><span class=tocnumber>2</span><span class=toctext>在实时三维计算机图形中的应用</span></u></font></a>
                <ul>
                    <li class=toclevel-2><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E6.A0.87.E5.87.86.E7.8E.AF.E5.A2.83.E6.98.A0.E5.B0.84_2"><font color=#800080><u><span class=tocnumber>2.1</span><span class=toctext>标准环境映射</span></u></font></a></li>
                    <li class=toclevel-2><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E7.AB.8B.E6.96.B9.E7.8E.AF.E5.A2.83.E6.98.A0.E5.B0.84_2"><font color=#800080><u><span class=tocnumber>2.2</span><span class=toctext>立方环境映射</span></u></font></a></li>
                </ul>
                </li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.8F.82.E8.A7.81"><u><font color=#800080><span class=tocnumber>3</span><span class=toctext>参见</span></font></u></a></li>
            </ul>
            </td>
        </tr>
    </tbody>
</table>
<p><a name=.E5.85.B8.E5.9E.8B.E7.9A.84.E5.8F.8D.E5.B0.84.E6.98.A0.E5.B0.84><u><font color=#800080></font></u></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%8F%8D%E5%B0%84%E6%98%A0%E5%B0%84&amp;action=edit&amp;section=1" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>典型的反射映射</span></h2>
<p><a name=.E6.A0.87.E5.87.86.E7.8E.AF.E5.A2.83.E6.98.A0.E5.B0.84></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%8F%8D%E5%B0%84%E6%98%A0%E5%B0%84&amp;action=edit&amp;section=2" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>标准环境映射</span></h3>
<p><strong>标准环境映射</strong>更加常用的名称是<strong>球形环境映射</strong>，是反射无限远环境物体的纹理球面的应用。使用<a title=鱼眼镜头 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E9%B1%BC%E7%9C%BC%E9%95%9C%E5%A4%B4'))"><u><font color=#0000ff>鱼眼镜头</font></u></a>、<a title=光线跟踪 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%85%89%E7%BA%BF%E8%B7%9F%E8%B8%AA'))"><u><font color=#0000ff>预渲染</font></u></a>或者<a class=new title=光探头 href="http://zh.wikipedia.org/w/index.php?title=%E5%85%89%E6%8E%A2%E5%A4%B4&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>光探头</font></u></a>生成球形纹理，然后将这个纹理映射到空球表面，通过计算物体上个点的光向量到达环境图上的纹素从而确定纹素的颜色。这项技术类似于<a title=光线跟踪 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%85%89%E7%BA%BF%E8%B7%9F%E8%B8%AA'))"><u><font color=#0000ff>光线跟踪</font></u></a>，但是由于所需物体各点的所有颜色<a class=new title=图形处理单元 href="http://zh.wikipedia.org/w/index.php?title=%E5%9B%BE%E5%BD%A2%E5%A4%84%E7%90%86%E5%8D%95%E5%85%83&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>图形处理单元</font></u></a>已经预先知道，所以所需做的就是计算入射与反射角度。</p>
<p><a title=1982年 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/1982%E5%B9%B4'))"><u><font color=#0000ff>1982年</font></u></a> Gene Miller 在 MAGI Synthavision 首次试验了球形环境映射。<sup class=reference id=_ref-spheremap_0><a title="" href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#_note-spheremap"><u><font color=#800080>[1]</font></u></a></sup> 在 Christine Chang 的帮助下，他在 MAGI 的停车场拍摄了一幅圣诞装饰照片。通过将球体的照片裁减到直径大小，他将照片映射到空球表面（参见上面的过程）(<a class="external text" title=http://www.debevec.org/ReflectionMapping/Images/08-768.JPG href="http://www.debevec.org/ReflectionMapping/Images/08-768.JPG" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Fig. 1</font></u></a>)。然后，他将这幅纹理用到 Ken Perlin (<a class="external text" title=http://www.debevec.org/ReflectionMapping/Images/11-768.JPG href="http://www.debevec.org/ReflectionMapping/Images/11-768.JPG" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Fig. 2</font></u></a>) 创建的一个斑点狗模型上，并且将环境映射模型添加到停车场照片上，就得到 <a class="external text" title=http://www.debevec.org/ReflectionMapping/Images/07-768.JPG href="http://www.debevec.org/ReflectionMapping/Images/07-768.JPG" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Fig. 3</font></u></a> 中的照片。这种环境映射的技术最后在真实的环境<a title=高动态范围成像 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E9%AB%98%E5%8A%A8%E6%80%81%E8%8C%83%E5%9B%B4%E6%88%90%E5%83%8F'))"><u><font color=#800080>高动态范围成像</font></u></a>中的<a class=new title=基于图像的照明 href="http://zh.wikipedia.org/w/index.php?title=%E5%9F%BA%E4%BA%8E%E5%9B%BE%E5%83%8F%E7%9A%84%E7%85%A7%E6%98%8E&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>基于图像的照明</font></u></a>中得到了应用（参见<a class="external text" title=http://www.debevec.org/Probes/ href="http://www.debevec.org/Probes/" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>这里</font></u></a>）。</p>
<p>球形映射有一些明显的限制，其中之一是，由于纹理属性的原因，在球形映射物体的后面有一个突变点。下面的<strong>立方映射</strong>就是为了解决这个问题而开发出来的，如果能够正确地生成与滤波，立方映射就没有明显的接缝，所以很显然它是旧的球形映射的替代者，目前球形环境映射在当今的图形应用中几乎已经销声匿迹了。</p>
<p><a name=.E7.AB.8B.E6.96.B9.E7.8E.AF.E5.A2.83.E6.98.A0.E5.B0.84></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%8F%8D%E5%B0%84%E6%98%A0%E5%B0%84&amp;action=edit&amp;section=3" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>立方环境映射</span></h3>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 182px"><a class=image title=解释立方映射工作原理的示意图 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Cube_mapped_reflection_example.jpg'))"><img class=thumbimage height=216 alt=解释立方映射工作原理的示意图 src="http://upload.wikimedia.org/wikipedia/commons/thumb/6/67/Cube_mapped_reflection_example.jpg/180px-Cube_mapped_reflection_example.jpg" width=180 border=0></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=放大 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Cube_mapped_reflection_example.jpg'))"><img height=11 alt="" src="http://zh.wikipedia.org/skins-1.5/common/images/magnify-clip.png" width=15></a></div>
解释立方映射工作原理的示意图</div>
</div>
</div>
<p><strong>立方反射映射</strong>是用<a class=new title=立方映射 href="http://zh.wikipedia.org/w/index.php?title=%E7%AB%8B%E6%96%B9%E6%98%A0%E5%B0%84&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>立方映射</font></u></a>使得物体看起来如同在反射周围环境的一项技术。通常，这通常使用户外渲染中使用的 <a class=new title="Skybox (video games)" href="http://zh.wikipedia.org/w/index.php?title=Skybox_%28video_games%29&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>skybox</font></u></a> 完成。尽管由于反射物周围的物体无法在结果中看到，所以这并不是一个真正的反射，但是通常仍然可以达到所期望的效果。</p>
<p>通过确定观察物体的<a title=向量 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%90%91%E9%87%8F'))"><u><font color=#0000ff>向量</font></u></a>就可以进行立方映射反射，<strong>照相机光线</strong>在照相机向量与物体相交的位置按照<a class=new title=曲面法线 href="http://zh.wikipedia.org/w/index.php?title=%E6%9B%B2%E9%9D%A2%E6%B3%95%E7%BA%BF&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>曲面法线</font></u></a>方向进行反射，这样传到<a class=new title=立方图 href="http://zh.wikipedia.org/w/index.php?title=%E7%AB%8B%E6%96%B9%E5%9B%BE&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>立方图</font></u></a>（cube map）取得<a title=纹素 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%BA%B9%E7%B4%A0'))"><u><font color=#0000ff>纹素</font></u></a>(texel)的<strong>反射光线</strong>在照相机看来好像位于物体表面，这样就得到了物体的反射效果。</p>
<p><a name=.E5.9C.A8.E5.AE.9E.E6.97.B6.E4.B8.89.E7.BB.B4.E8.AE.A1.E7.AE.97.E6.9C.BA.E5.9B.BE.E5.BD.A2.E4.B8.AD.E7.9A.84.E5.BA.94.E7.94.A8></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%8F%8D%E5%B0%84%E6%98%A0%E5%B0%84&amp;action=edit&amp;section=4" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>在实时三维计算机图形中的应用</span></h2>
<p><a name=.E6.A0.87.E5.87.86.E7.8E.AF.E5.A2.83.E6.98.A0.E5.B0.84_2></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%8F%8D%E5%B0%84%E6%98%A0%E5%B0%84&amp;action=edit&amp;section=5" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>标准环境映射</span></h3>
<p><a name=.E7.AB.8B.E6.96.B9.E7.8E.AF.E5.A2.83.E6.98.A0.E5.B0.84_2></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%8F%8D%E5%B0%84%E6%98%A0%E5%B0%84&amp;action=edit&amp;section=6" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>立方环境映射</span></h3>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 182px"><a class=image title=使用立方反射映射的一个三维模型实例 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Cube_mapped_reflection_example_2.JPG'))"><img class=thumbimage height=180 alt=使用立方反射映射的一个三维模型实例 src="http://upload.wikimedia.org/wikipedia/commons/thumb/1/19/Cube_mapped_reflection_example_2.JPG/180px-Cube_mapped_reflection_example_2.JPG" width=180 border=0></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=放大 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Cube_mapped_reflection_example_2.JPG'))"><img height=11 alt="" src="http://zh.wikipedia.org/skins-1.5/common/images/magnify-clip.png" width=15></a></div>
使用立方反射映射的一个三维模型实例</div>
</div>
</div>
<p>如果能够正确使用，立方映射反射或许是渲染反射表面最快的方法。为了提高渲染的速度，每个定点都要计算反射光线的位置，然后，在于这些定点相关的多边形中对位置进行插值，这样就可取消对每个像素的反射进行计算。</p>
<p><a name=.E5.8F.82.E8.A7.81></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%8F%8D%E5%B0%84%E6%98%A0%E5%B0%84&amp;action=edit&amp;section=7" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>参见</span></h2>
<ul>
    <li><a class="external text" title=http://www.debevec.org/ReflectionMapping/ href="http://www.debevec.org/ReflectionMapping/" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>The Story of Reflection mapping</font></u></a> cured by <a class=new title="Paul Debevec" href="http://zh.wikipedia.org/w/index.php?title=Paul_Debevec&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><font color=#0000ff><u>Paul Debevec</u></font></a></li>
    <li><a class=new title="Skybox (video games)" href="http://zh.wikipedia.org/w/index.php?title=Skybox_%28video_games%29&amp;action=edit" target=_blank><font color=#0000ff><u><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Skybox (video games)</u></font></a></li>
    <li><a class=new title=立方映射 href="http://zh.wikipedia.org/w/index.php?title=%E7%AB%8B%E6%96%B9%E6%98%A0%E5%B0%84&amp;action=edit" target=_blank><u><font color=#0000ff><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">立方映射</font></u></a></li>
</ul>
</div>
<img src ="http://www.cppblog.com/yaoming/aggbug/40141.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/yaoming/" target="_blank">姚明</a> 2008-01-01 08:59 <a href="http://www.cppblog.com/yaoming/archive/2008/01/01/40141.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>双线性滤波</title><link>http://www.cppblog.com/yaoming/archive/2008/01/01/40140.html</link><dc:creator>姚明</dc:creator><author>姚明</author><pubDate>Tue, 01 Jan 2008 00:58:00 GMT</pubDate><guid>http://www.cppblog.com/yaoming/archive/2008/01/01/40140.html</guid><wfw:comment>http://www.cppblog.com/yaoming/comments/40140.html</wfw:comment><comments>http://www.cppblog.com/yaoming/archive/2008/01/01/40140.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cppblog.com/yaoming/comments/commentRss/40140.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/yaoming/services/trackbacks/40140.html</trackback:ping><description><![CDATA[<h1 class=firstHeading>双线性滤波</h1>
<div id=bodyContent>
<h3 id=siteSub>&nbsp;</h3>
<div id=contentSub></div>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 221px"><a class=image title=经过缩放的一小部分猫的位图图像，左图使用了最近邻插值滤波，右图是用了立方滤波。立方插值滤波类似于双线性插值 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Pixel_interpolation.png'))"><img class=thumbimage height=73 alt=经过缩放的一小部分猫的位图图像，左图使用了最近邻插值滤波，右图是用了立方滤波。立方插值滤波类似于双线性插值 src="http://upload.wikimedia.org/wikipedia/zh/d/d6/Pixel_interpolation.png" width=219 border=0></a>
<div class=thumbcaption>经过<a title=缩放 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%BC%A9%E6%94%BE'))"><u><font color=#0000ff>缩放</font></u></a>的一小部分<a title=猫 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%8C%AB'))"><u><font color=#0000ff>猫</font></u></a>的<a title=位图 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E4%BD%8D%E5%9B%BE'))"><u><font color=#800080>位图</font></u></a>图像，左图使用了<a class=new title=最近邻插值 href="http://zh.wikipedia.org/w/index.php?title=%E6%9C%80%E8%BF%91%E9%82%BB%E6%8F%92%E5%80%BC&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>最近邻插值</font></u></a>滤波，右图是用了立方滤波。<a class=new title=立方插值 href="http://zh.wikipedia.org/w/index.php?title=%E7%AB%8B%E6%96%B9%E6%8F%92%E5%80%BC&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>立方插值</font></u></a>滤波类似于双线性插值</div>
</div>
</div>
<p><strong>双线性滤波</strong>是进行缩放显示的时候进行纹理平滑的一种<a class=new title=纹理滤波 href="http://zh.wikipedia.org/w/index.php?title=%E7%BA%B9%E7%90%86%E6%BB%A4%E6%B3%A2&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>纹理滤波</font></u></a>方法。 在大多数情况下，纹理在屏幕上显示的时候都不会同保存的纹理一模一样，没有任何失真。正因为这样，所以一些像素要使用<a title=纹素 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%BA%B9%E7%B4%A0'))"><u><font color=#0000ff>纹素</font></u></a>之间的点进行表示，在这里我们假设纹素都是位于各个单元中心或者左上或者其它位置的点。双线性滤波器利用这些点在像素所表示点周围四个最近的点之间进行<a title=双线性插值 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%8F%8C%E7%BA%BF%E6%80%A7%E6%8F%92%E5%80%BC'))"><u><font color=#0000ff>双线性插值</font></u></a>。</p>
<table class=toc id=toc summary=目录>
    <tbody>
        <tr>
            <td>
            <div id=toctitle>
            <h2>目录</h2>
            </div>
            <ul>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.85.AC.E5.BC.8F"><font color=#800080><u><span class=tocnumber>1</span><span class=toctext>公式</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E7.A4.BA.E4.BE.8B.E4.BB.A3.E7.A0.81"><font color=#800080><u><span class=tocnumber>2</span><span class=toctext>示例代码</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.B1.80.E9.99.90"><font color=#800080><u><span class=tocnumber>3</span><span class=toctext>局限</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E7.89.B9.E6.AE.8A.E6.83.85.E5.86.B5"><font color=#800080><u><span class=tocnumber>4</span><span class=toctext>特殊情况</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.8F.82.E8.A7.81"><u><font color=#800080><span class=tocnumber>5</span><span class=toctext>参见</span></font></u></a></li>
            </ul>
            </td>
        </tr>
    </tbody>
</table>
<p><a name=.E5.85.AC.E5.BC.8F><u><font color=#800080></font></u></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%8F%8C%E7%BA%BF%E6%80%A7%E6%BB%A4%E6%B3%A2&amp;action=edit&amp;section=1" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>公式</span></h2>
<p>在下面这些方程中，u<sub>k</sub> 与 v<sub>k</sub> 是纹理坐标，y<sub>k</sub> 是点 k 处的颜色值。不带下标的值表示像素点，带有下标 0、1、2、3 的值表示从左上到右下包围像素的纹素点，这就是<a title=线性插值 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%BA%BF%E6%80%A7%E6%8F%92%E5%80%BC'))"><u><font color=#0000ff>线性插值</font></u></a>方程。由于双线性方程是线性插值方程的一种特殊形式，所以 我们从较简单的线性插值方程开始分析。</p>
<dl>
<dd><img class=tex alt="y_a = y_0 + \frac{y_1-y_0}{u_1-u_0}(u-u_0) \,\!" src="http://www.gollumbrowser.com/tc/math/4/a/3/4a3b5fe4cf81183c7e187975f9d2ddc3.png"></dd>
<dd><img class=tex alt="y_b = y_2 + \frac{y_3-y_2}{u_3-u_2}(u-u_2) \,\!" src="http://www.gollumbrowser.com/tc/math/8/5/1/851d971e26055dd812305efde5145bcf.png"></dd>
<dd><img class=tex alt="y = y_b + \frac{y_b-y_a}{v_2-v_0}(v-v_0) \,\!" src="http://www.gollumbrowser.com/tc/math/0/0/d/00d779466791a482f01fd77b492a580d.png"></dd></dl>
<p>假设纹理是正方形的位图，并且满足</p>
<dl>
<dd><img class=tex alt="v_1 = v_0 \,\!" src="http://www.gollumbrowser.com/tc/math/e/8/1/e81912d5c8d1313b21f62dd0addc4942.png"></dd>
<dd><img class=tex alt="v_2 = v_3 \,\!" src="http://www.gollumbrowser.com/tc/math/b/e/3/be31b69f5c5ebdf7d14969d9ecc00cdc.png"></dd>
<dd><img class=tex alt="u_1 = u_3 \,\!" src="http://www.gollumbrowser.com/tc/math/0/7/6/076900cbb98a23f73698abf15a0644eb.png"></dd>
<dd><img class=tex alt="u_2 = u_0 \,\!" src="http://www.gollumbrowser.com/tc/math/6/0/6/606e642f3d41c3ba7d8b12d68892d1a7.png"></dd>
<dd><img class=tex alt="v_3 - v_0 = u_3 - u_0 = w \,\!" src="http://www.gollumbrowser.com/tc/math/9/e/e/9ee1bedb627487fe682e753e1e012a3a.png"></dd></dl>
<p>我们进一步定义，</p>
<dl>
<dd><img class=tex alt="U = \frac{u - u_0}{w} \,\!" src="http://www.gollumbrowser.com/tc/math/1/5/2/1527612c526ca5112c9eac92e3112b4b.png"></dd>
<dd><img class=tex alt="V = \frac{v - v_0}{w} \,\!" src="http://www.gollumbrowser.com/tc/math/4/3/f/43f5a701ed5e795c7999f8c5a2743b2f.png"></dd></dl>
<p>这样就可以将插值方程化简为：</p>
<dl>
<dd><img class=tex alt="y_a = y_0 + (y_1-y_0)U \,\!" src="http://www.gollumbrowser.com/tc/math/e/3/9/e394da77e9893e5706034b3fe4790966.png"></dd>
<dd><img class=tex alt="y_b = y_2 + (y_3-y_2)U \,\!" src="http://www.gollumbrowser.com/tc/math/e/c/e/eced82a104622815ca6a08d0d6ed8e8e.png"></dd>
<dd><img class=tex alt="y = y_a + (y_b-y_a)V \,\!" src="http://www.gollumbrowser.com/tc/math/7/d/3/7d302ce63583e13ead355658d384c1a5.png"></dd></dl>
<p>代入方程，得到：</p>
<dl>
<dd><img class=tex alt="y = y_0 + (y_1 - y_0)U + (y_2 - y_0)V + (y_3 - y_2 - y_1 + y_0)UV \,\!" src="http://www.gollumbrowser.com/tc/math/f/9/3/f9344d8cf82d0bc9fa902125e2873769.png"></dd></dl>
<p>或者，</p>
<dl>
<dd><img class=tex alt="y = y_0(1 - U)(1 - V) + y_1 U (1 - V) + y_2 (1 - U) V + y_3 U V \,\!" src="http://www.gollumbrowser.com/tc/math/c/9/8/c98f49195fc81cf5340dac97a1f2a16c.png"></dd></dl>
<p>这种表示相当简单。但是，如果图像只进行缩放处理，而没有旋转、扭曲、透视或者其它处理，那么使用独立的方程计算并且保存用于后面数据行计算的 y<sub>b</sub> 或者 y<sub>a</sub> 速度将更快。</p>
<p><a name=.E7.A4.BA.E4.BE.8B.E4.BB.A3.E7.A0.81></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%8F%8C%E7%BA%BF%E6%80%A7%E6%BB%A4%E6%B3%A2&amp;action=edit&amp;section=2" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>示例代码</span></h2>
<p>这部分代码假设纹理是常见的正方形，没有<a class=new title=Mipmap href="http://zh.wikipedia.org/w/index.php?title=Mipmap&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Mipmap</font></u></a>，并且只有一个通道的数据。只有一个通道的情况非常少见，几乎所有的纹理都是彩色的，都有红色、绿色与蓝色通道，有些还有阿尔法透明通道，所以每个 y 都要进行三到四次的计算</p>
<pre>double getBilinearFilteredPixelColor(Texture tex, double u, double v) {
u *= tex.size;
v *= tex.size;
int x = floor(u);
int y = floor(v);
double u_ratio = u - x;
double v_ratio = v - y;
double u_opposite = 1 - u_ratio;
double v_opposite = 1 - v_ratio;
double result = (tex[x][y]   * u_opposite + tex[x+1][y]   * u_ratio) * v_opposite +
(tex[x][y+1] * u_opposite + tex[x+1][y+1] * u_ratio) * v_ratio;
return result;
}
</pre>
<p><a name=.E5.B1.80.E9.99.90></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%8F%8C%E7%BA%BF%E6%80%A7%E6%BB%A4%E6%B3%A2&amp;action=edit&amp;section=3" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>局限</span></h2>
<p>在纹理缩减到一半或者放大一倍的范围内，双线性滤波都能够有非常好的精度。这也就是说，如果纹理在每个方向都有 256 个像素，那么将它缩减到 128 以下或者放大到 512 以上的时候，由于会丢掉太多的像素或者进行了过多的平滑处理，纹理看起来就会很差。通常，可以在缩减的过程中使用 <a class=new title=Mipmap href="http://zh.wikipedia.org/w/index.php?title=Mipmap&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Mipmap</font></u></a> 来实现较好的性能；但是，在透视图中的纹理上的经过双线性滤波处理的两个不同尺寸的 mipmap 之间的过渡将非常明显。<a class=new title=三线性滤波 href="http://zh.wikipedia.org/w/index.php?title=%E4%B8%89%E7%BA%BF%E6%80%A7%E6%BB%A4%E6%B3%A2&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>三线性滤波</font></u></a>尽管比较复杂，但是可以使得过渡非常平滑。</p>
<p>为了快速说明纹理滤波中如何丢失纹素，这里有一组用来自于 8 纹素宽纹理的数字表示的盒子的中心，它们与蓝色表示的来自于 3 纹素宽的纹理表示的盒子中心的一组数字混杂在一起。红色数字表示计算 3 纹素纹理中根本不需要的纹素。</p>
<p>0.0625, <span style="COLOR: blue">0.1667</span>, 0.1875, <span style="COLOR: red">0.3125</span>, 0.4375, <span style="COLOR: blue">0.5000</span>, 0.5625, <span style="COLOR: red">0.6875</span>, 0.8125, <span style="COLOR: blue">0.8333</span>, 0.9375</p>
<p><a name=.E7.89.B9.E6.AE.8A.E6.83.85.E5.86.B5></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%8F%8C%E7%BA%BF%E6%80%A7%E6%BB%A4%E6%B3%A2&amp;action=edit&amp;section=4" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>特殊情况</span></h2>
<p>通常纹理是有限大小的，我们经常会得到坐标位于纹素坐标之外栅格之外的像素。可以用以下几种方法来处理这种情况：</p>
<ul>
    <li>旋绕纹理，这样一行中的最后一个纹素将出现在该行第一个纹素的前面，一列中的最后一个纹素将出现在该列第一个纹素前面。在纹理平铺的时候这种方法可以得到最好的效果。</li>
    <li>纹理之外的区域使用一种颜色。这可能并不是一个非常了不起的想法，但是如果纹理要放到固体或者透明背景上，那么就可以使用这种方法。</li>
    <li>无限重复边界纹素。如果所设计的纹理不是要重复使用的话，这种方法可以很好地工作。</li>
</ul>
<p><a name=.E5.8F.82.E8.A7.81></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%8F%8C%E7%BA%BF%E6%80%A7%E6%BB%A4%E6%B3%A2&amp;action=edit&amp;section=5" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>参见</span></h2>
<ul>
    <li><a class=new title=三线性滤波 href="http://zh.wikipedia.org/w/index.php?title=%E4%B8%89%E7%BA%BF%E6%80%A7%E6%BB%A4%E6%B3%A2&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><font color=#0000ff><u>三线性滤波</u></font></a></li>
    <li><a class=new title=各向异性滤波 href="http://zh.wikipedia.org/w/index.php?title=%E5%90%84%E5%90%91%E5%BC%82%E6%80%A7%E6%BB%A4%E6%B3%A2&amp;action=edit" target=_blank><u><font color=#0000ff><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">各向异性滤波</font></u></a></li>
</ul>
</div>
<img src ="http://www.cppblog.com/yaoming/aggbug/40140.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/yaoming/" target="_blank">姚明</a> 2008-01-01 08:58 <a href="http://www.cppblog.com/yaoming/archive/2008/01/01/40140.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>位移映射</title><link>http://www.cppblog.com/yaoming/archive/2008/01/01/40139.html</link><dc:creator>姚明</dc:creator><author>姚明</author><pubDate>Tue, 01 Jan 2008 00:51:00 GMT</pubDate><guid>http://www.cppblog.com/yaoming/archive/2008/01/01/40139.html</guid><wfw:comment>http://www.cppblog.com/yaoming/comments/40139.html</wfw:comment><comments>http://www.cppblog.com/yaoming/archive/2008/01/01/40139.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/yaoming/comments/commentRss/40139.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/yaoming/services/trackbacks/40139.html</trackback:ping><description><![CDATA[<h1 class=firstHeading>位移映射</h1>
<div id=bodyContent>
<h3 id=siteSub>&nbsp;</h3>
<div id=contentSub></div>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 182px"><a class=image title=位移映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Displacement.jpg'))"><img class=thumbimage height=267 alt=位移映射 src="http://upload.wikimedia.org/wikipedia/zh/thumb/a/a4/Displacement.jpg/180px-Displacement.jpg" width=180 border=0></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=放大 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Displacement.jpg'))"><img height=11 alt="" src="http://zh.wikipedia.org/skins-1.5/common/images/magnify-clip.png" width=15></a></div>
位移映射</div>
</div>
</div>
<p><strong>位移映射</strong>是使用<a class=new title=高度图 href="http://zh.wikipedia.org/w/index.php?title=%E9%AB%98%E5%BA%A6%E5%9B%BE&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>高度图</font></u></a>将经过纹理化的表面上实际几何点位置沿着表面法线根据保存在纹理中的数值进行移位的技术，这是与<a title=凸凹纹理映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%87%B8%E5%87%B9%E7%BA%B9%E7%90%86%E6%98%A0%E5%B0%84'))"><u><font color=#0000ff>凸凹纹理映射</font></u></a>、<a title=法向映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%B3%95%E5%90%91%E6%98%A0%E5%B0%84'))"><u><font color=#0000ff>法向映射</font></u></a>以及<a title=视差映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%A7%86%E5%B7%AE%E6%98%A0%E5%B0%84'))"><u><font color=#0000ff>视差映射</font></u></a>不同的技术。</p>
<p>多年以来，位移映射一直是 <a title=RenderMan href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/RenderMan'))"><u><font color=#0000ff>RenderMan</font></u></a> 这样的高端渲染系统的一个特性，如 <a title=OpenGL href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/OpenGL'))"><u><font color=#0000ff>OpenGL</font></u></a> 与 <a title=DirectX href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/DirectX'))"><u><font color=#0000ff>DirectX</font></u></a> 这样的<a title=应用程序编程接口 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%E7%BC%96%E7%A8%8B%E6%8E%A5%E5%8F%A3'))"><u><font color=#0000ff>应用程序编程接口</font></u></a>则没有这样的特性，其中一个原因就是位移映射的最初实现为了得到与屏幕上的像素匹配的<a class=new title=微多边形 href="http://zh.wikipedia.org/w/index.php?title=%E5%BE%AE%E5%A4%9A%E8%BE%B9%E5%BD%A2&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>微多边形</font></u></a>（<a class=extiw title=en:micropolygon href="javascript:void(wb.w._link('http://en.wikipedia.org/wiki/micropolygon'))"><u><font color=#0000ff>en:micropolygon</font></u></a>）需要自适应的表面镶嵌。</p>
<p>在最新一代的图形处理硬件上，位移映射可以解释为一种顶点-纹理映射。在这种方法中，纹理映射的数值将不再改变像素的颜色，而是用来改变顶点的位置。与凸凹纹理映射和法向映射不同，位移映射可以用这种方法生成真正<em>粗糙</em>的表面。目前只在一小部分的桌面图形处理器上实现了这种功能，并且为了生成非常细致的网格、得到更好的三维感觉以及更好的纹理深度与细节需要与自适应的镶嵌术配合使用，自适应镶嵌技术可以根据当前的观察参数设定增加渲染的多边形数目。</p>
<p><a name=.E8.BF.9B.E4.B8.80.E6.AD.A5.E7.9A.84.E9.98.85.E8.AF.BB.E8.B5.84.E6.96.99></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E4%BD%8D%E7%A7%BB%E6%98%A0%E5%B0%84&amp;action=edit&amp;section=1" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>进一步的阅读资料</span></h2>
<ul>
    <li><a class="external text" title=http://mediawiki.blender.org/index.php/Manual/Displacement_Maps href="http://mediawiki.blender.org/index.php/Manual/Displacement_Maps" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><font color=#0000ff><u>Blender Displacement Mapping</u></font></a></li>
    <li><a class="external text" title=http://www.inf.ufrgs.br/%7Eoliveira/RTM.html href="http://www.inf.ufrgs.br/%7Eoliveira/RTM.html" target=_blank rel=nofollow><u><font color=#0000ff><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">浮雕纹理映射</font></u></a>网站</li>
    <li><a class="external text" title=http://www.inf.ufrgs.br/%7Eoliveira/pubs_files/Policarpo_Oliveira_Comba_RTRM_I3D_2005.pdf href="http://www.inf.ufrgs.br/%7Eoliveira/pubs_files/Policarpo_Oliveira_Comba_RTRM_I3D_2005.pdf" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><em><u><font color=#0000ff>任意多边形表面的实时浮雕纹理映射</font></u></em></a>论文</li>
    <li><a class="external text" title=http://www.inf.ufrgs.br/%7Eoliveira/pubs_files/Policarpo_Oliveira_RTM_multilayer_I3D2006.pdf href="http://www.inf.ufrgs.br/%7Eoliveira/pubs_files/Policarpo_Oliveira_RTM_multilayer_I3D2006.pdf" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><em><u><font color=#0000ff>无高度场的表面细节的浮雕纹理映射</font></u></em></a>论文</li>
</ul>
<p><a name=.E5.8F.82.E8.A7.81></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E4%BD%8D%E7%A7%BB%E6%98%A0%E5%B0%84&amp;action=edit&amp;section=2" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>参见</span></h2>
<ul>
    <li><a title=纹理映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%BA%B9%E7%90%86%E6%98%A0%E5%B0%84'))"><font color=#0000ff><u>纹理映射</u></font></a></li>
    <li><a title=凸凹纹理映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%87%B8%E5%87%B9%E7%BA%B9%E7%90%86%E6%98%A0%E5%B0%84'))"><font color=#0000ff><u>凸凹纹理映射</u></font></a></li>
    <li><a title=法向映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%B3%95%E5%90%91%E6%98%A0%E5%B0%84'))"><font color=#0000ff><u>法向映射</u></font></a></li>
    <li><a title=视差映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%A7%86%E5%B7%AE%E6%98%A0%E5%B0%84'))"><font color=#0000ff><u>视差映射</u></font></a></li>
    <li><a class=new title=演示效果 href="http://zh.wikipedia.org/w/index.php?title=%E6%BC%94%E7%A4%BA%E6%95%88%E6%9E%9C&amp;action=edit" target=_blank><font color=#0000ff><u><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">演示效果</u></font></a></li>
    <li><a class=new title=高度图 href="http://zh.wikipedia.org/w/index.php?title=%E9%AB%98%E5%BA%A6%E5%9B%BE&amp;action=edit" target=_blank><u><font color=#0000ff><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">高度图</font></u></a></li>
</ul>
</div>
<img src ="http://www.cppblog.com/yaoming/aggbug/40139.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/yaoming/" target="_blank">姚明</a> 2008-01-01 08:51 <a href="http://www.cppblog.com/yaoming/archive/2008/01/01/40139.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>子分曲面</title><link>http://www.cppblog.com/yaoming/archive/2008/01/01/40138.html</link><dc:creator>姚明</dc:creator><author>姚明</author><pubDate>Tue, 01 Jan 2008 00:43:00 GMT</pubDate><guid>http://www.cppblog.com/yaoming/archive/2008/01/01/40138.html</guid><wfw:comment>http://www.cppblog.com/yaoming/comments/40138.html</wfw:comment><comments>http://www.cppblog.com/yaoming/archive/2008/01/01/40138.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/yaoming/comments/commentRss/40138.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/yaoming/services/trackbacks/40138.html</trackback:ping><description><![CDATA[<h1 class=firstHeading>子分曲面</h1>
<div id=bodyContent>
<h3 id=siteSub>&nbsp;</h3>
<div id=contentSub></div>
<p><a title=计算机图形学 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9B%BE%E5%BD%A2%E5%AD%A6'))"><u><font color=#0000ff>计算机图形学</font></u></a>中，<strong>子分曲面</strong>用于从任意网格创建光滑曲面。子分曲面定义为一个无穷细化过程的极限。它们由<a class=new title="Edwin Catmull" href="http://zh.wikipedia.org/w/index.php?title=Edwin_Catmull&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Edwin Catmull</font></u></a>和Jim Clark，还有Daniel Doo和Malcom Sabin在1978年同时引入。在1995年之前该方法没有什么进展，直到Ulrich Reif解决了子分曲面在特殊点附近的行为。</p>
<p>最基本的概念是细化。通过反复细化初始的多边形网格，可以产生一系列网格趋向于最终的子分曲面。每个新的子分步骤产生一个新的有更多多边形元素并且更光滑的网格。</p>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 182px"><a class=image title=立方体的Catmull-Clark子分的最初三步和子分曲面 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Catmull-Clark_subdivision_of_a_cube.svg'))"><img class=thumbimage height=260 alt=立方体的Catmull-Clark子分的最初三步和子分曲面 src="http://upload.wikimedia.org/wikipedia/commons/thumb/3/33/Catmull-Clark_subdivision_of_a_cube.svg/180px-Catmull-Clark_subdivision_of_a_cube.svg.png" width=180 border=0></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=放大 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Catmull-Clark_subdivision_of_a_cube.svg'))"><img height=11 alt="" src="http://zh.wikipedia.org/skins-1.5/common/images/magnify-clip.png" width=15></a></div>
立方体的Catmull-Clark子分的最初三步和子分曲面</div>
</div>
</div>
<table class=toc id=toc summary=目录>
    <tbody>
        <tr>
            <td>
            <div id=toctitle>
            <h2>目录</h2>
            </div>
            <ul>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.AD.90.E5.88.86.E6.96.B9.E6.B3.95"><font color=#800080><u><span class=tocnumber>1</span><span class=toctext>子分方法</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E7.9B.B8.E5.AF.B9.E4.BA.8ENURBS.E6.A8.A1.E5.9E.8B.E7.9A.84.E4.BC.98.E7.82.B9"><font color=#800080><u><span class=tocnumber>2</span><span class=toctext>相对于NURBS模型的优点</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.92.8CB-.E6.A0.B7.E6.9D.A1.E7.9A.84.E5.85.B3.E7.B3.BB"><font color=#800080><u><span class=tocnumber>3</span><span class=toctext>和B-样条的关系</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E7.BB.86.E5.8C.96.E8.BF.9B.E7.A8.8B"><font color=#800080><u><span class=tocnumber>4</span><span class=toctext>细化进程</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E7.89.B9.E6.AE.8A.E7.82.B9"><font color=#800080><u><span class=tocnumber>5</span><span class=toctext>特殊点</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.A4.96.E9.83.A8.E9.93.BE.E6.8E.A5"><u><font color=#800080><span class=tocnumber>6</span><span class=toctext>外部链接</span></font></u></a></li>
            </ul>
            </td>
        </tr>
    </tbody>
</table>
<p><a name=.E5.AD.90.E5.88.86.E6.96.B9.E6.B3.95><u><font color=#800080></font></u></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%AD%90%E5%88%86%E6%9B%B2%E9%9D%A2&amp;action=edit&amp;section=1" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>子分方法</span></h2>
<p>有几种细化方案：</p>
<ul>
    <li><strong><a class=new title=Catmull-Clark子分曲面 href="http://zh.wikipedia.org/w/index.php?title=Catmull-Clark%E5%AD%90%E5%88%86%E6%9B%B2%E9%9D%A2&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Catmull-Clark</font></u></a></strong>是双三次<a title=B-样条 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/B-%E6%A0%B7%E6%9D%A1'))"><u><font color=#0000ff>B-样条</font></u></a>的推广</li>
    <li><strong>Doo-Sabin</strong>是双二次均匀<a title=B-样条 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/B-%E6%A0%B7%E6%9D%A1'))"><u><font color=#0000ff>B-样条</font></u></a>的推广</li>
    <li><strong>Loop</strong> 是二次三角形<a class=new title=Box样条 href="http://zh.wikipedia.org/w/index.php?title=Box%E6%A0%B7%E6%9D%A1&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>box样条</font></u></a>的推广，由Charles Loop发明。（可以用于三角形网格）</li>
    <li><strong>蝶型</strong> 因为该方案的形状得名</li>
    <li><strong>中边（Midedge）</strong></li>
    <li><strong>Kobbelt</strong> 是变分法子分方法，它试图克服均匀子分的缺点。</li>
</ul>
<p><a name=.E7.9B.B8.E5.AF.B9.E4.BA.8ENURBS.E6.A8.A1.E5.9E.8B.E7.9A.84.E4.BC.98.E7.82.B9></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%AD%90%E5%88%86%E6%9B%B2%E9%9D%A2&amp;action=edit&amp;section=2" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>相对于NURBS模型的优点</span></h2>
<p>在主要的建模软件中，子分曲面建模现在比<a class=new title=非均匀有理样条 href="http://zh.wikipedia.org/w/index.php?title=%E9%9D%9E%E5%9D%87%E5%8C%80%E6%9C%89%E7%90%86%E6%A0%B7%E6%9D%A1&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>非均匀有理样条</font></u></a>（NURBS）建模更为流行。因为它们有很多优点：</p>
<ul>
    <li>适用于任意拓扑结构</li>
    <li>数值上稳定</li>
    <li>实现简易</li>
    <li>局部连续性控制</li>
    <li>局部细化</li>
</ul>
<p><a name=.E5.92.8CB-.E6.A0.B7.E6.9D.A1.E7.9A.84.E5.85.B3.E7.B3.BB></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%AD%90%E5%88%86%E6%9B%B2%E9%9D%A2&amp;action=edit&amp;section=3" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>和B-样条的关系</span></h2>
<p><a title=B-样条 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/B-%E6%A0%B7%E6%9D%A1'))"><u><font color=#0000ff>B-样条</font></u></a>曲线可以细化：他们的控制点序列可以细化而迭代进程收敛于实际曲线。这对于曲线来讲毫无用处，但是它推广到曲面就产生了子分曲面。</p>
<p><a name=.E7.BB.86.E5.8C.96.E8.BF.9B.E7.A8.8B></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%AD%90%E5%88%86%E6%9B%B2%E9%9D%A2&amp;action=edit&amp;section=4" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>细化进程</span></h2>
<p><a title=插值 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%8F%92%E5%80%BC'))"><u><font color=#0000ff>插值</font></u></a>过程在保持原有定点不动的情况下插入新的点。</p>
<p>细化过程在子分的每一步插入新的顶点并移动旧的定点。</p>
<p><a name=.E7.89.B9.E6.AE.8A.E7.82.B9></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%AD%90%E5%88%86%E6%9B%B2%E9%9D%A2&amp;action=edit&amp;section=5" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>特殊点</span></h2>
<p>Catmull-Clark细化方案是双三次均匀<a title=B-样条 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/B-%E6%A0%B7%E6%9D%A1'))"><u><font color=#0000ff>B-样条</font></u></a>的一个推广。曲面的等价于一个4x4控制点格点的每一部分代表一个双三次均匀B-样条片。曲面细化在控制点<a class=new title=价 href="http://zh.wikipedia.org/w/index.php?title=%E4%BB%B7&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>价</font></u></a>（相邻点个数）等于4的那些区域很容易进行。定义价不是4的定点的子分曲面曾经很困难；这样的点称为<strong>特殊点</strong>。类似的，在Doo-Sabin方案中的特殊点是价不是3的点。</p>
<p>多数方案在子分过程中不产生新的特殊点。</p>
<p><a name=.E5.A4.96.E9.83.A8.E9.93.BE.E6.8E.A5></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%AD%90%E5%88%86%E6%9B%B2%E9%9D%A2&amp;action=edit&amp;section=6" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>外部链接</span></h2>
<ul>
    <li><a class="external text" title=http://www.subdivision.org/subdivision/index.jsp href="http://www.subdivision.org/subdivision/index.jsp" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><font color=#0000ff><u>Resources about subdvisions</u></font></a></li>
    <li><a class="external text" title=http://www.pixar.com/shorts/gg/theater/index.html href="http://www.pixar.com/shorts/gg/theater/index.html" target=_blank rel=nofollow><u><font color=#0000ff><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Geri\'s Game</font></u></a>&nbsp;: Oscar winning animation by <a title=Pixar href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Pixar'))"><u><font color=#0000ff>Pixar</font></u></a> completed in 1997 that introduced subdivision surfaces (along with cloth simulation)</li>
    <li><a class="external text" title=http://www.mrl.nyu.edu/dzorin/sig00course/ href="http://www.mrl.nyu.edu/dzorin/sig00course/" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>SIGGRAPH 2000 Course Notes</font></u></a>&nbsp;: Subdivision for Modeling and Animation paper</li>
</ul>
</div>
<img src ="http://www.cppblog.com/yaoming/aggbug/40138.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/yaoming/" target="_blank">姚明</a> 2008-01-01 08:43 <a href="http://www.cppblog.com/yaoming/archive/2008/01/01/40138.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>实体造型</title><link>http://www.cppblog.com/yaoming/archive/2008/01/01/40137.html</link><dc:creator>姚明</dc:creator><author>姚明</author><pubDate>Tue, 01 Jan 2008 00:42:00 GMT</pubDate><guid>http://www.cppblog.com/yaoming/archive/2008/01/01/40137.html</guid><wfw:comment>http://www.cppblog.com/yaoming/comments/40137.html</wfw:comment><comments>http://www.cppblog.com/yaoming/archive/2008/01/01/40137.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/yaoming/comments/commentRss/40137.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/yaoming/services/trackbacks/40137.html</trackback:ping><description><![CDATA[<h1 class=firstHeading>实体造型</h1>
<div id=bodyContent>
<h3 id=siteSub>&nbsp;</h3>
<div id=contentSub></div>
<p><strong>实体造型(Solid modelling)</strong> (或<strong>造型(modeling)</strong>，<strong>立体造型</strong>)研究物体的立体部分的统一表示，也就是说，立体物体的适合计算机处理的<a title=模型 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%A8%A1%E5%9E%8B'))"><u><font color=#0000ff>模型</font></u></a>。也被称为<strong>体造型(volume modeling)</strong>。其他的造型方法包括曲面造型(在动画中广泛使用)和<a title=线框模型 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%BA%BF%E6%A1%86%E6%A8%A1%E5%9E%8B'))"><u><font color=#0000ff>线框模型</font></u></a>(所表示的立体有歧义)。</p>
<p>实体造型的主要用途是<a title=计算机辅助设计 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%AE%A1%E7%AE%97%E6%9C%BA%E8%BE%85%E5%8A%A9%E8%AE%BE%E8%AE%A1'))"><u><font color=#0000ff>计算机辅助设计</font></u></a>，<a class=new title=工程分析 href="http://zh.wikipedia.org/w/index.php?title=%E5%B7%A5%E7%A8%8B%E5%88%86%E6%9E%90&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>工程分析</font></u></a>，<a title=计算机图形学 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9B%BE%E5%BD%A2%E5%AD%A6'))"><u><font color=#0000ff>计算机图形学</font></u></a>和<a title=动画 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%8A%A8%E7%94%BB'))"><u><font color=#0000ff>动画</font></u></a>，<a class=new title=快速原型 href="http://zh.wikipedia.org/w/index.php?title=%E5%BF%AB%E9%80%9F%E5%8E%9F%E5%9E%8B&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>快速原型</font></u></a>(rapid prototyping)，医疗测试，和科学研究的<a class=new title=可视化 href="http://zh.wikipedia.org/w/index.php?title=%E5%8F%AF%E8%A7%86%E5%8C%96&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>可视化</font></u></a>(visualization)。</p>
<table class=toc id=toc summary=目录>
    <tbody>
        <tr>
            <td>
            <div id=toctitle>
            <h2>目录</h2>
            </div>
            <ul>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.9F.BA.E6.9C.AC.E6.A6.82.E5.BF.B5"><font color=#800080><u><span class=tocnumber>1</span><span class=toctext>基本概念</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.AE.9E.E4.BD.93.E9.80.A0.E5.9E.8B_CAD"><font color=#800080><u><span class=tocnumber>2</span><span class=toctext>实体造型 CAD</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.8F.82.E6.95.B0.E5.8C.96.E5.AE.9E.E4.BD.93.E9.80.A0.E5.9E.8B_parametric_solid_modelling"><font color=#800080><u><span class=tocnumber>3</span><span class=toctext>参数化实体造型 parametric solid modelling</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.8C.BB.E7.94.A8.E5.AE.9E.E4.BD.93.E9.80.A0.E5.9E.8B"><font color=#800080><u><span class=tocnumber>4</span><span class=toctext>医用实体造型</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.8F.A6.E8.A7.81"><font color=#800080><u><span class=tocnumber>5</span><span class=toctext>另见</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.A4.96.E9.83.A8.E9.93.BE.E6.8E.A5"><font color=#800080><u><span class=tocnumber>6</span><span class=toctext>外部链接</span></u></font></a>
                <ul>
                    <li class=toclevel-2><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.95.86.E4.B8.9A.E5.AE.9E.E4.BD.93.E9.80.A0.E5.9E.8B.E7.B3.BB.E7.BB.9F"><font color=#800080><u><span class=tocnumber>6.1</span><span class=toctext>商业实体造型系统</span></u></font></a></li>
                    <li class=toclevel-2><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.85.8D.E8.B4.B9.E5.AE.9E.E4.BD.93.E9.80.A0.E5.9E.8B.E7.B3.BB.E7.BB.9F"><u><font color=#800080><span class=tocnumber>6.2</span><span class=toctext>免费实体造型系统</span></font></u></a></li>
                </ul>
                </li>
            </ul>
            </td>
        </tr>
    </tbody>
</table>
<p><a name=.E5.9F.BA.E6.9C.AC.E6.A6.82.E5.BF.B5><u><font color=#800080></font></u></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%AE%9E%E4%BD%93%E9%80%A0%E5%9E%8B&amp;action=edit&amp;section=1" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>基本概念</span></h2>
<ul>
    <li><strong>扫掠(Sweeping)</strong>
    <ul>
        <li>把一个元素沿着一条路径"扫出"的一个立体特征叫做面特征。这些体积要么加到物体上("拉伸(extrusion)")要么切除材料("切割路径(cutter path)").</li>
        <li>也叫做'基于草图的造型(sketcher based modelling)'.</li>
        <li>和各种制造技术类似，例如<a class=new title=挤压 href="http://zh.wikipedia.org/w/index.php?title=%E6%8C%A4%E5%8E%8B&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>挤压</font></u></a>(extrusion),<a class=new title=铣 href="http://zh.wikipedia.org/w/index.php?title=%E9%93%A3&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>铣</font></u></a>(milling),<a class=new title=车削 href="http://zh.wikipedia.org/w/index.php?title=%E8%BD%A6%E5%89%8A&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>车削</font></u></a>(lathe)等等。</li>
    </ul>
    </li>
</ul>
<ul>
    <li><strong>边界表示(Boundary representation)</strong>
    <ul>
        <li>一个立体可以用其边界表面表达，然后填充成为实体.</li>
        <li>也成为'曲面造型surfacing'。</li>
        <li>和各种制造技术类似；<a class=new title=注模 href="http://zh.wikipedia.org/w/index.php?title=%E6%B3%A8%E6%A8%A1&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>注模</font></u></a>(Injection moulding),<a title=鑄造 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E9%91%84%E9%80%A0'))"><u><font color=#0000ff>铸造</font></u></a>(casting)，锻造(forging)，<a class=new title=热塑加工 href="http://zh.wikipedia.org/w/index.php?title=%E7%83%AD%E5%A1%91%E5%8A%A0%E5%B7%A5&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>热塑加工</font></u></a>(thermoforming)，等等。</li>
    </ul>
    </li>
</ul>
<p><br></p>
<ul>
    <li><strong>参数化体素(也称基元)实例化Parameterized primitive instancing.</strong>
    <ul>
        <li>从一个参数化的<strong>体素</strong>库中挑出并指定参数得到一个物体</li>
        <li>例如，螺栓在库中有一个模型，通过修改它的参数集合这个模型可以用于所有螺栓的尺寸</li>
    </ul>
    </li>
</ul>
<p><br></p>
<ul>
    <li><strong>空间占领(Spatial occupancy,或空间枚举)</strong>
    <ul>
        <li>整个空间子分成规则<strong>块(cell，或细胞，胞腔)</strong>，物体通过指定它占据了那些块来表示。</li>
        <li>这样表示的物体可用于<a class=new title=有限差 href="http://zh.wikipedia.org/w/index.php?title=%E6%9C%89%E9%99%90%E5%B7%AE&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>有限差</font></u></a>分析</li>
        <li>这通常是在模型完成之后作的，作为分析软件的预处理的一部分。</li>
    </ul>
    </li>
</ul>
<ul>
    <li><strong>分解Decomposition</strong>
    <ul>
        <li>和"空间占据"类似，但是块可以不规则，也不用"预编织".</li>
        <li>这样表示的模型可以用于<a title=有限元分析 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%9C%89%E9%99%90%E5%85%83%E5%88%86%E6%9E%90'))"><u><font color=#0000ff>有限元分析</font></u></a></li>
        <li>这通常是在模型完成之后作的，作为分析软件的预处理的一部分。</li>
    </ul>
    </li>
</ul>
<ul>
    <li><strong><a title=构造实体几何 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%9E%84%E9%80%A0%E5%AE%9E%E4%BD%93%E5%87%A0%E4%BD%95'))"><u><font color=#0000ff>构造实体几何</font></u></a>(Constructive solid geometry).</strong>
    <ul>
        <li>用象并，差，交这样的布尔操作把简单的物体组合起来，通常有树形的等级结构(组合体可以再组合)。</li>
    </ul>
    </li>
</ul>
<ul>
    <li><strong>基于特征的造型(Feature based modelling)</strong>
    <ul>
        <li>物体和操作的复杂组合可以作为一个单元一起修改和复制</li>
        <li>操作的顺序存储在一個樹狀結構(boolean tree or feature tree)中，参数的改变可以在树中传播(propagate)。</li>
    </ul>
    </li>
</ul>
<ul>
    <li><strong>参数化造型(Parameteric modelling)</strong>
    <ul>
        <li>特征的属性被参数化，并给予标签(变量名)而不仅是固定的数字尺寸，整个模型的参数间的关系也记录下来，使得参数值的改变变得更简单。</li>
        <li>几乎总是和特征联合使用，称为<a class=new title=基于特征的参数化造型系统 href="http://zh.wikipedia.org/w/index.php?title=%E5%9F%BA%E4%BA%8E%E7%89%B9%E5%BE%81%E7%9A%84%E5%8F%82%E6%95%B0%E5%8C%96%E9%80%A0%E5%9E%8B%E7%B3%BB%E7%BB%9F&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>基于特征的参数化造型系统</font></u></a>。</li>
    </ul>
    </li>
</ul>
<p><a name=.E5.AE.9E.E4.BD.93.E9.80.A0.E5.9E.8B_CAD></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%AE%9E%E4%BD%93%E9%80%A0%E5%9E%8B&amp;action=edit&amp;section=2" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>实体造型 CAD</span></h2>
<p>因为PC的高速发展和有竞争力的软件价格，实体造型系统在过去十年中成了工程专业的常识课。它们是机器设计者的重要工具。</p>
<p>实体造型软件为机器设计和分析创造了一个<a title=虚拟现实 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%99%9A%E6%8B%9F%E7%8E%B0%E5%AE%9E'))"><u><font color=#0000ff>虚拟现实</font></u></a>。和操作者的界面得到了高度优化，包括可编的宏命令，键盘快捷键和动态模型操作。动态转动模型，实时三维明暗图的功能得到了强调，以帮助设计者维持思考中的三维影像。</p>
<p>设计者通常可以在其他人也在同时工作的时候对模型进行处理。例如，几个人同时设计一台有很多零件的机器。新零件创建后加入到装配模型。每个设计者都可以处理装配模型，并一边工作和加工他们自己的零件。整个设计的演变对所有参与者都是可见的。</p>
<p>一个实体模型通常由一组特征组成，一个一个加上去，直到模型完成。工程实体模型通常主要由基于草图的特征组成；二维草图沿着路径扫掠形成三维特征。这些可以是切割，也可以是拉伸等等。</p>
<p>另一类建模技术是'曲面造型'。其中，先定义曲面，然后裁剪，合并，最后填充成为实体。曲面通常由空间中的数据曲线和很多不同的复杂指令定义。曲面造型更困难，但是对于注模之类的制造技术应用起来更好。注模零件的实体模型通常既有曲面造型也有基于草图的特征。</p>
<p>另一个曲面造型很有优势的例子是车身面板。如果两块面板有不同的曲率半径，并融合在一起，保持切向连续性(意思是融合的表面方向不会突然改变只会光滑的改变)是不够的。在两块区域之间必须有连续的曲率变化率，否则他们的反射看起来会断开。</p>
<p><a class=new title=工程图纸 href="http://zh.wikipedia.org/w/index.php?title=%E5%B7%A5%E7%A8%8B%E5%9B%BE%E7%BA%B8&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>工程图纸</font></u></a>是通过索引实体模型半自动的创建的。</p>
<p>这些软件包的学习曲线很陡，但是能够掌握这些软件的熟练机械设计者会有很高的效率。</p>
<p>实体造型软件(至少)必须做到以下这些:</p>
<ul>
    <li>对实体零件建模</li>
    <li>对零件的装配建模</li>
    <li>维护零件和装配件的库</li>
    <li>计算零件和装配件的质量属性</li>
    <li>反映建造零件所需的'材料表'</li>
    <li>从实体模型建立<a class=new title=工程图纸 href="http://zh.wikipedia.org/w/index.php?title=%E5%B7%A5%E7%A8%8B%E5%9B%BE%E7%BA%B8&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>工程图纸</font></u></a></li>
    <li>通过明暗图，转动，隐藏线消除等技术帮助更好的显示模型</li>
</ul>
<p>多数现代的软件包还包括附加的功能:</p>
<ul>
    <li>双向参数关联(任何特征的改变会反映在所有和该特征有关的信息中:图纸，质量属性，装配，等等，反过来也是一样)</li>
    <li>装配件的运动，碰撞，和间隙检测。</li>
    <li>专门的附加模块(<a title=有限元分析 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%9C%89%E9%99%90%E5%85%83%E5%88%86%E6%9E%90'))"><u><font color=#0000ff>有限元分析</font></u></a>，钣金，曲面造型，管/缆布线，电子部件封装...)</li>
    <li>控制文档和改版级别的管理</li>
    <li>模型中包含可编程代码以控制和关联模型的相关属性</li>
    <li>数控机床的自动编程</li>
    <li>真实感绘制</li>
    <li>和其他软件包交换数据用的引入/导出程序</li>
    <li>可编程的设计学习和优化</li>
    <li>自动壳特征创建</li>
    <li>自动轴特征创建</li>
    <li>高级的视觉分析程序，用于轴，曲率，曲率连续性...</li>
</ul>
<p><a name=.E5.8F.82.E6.95.B0.E5.8C.96.E5.AE.9E.E4.BD.93.E9.80.A0.E5.9E.8B_parametric_solid_modelling></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%AE%9E%E4%BD%93%E9%80%A0%E5%9E%8B&amp;action=edit&amp;section=3" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>参数化实体造型 parametric solid modelling</span></h2>
<p>三维CAD的一场革命始于1989年，当时第一个参数化造型系统<a class=new title=T-FLEX href="http://zh.wikipedia.org/w/index.php?title=T-FLEX&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>T-FLEX</font></u></a>在PC上发布了。<a class=new title=Pro/ENGINEER href="http://zh.wikipedia.org/w/index.php?title=Pro/ENGINEER&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Pro/ENGINEER</font></u></a>也于同年发行。现在大部分实体造型系统都是参数化的。</p>
<p>参数化造型用参数来定义模型(例如尺寸)。参数可以以后修改，模型会更新以反映所作的改动。</p>
<p>例子:一个轴通过拉伸一个圆100mm产生。一个毂装配在其尾端。后来，轴改成200mm长(点击轴，选择长度尺寸，改为200mm)。当模型更新的时候轴变成200mm长，毂会重新定位到它所装配到的那个尾端，工程图纸和质量属性会自动反映所有的变化。</p>
<p>参数的例子有：用于创建模型特征的尺寸，材料密度，描述扫掠特征的公式，引入的数据(例如，描述参照曲面的数据)。</p>
<p>参数化造型和明显也很直观。但是CAD的头三十年却不是这样的。修改就意味着重化，或者在旧模型的上面增加新的切割或伸展。工程图纸上的尺寸不是根据模型<em>显示</em>,而是直接<em>造</em>出来的。</p>
<p>参数化造型功能强大，但是模型建造过程需要相当的技巧。为一个<a class=new title=注模 href="http://zh.wikipedia.org/w/index.php?title=%E6%B3%A8%E6%A8%A1&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>注模</font></u></a>零件制作的复杂模型可能包含上千个特征，修改早先建立的特征可能导致后续特征创建失败。有技巧的创建的参数化模型更易于维护和修改。</p>
<p>参数化模型易于数据重用。譬如一整族的带头螺钉可以从一个模型得到。</p>
<p>计算机产生的人物的动画是参数化造型的一个例子。<a title=佳佳 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E4%BD%B3%E4%BD%B3'))"><u><font color=#0000ff>佳佳</font></u></a>(Jar Jar Binks,星战人物)用一组定位关键肢体位置的参数描述。模型从这些位置开始建造。对每一<a class=new title=帧 href="http://zh.wikipedia.org/w/index.php?title=%E5%B8%A7&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>帧</font></u></a>进行参数修改和模型重建就得到了<a title=动画 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%8A%A8%E7%94%BB'))"><u><font color=#0000ff>动画</font></u></a>。</p>
<p><a name=.E5.8C.BB.E7.94.A8.E5.AE.9E.E4.BD.93.E9.80.A0.E5.9E.8B></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%AE%9E%E4%BD%93%E9%80%A0%E5%9E%8B&amp;action=edit&amp;section=4" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>医用实体造型</span></h2>
<p>现代<a title=CT href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/CT'))"><u><font color=#0000ff>计算机断层摄影</font></u></a>(俗称CT)和<a title=核磁共振 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%A0%B8%E7%A3%81%E5%85%B1%E6%8C%AF'))"><u><font color=#0000ff>核磁共振</font></u></a>扫描仪可以为体内特征构造实体模型</p>
<p>医学实体造型的用途:</p>
<ul>
    <li>可视化</li>
    <li>特殊组织的可视化(譬如血管和肿瘤)</li>
    <li>为<a class=new title=快速原型 href="http://zh.wikipedia.org/w/index.php?title=%E5%BF%AB%E9%80%9F%E5%8E%9F%E5%9E%8B&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>快速原型</font></u></a>提供实体模型数据(例如，用以辅助外科医生准备困难的手术).</li>
    <li>把医学实体模型和<a title=计算机辅助设计 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%AE%A1%E7%AE%97%E6%9C%BA%E8%BE%85%E5%8A%A9%E8%AE%BE%E8%AE%A1'))"><u><font color=#0000ff>计算机辅助设计</font></u></a>实体模型结合起来(例如，用于设计髋关节替代部件)</li>
</ul>
<p><a name=.E5.8F.A6.E8.A7.81></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%AE%9E%E4%BD%93%E9%80%A0%E5%9E%8B&amp;action=edit&amp;section=5" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>另见</span></h2>
<ul>
    <li><a title=计算机图形学 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9B%BE%E5%BD%A2%E5%AD%A6'))"><font color=#0000ff><u>计算机图形学</u></font></a></li>
    <li><a title=计算几何 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%AE%A1%E7%AE%97%E5%87%A0%E4%BD%95'))"><u><font color=#0000ff>计算几何</font></u></a></li>
    <li>欧拉<a title=边界表示 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%BE%B9%E7%95%8C%E8%A1%A8%E7%A4%BA'))"><font color=#0000ff><u>边界表示</u></font></a></li>
    <li><a class=new title=工程图纸 href="http://zh.wikipedia.org/w/index.php?title=%E5%B7%A5%E7%A8%8B%E5%9B%BE%E7%BA%B8&amp;action=edit" target=_blank><font color=#0000ff><u><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">工程图纸</u></font></a></li>
    <li><a class=new title=草图 href="http://zh.wikipedia.org/w/index.php?title=%E8%8D%89%E5%9B%BE&amp;action=edit" target=_blank><font color=#0000ff><u><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">草图</u></font></a></li>
    <li><a class=new title=Inventor href="http://zh.wikipedia.org/w/index.php?title=Inventor&amp;action=edit" target=_blank><font color=#0000ff><u><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Inventor</u></font></a></li>
    <li><a class=new title=Alibre href="http://zh.wikipedia.org/w/index.php?title=Alibre&amp;action=edit" target=_blank><font color=#0000ff><u><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Alibre</u></font></a></li>
    <li><a class=new title=SolidWorks href="http://zh.wikipedia.org/w/index.php?title=SolidWorks&amp;action=edit" target=_blank><font color=#0000ff><u><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">SolidWorks</u></font></a></li>
    <li><a class=new title="Solid Edge" href="http://zh.wikipedia.org/w/index.php?title=Solid_Edge&amp;action=edit" target=_blank><font color=#0000ff><u><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Solid Edge</u></font></a></li>
    <li><a class=new title=Pro/ENGINEER href="http://zh.wikipedia.org/w/index.php?title=Pro/ENGINEER&amp;action=edit" target=_blank><font color=#0000ff><u><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Pro/ENGINEER</u></font></a></li>
    <li><a class=new title=BRL-CAD href="http://zh.wikipedia.org/w/index.php?title=BRL-CAD&amp;action=edit" target=_blank><font color=#0000ff><u><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">BRL-CAD</u></font></a></li>
    <li><a class=new title=I-DEAS href="http://zh.wikipedia.org/w/index.php?title=I-DEAS&amp;action=edit" target=_blank><font color=#0000ff><u><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">I-DEAS</u></font></a></li>
    <li><a class=new title=CATIA href="http://zh.wikipedia.org/w/index.php?title=CATIA&amp;action=edit" target=_blank><font color=#0000ff><u><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">CATIA</u></font></a></li>
    <li><a title=AutoCAD href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/AutoCAD'))"><font color=#0000ff><u>AutoCAD</u></font></a></li>
    <li><a class=new title=Solid3000 href="http://zh.wikipedia.org/w/index.php?title=Solid3000&amp;action=edit" target=_blank><u><font color=#0000ff><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Solid3000</font></u></a></li>
</ul>
<p><a name=.E5.A4.96.E9.83.A8.E9.93.BE.E6.8E.A5><u><font color=#0000ff></font></u></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%AE%9E%E4%BD%93%E9%80%A0%E5%9E%8B&amp;action=edit&amp;section=6" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>外部链接</span></h2>
<p><a name=.E5.95.86.E4.B8.9A.E5.AE.9E.E4.BD.93.E9.80.A0.E5.9E.8B.E7.B3.BB.E7.BB.9F></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%AE%9E%E4%BD%93%E9%80%A0%E5%9E%8B&amp;action=edit&amp;section=7" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>商业实体造型系统</span></h3>
<ul>
    <li><a class="external text" title=http://www.alibre.com/ href="http://www.alibre.com/" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><font color=#0000ff><u>Alibre</u></font></a></li>
    <li><a class="external text" title=http://usa.autodesk.com/ href="http://usa.autodesk.com/" target=_blank rel=nofollow><font color=#0000ff><u><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">AutoCAD</u></font></a></li>
    <li><a class="external text" title=http://usa.autodesk.com/ href="http://usa.autodesk.com/" target=_blank rel=nofollow><u><font color=#0000ff><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Inventor</font></u></a></li>
    <li>Euclid-IS</li>
    <li><a class="external text" title=http://www.ptc.com href="http://www.ptc.com/" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><font color=#0000ff><u>Pro/ENGINEER</u></font></a></li>
    <li><a class="external text" title=http://www.catia.ibm.com href="http://www.catia.ibm.com/" target=_blank rel=nofollow><font color=#0000ff><u><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Catia</u></font></a></li>
    <li><a class="external text" title=http://www.unigraphics.com href="http://www.unigraphics.com/" target=_blank rel=nofollow><font color=#0000ff><u><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Unigraphics</u></font></a></li>
    <li><a class="external text" title=http://www.solidedge.com href="http://www.solidedge.com/" target=_blank rel=nofollow><font color=#0000ff><u><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Solid Edge</u></font></a></li>
    <li><a class="external text" title=http://www.solidworks.com href="http://www.solidworks.com/" target=_blank rel=nofollow><font color=#0000ff><u><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Solid Works</u></font></a></li>
    <li><a class="external text" title=http://www.a3ds.com href="http://www.a3ds.com/" target=_blank rel=nofollow><font color=#0000ff><u><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">ParaLogix</u></font></a></li>
    <li><a class="external text" title=http://www.tekla.com href="http://www.tekla.com/" target=_blank rel=nofollow><font color=#0000ff><u><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Tekla Structures</u></font></a></li>
    <li><a class="external text" title=http://www.smlib.com/ href="http://www.smlib.com/" target=_blank rel=nofollow><font color=#0000ff><u><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">SMLib</u></font></a></li>
    <li><a class="external text" title=http://www.kubotekusa.com/ href="http://www.kubotekusa.com/" target=_blank rel=nofollow><font color=#0000ff><u><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">KeyCreator</u></font></a></li>
    <li><a class="external text" title=http://www.opencascade.com/ href="http://www.opencascade.com/" target=_blank rel=nofollow><font color=#0000ff><u><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">OpenCascade</u></font></a></li>
    <li><a class="external text" title=http://www.spatial.com/ href="http://www.spatial.com/" target=_blank rel=nofollow><u><font color=#0000ff><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Spatial\'s (SAT format)</font></u></a></li>
</ul>
<p><a name=.E5.85.8D.E8.B4.B9.E5.AE.9E.E4.BD.93.E9.80.A0.E5.9E.8B.E7.B3.BB.E7.BB.9F><u><font color=#0000ff></font></u></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%AE%9E%E4%BD%93%E9%80%A0%E5%9E%8B&amp;action=edit&amp;section=8" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>免费实体造型系统</span></h3>
<ul>
    <li><a class="external text" title=http://brlcad.org/ href="http://brlcad.org/" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>BRL-CAD</font></u></a></li>
</ul>
</div>
<img src ="http://www.cppblog.com/yaoming/aggbug/40137.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/yaoming/" target="_blank">姚明</a> 2008-01-01 08:42 <a href="http://www.cppblog.com/yaoming/archive/2008/01/01/40137.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>扫描线渲染</title><link>http://www.cppblog.com/yaoming/archive/2008/01/01/40136.html</link><dc:creator>姚明</dc:creator><author>姚明</author><pubDate>Tue, 01 Jan 2008 00:41:00 GMT</pubDate><guid>http://www.cppblog.com/yaoming/archive/2008/01/01/40136.html</guid><wfw:comment>http://www.cppblog.com/yaoming/comments/40136.html</wfw:comment><comments>http://www.cppblog.com/yaoming/archive/2008/01/01/40136.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/yaoming/comments/commentRss/40136.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/yaoming/services/trackbacks/40136.html</trackback:ping><description><![CDATA[<h1 class=firstHeading>扫描线渲染</h1>
<div id=bodyContent>
<h3 id=siteSub>&nbsp;</h3>
<div id=contentSub></div>
<p><strong>扫描线渲染</strong>是一行一行、而不是根据多边形到多边形或者点到点方式渲染的一项技术和<a title=算法 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%AE%97%E6%B3%95'))"><u><font color=#0000ff>算法</font></u></a>集。所有待渲染的多边形首先按照顶点 y 坐标出现的顺序排序，然后使用扫描线与列表中前面多边形的交点计算图像的每行或者每条扫描线，在活动扫描线逐步沿图像向下计算的时候更新列表丢弃不可见的多边形。</p>
<p>这种方法的一个优点就是没有必要将主内存中的所有<a title=顶点 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E9%A1%B6%E7%82%B9'))"><u><font color=#0000ff>顶点</font></u></a>都转到工作内存，只有与当前扫描线相交边界的约束顶点才需要读到工作内存，并且每个定点数据只需读取一次。主内存的速度通常远远低于中央处理单元或者<a title=高速缓存 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E9%AB%98%E9%80%9F%E7%BC%93%E5%AD%98'))"><u><font color=#0000ff>高速缓存</font></u></a>，避免多次访问主内存中的顶点数据就可以大幅度地提升运算速度。</p>
<p>这类算法可以很容易地与 <a class=new title="Phong reflection model" href="http://zh.wikipedia.org/w/index.php?title=Phong_reflection_model&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Phong reflection model</font></u></a>、<a class=new title=Z-buffer href="http://zh.wikipedia.org/w/index.php?title=Z-buffer&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Z-buffer</font></u></a> 算法以及其它图形技术集成到一起。</p>
<table class=toc id=toc summary=目录>
    <tbody>
        <tr>
            <td>
            <div id=toctitle>
            <h2>目录</h2>
            </div>
            <ul>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.8E.86.E5.8F.B2"><font color=#800080><u><span class=tocnumber>1</span><span class=toctext>历史</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.8F.82.E8.80.83.E6.96.87.E7.8C.AE"><font color=#800080><u><span class=tocnumber>2</span><span class=toctext>参考文献</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.A4.96.E9.83.A8.E9.93.BE.E6.8E.A5"><font color=#800080><u><span class=tocnumber>3</span><span class=toctext>外部链接</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.8F.82.E8.A7.81"><u><font color=#800080><span class=tocnumber>4</span><span class=toctext>参见</span></font></u></a></li>
            </ul>
            </td>
        </tr>
    </tbody>
</table>
<p><a name=.E5.8E.86.E5.8F.B2><u><font color=#800080></font></u></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%89%AB%E6%8F%8F%E7%BA%BF%E6%B8%B2%E6%9F%93&amp;action=edit&amp;section=1" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>历史</span></h2>
<p>扫描线渲染技术的首次公开发表是 1967 年 Wylie、Romney、Evans 以及 Erdahl 完成的。<sup class=reference id=_ref-0><a title="" href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#_note-0"><u><font color=#800080>[1]</font></u></a></sup></p>
<p>其它一些扫描线渲染的方法分别是由 Bouknight 于 1969 年 <sup class=reference id=_ref-1><a title="" href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#_note-1"><u><font color=#800080>[2]</font></u></a></sup> 以及 Newell、Newell 与 Sancha 于 1972 年开发的。<sup class=reference id=_ref-2><a title="" href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#_note-2"><u><font color=#800080>[3]</font></u></a></sup> 许多这方面的早期研究工作都是由<a title=犹他大学 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%8A%B9%E4%BB%96%E5%A4%A7%E5%AD%A6'))"><u><font color=#0000ff>犹他大学</font></u></a>的 <a class=new title="Ivan Sutherland" href="http://zh.wikipedia.org/w/index.php?title=Ivan_Sutherland&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Ivan Sutherland</font></u></a> 图形研究组以及位于<a title=犹他州 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%8A%B9%E4%BB%96%E5%B7%9E'))"><u><font color=#0000ff>犹他州</font></u></a><a title=盐湖城 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%9B%90%E6%B9%96%E5%9F%8E'))"><u><font color=#0000ff>盐湖城</font></u></a>的 <a class=new title="Evans &amp; Sutherland" href="http://zh.wikipedia.org/w/index.php?title=Evans_%26_Sutherland&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Evans &amp; Sutherland</font></u></a> 公司完成的。</p>
<p><a name=.E5.8F.82.E8.80.83.E6.96.87.E7.8C.AE></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%89%AB%E6%8F%8F%E7%BA%BF%E6%B8%B2%E6%9F%93&amp;action=edit&amp;section=2" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>参考文献</span></h2>
<ol class=references>
    <li id=_note-0><a title="" href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#_ref-0"><u><font color=#800080>&#8593;</font></u></a> Wylie, C, Romney, G W, Evans, D C, and Erdahl, A, "Halftone Perspective Drawings by Computer," Proc. AFIPS FJCC 1967, Vol. 31, 49</li>
    <li id=_note-1><a title="" href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#_ref-1"><u><font color=#800080>&#8593;</font></u></a> Bouknight W.J, "An Improved Procedure for Generation of Half-tone Computer Graphics Representation," UI, Coordinated Science Laboratory, Sept 1969</li>
    <li id=_note-2><a title="" href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#_ref-2"><u><font color=#800080>&#8593;</font></u></a> Newell, M E, Newell R. G, and Sancha, T.L, "A New Approach to the Shaded Picture Problem," Proc ACM National Conf. 1972</li>
</ol>
<p><a name=.E5.A4.96.E9.83.A8.E9.93.BE.E6.8E.A5></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%89%AB%E6%8F%8F%E7%BA%BF%E6%B8%B2%E6%9F%93&amp;action=edit&amp;section=3" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>外部链接</span></h2>
<ul>
    <li><a class="external text" title=http://accad.osu.edu/~waynec/history/tree/utah.html href="http://accad.osu.edu/%7Ewaynec/history/tree/utah.html" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>University of Utah Graphics Group History</font></u></a></li>
</ul>
<p><a name=.E5.8F.82.E8.A7.81><u><font color=#0000ff></font></u></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%89%AB%E6%8F%8F%E7%BA%BF%E6%B8%B2%E6%9F%93&amp;action=edit&amp;section=4" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>参见</span></h2>
<ul>
    <li><a class=new title=扫描线 href="http://zh.wikipedia.org/w/index.php?title=%E6%89%AB%E6%8F%8F%E7%BA%BF&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><font color=#0000ff><u>扫描线</u></font></a></li>
    <li><a title=像素 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%83%8F%E7%B4%A0'))"><font color=#0000ff><u>像素</u></font></a></li>
    <li><a class=new title="Raster scan" href="http://zh.wikipedia.org/w/index.php?title=Raster_scan&amp;action=edit" target=_blank><u><font color=#0000ff><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Raster scan</font></u></a></li>
</ul>
</div>
<img src ="http://www.cppblog.com/yaoming/aggbug/40136.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/yaoming/" target="_blank">姚明</a> 2008-01-01 08:41 <a href="http://www.cppblog.com/yaoming/archive/2008/01/01/40136.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>构造实体几何</title><link>http://www.cppblog.com/yaoming/archive/2008/01/01/40135.html</link><dc:creator>姚明</dc:creator><author>姚明</author><pubDate>Tue, 01 Jan 2008 00:39:00 GMT</pubDate><guid>http://www.cppblog.com/yaoming/archive/2008/01/01/40135.html</guid><wfw:comment>http://www.cppblog.com/yaoming/comments/40135.html</wfw:comment><comments>http://www.cppblog.com/yaoming/archive/2008/01/01/40135.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cppblog.com/yaoming/comments/commentRss/40135.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/yaoming/services/trackbacks/40135.html</trackback:ping><description><![CDATA[<h1 class=firstHeading>构造实体几何</h1>
<div id=bodyContent>
<h3 id=siteSub>&nbsp;</h3>
<div id=contentSub></div>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 182px"><a class=new title="Image:Tron Lightcycles.jpg" href="javascript:void(wb.w._link('http://zh.wikipedia.org/w/index.php?title=Special:Upload&amp;wpDestFile=Tron_Lightcycles.jpg'))"><u><font color=#0000ff>Image:Tron Lightcycles.jpg</font></u></a>
<div class=thumbcaption>电影 <em><a class=new title="Tron (film)" href="http://zh.wikipedia.org/w/index.php?title=Tron_%28film%29&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Tron</font></u></a></em> 中的光环就是用构造实体几何生成的</div>
</div>
</div>
<p><strong>构造实体几何</strong>（英文为 Constructive solid geometry，缩写为 CSG）是<a title=实体造型 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%AE%9E%E4%BD%93%E9%80%A0%E5%9E%8B'))"><u><font color=#0000ff>实体造型</font></u></a>中应用的一项技术。CSG 是 <a title=三维计算机图形学 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E4%B8%89%E7%BB%B4%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9B%BE%E5%BD%A2%E5%AD%A6'))"><u><font color=#800080>三维计算机图形学</font></u></a>与<a title=CAD href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/CAD'))"><u><font color=#0000ff>CAD</font></u></a>中经常使用的一个程序化建模技术。在构造实体几何中，建模人员可以使用<a title=逻辑运算符 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E9%80%BB%E8%BE%91%E8%BF%90%E7%AE%97%E7%AC%A6'))"><u><font color=#0000ff>逻辑运算符</font></u></a>将不同物体组合成复杂的曲面或者物体。通常 CSG 都是表示看起来非常复杂的模型或者曲面，但是它们通常都是由非常简单的物体组合形成的。在有些场合中，构造实体几何只在<a title=多边形网格 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%A4%9A%E8%BE%B9%E5%BD%A2%E7%BD%91%E6%A0%BC'))"><u><font color=#0000ff>多边形网格</font></u></a>上进行处理，因此可能并不是程序化的或者参数化的。</p>
<p>最简单的实体表示叫作<strong>体元</strong>，通常是形状简单的物体，如<a title=立方体 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%AB%8B%E6%96%B9%E4%BD%93'))"><u><font color=#0000ff>立方体</font></u></a>、<a title=圆柱体 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%9C%86%E6%9F%B1%E4%BD%93'))"><u><font color=#0000ff>圆柱体</font></u></a>、<a class=new title=棱柱 href="http://zh.wikipedia.org/w/index.php?title=%E6%A3%B1%E6%9F%B1&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>棱柱</font></u></a>、<a title=棱锥 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%A3%B1%E9%94%A5'))"><u><font color=#0000ff>棱锥</font></u></a>、<a title=球体 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%90%83%E4%BD%93'))"><u><font color=#0000ff>球体</font></u></a>、<a title=圆锥 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%9C%86%E9%94%A5'))"><u><font color=#0000ff>圆锥</font></u></a>等。根据每个软件包的不同这些体元也有所不同，在一些软件包中可以使用弯曲的物体进行 CSG 处理，在另外一些软件包中则不支持这些功能。</p>
<p><strong>构造</strong>物体就是将体元根据<a title=集合论 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E9%9B%86%E5%90%88%E8%AE%BA'))"><u><font color=#0000ff>集合论</font></u></a>的<a title=布尔逻辑 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%B8%83%E5%B0%94%E9%80%BB%E8%BE%91'))"><u><font color=#0000ff>布尔逻辑</font></u></a>组合在一起，这些运算包括：<a title=并集 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%B9%B6%E9%9B%86'))"><u><font color=#0000ff>并集</font></u></a>、<a title=交集 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E4%BA%A4%E9%9B%86'))"><u><font color=#0000ff>交集</font></u></a>以及<a title=补集 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%A1%A5%E9%9B%86'))"><u><font color=#0000ff>补集</font></u></a>。</p>
<table class=toc id=toc summary=目录>
    <tbody>
        <tr>
            <td>
            <div id=toctitle>
            <h2>目录</h2>
            </div>
            <ul>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E8.BF.90.E7.AE.97"><font color=#800080><u><span class=tocnumber>1</span><span class=toctext>运算</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E6.9E.84.E9.80.A0.E5.AE.9E.E4.BD.93.E5.87.A0.E4.BD.95.E7.9A.84.E5.BA.94.E7.94.A8"><font color=#800080><u><span class=tocnumber>2</span><span class=toctext>构造实体几何的应用</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E7.A4.BA.E4.BE.8B.E7.A8.8B.E5.BA.8F"><font color=#800080><u><span class=tocnumber>3</span><span class=toctext>示例程序</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.A4.96.E9.83.A8.E9.93.BE.E6.8E.A5"><u><font color=#800080><span class=tocnumber>4</span><span class=toctext>外部链接</span></font></u></a></li>
            </ul>
            </td>
        </tr>
    </tbody>
</table>
<p><a name=.E8.BF.90.E7.AE.97><u><font color=#800080></font></u></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%9E%84%E9%80%A0%E5%AE%9E%E4%BD%93%E5%87%A0%E4%BD%95&amp;action=edit&amp;section=1" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>运算</span></h2>
<p>在建模软件包中，如立方体、球体、环体以及其它基本几何体都可以用数学公式来表述，它们统称为<em>体元</em>。通常这些物体用可以输入<a class=new title=参数 href="http://zh.wikipedia.org/w/index.php?title=%E5%8F%82%E6%95%B0&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>参数</font></u></a>的程序来描述，例如球体可以用球心坐标及半径来表示。这些体元都可以经下面的操作组合成复杂的物体：</p>
<table cellSpacing=4 border=0>
    <caption><strong>构造实体几何中所用的运算</strong></caption>
    <tbody>
        <tr>
            <th width="30%">并集</th>
            <th width="30%">补集</th>
            <th width="30%">交集</th>
        </tr>
        <tr>
            <td><a class=image title=并集的例子 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Boolean_union.PNG'))"><img height=206 alt=并集的例子 src="http://upload.wikimedia.org/wikipedia/commons/thumb/4/4a/Boolean_union.PNG/275px-Boolean_union.PNG" width=275 border=0></a></td>
            <td><a class=image title=补集的例子 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Boolean_difference.PNG'))"><img height=206 alt=补集的例子 src="http://upload.wikimedia.org/wikipedia/commons/thumb/8/86/Boolean_difference.PNG/275px-Boolean_difference.PNG" width=275 border=0></a></td>
            <td><a class=image title=交集的例子 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Boolean_intersect.PNG'))"><img height=206 alt=交集的例子 src="http://upload.wikimedia.org/wikipedia/commons/thumb/0/0b/Boolean_intersect.PNG/275px-Boolean_intersect.PNG" width=275 border=0></a></td>
        </tr>
        <tr>
            <td>将两个物体组合成一个</td>
            <td>从一个物体中减去另一个</td>
            <td>两个物体共有的部分</td>
        </tr>
    </tbody>
</table>
<p><br></p>
<p><a name=.E6.9E.84.E9.80.A0.E5.AE.9E.E4.BD.93.E5.87.A0.E4.BD.95.E7.9A.84.E5.BA.94.E7.94.A8></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%9E%84%E9%80%A0%E5%AE%9E%E4%BD%93%E5%87%A0%E4%BD%95&amp;action=edit&amp;section=2" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>构造实体几何的应用</span></h2>
<p>构造实体几何有许多实际的应用，在需要简单几何物体的场合或者数学精度很关键的场合都有应用。 <a class=new title="Unreal engine" href="http://zh.wikipedia.org/w/index.php?title=Unreal_engine&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Unreal engine</font></u></a>、<a class=new title="Source engine" href="http://zh.wikipedia.org/w/index.php?title=Source_engine&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Source engine</font></u></a> 的映射引擎 <em><a class=new title="Valve Hammer Editor" href="http://zh.wikipedia.org/w/index.php?title=Valve_Hammer_Editor&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Hammer</font></u></a></em> 以及 <em><a title=Quake href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Quake'))"><u><font color=#0000ff>Quake</font></u></a></em> 都在使用这项技术。（Hammer 实际上最初来自于 Worldcraft，他是 Quake 的一位编辑。）<a class=new title=BRL-CAD href="http://zh.wikipedia.org/w/index.php?title=BRL-CAD&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>BRL-CAD</font></u></a> 是一个基于构造实体几何造型技术的<a title=实体造型 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%AE%9E%E4%BD%93%E9%80%A0%E5%9E%8B'))"><u><font color=#0000ff>实体造型</font></u></a><a title=CAD href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/CAD'))"><u><font color=#0000ff>CAD</font></u></a>软件包。由于可以用相对简单的物体来生成非常复杂的几何形状，因此构造实体几何得到了广泛的流行。如果构造实体几何是程序化的或者参数化的，那么用户可以通过修改物体的位置或者逻辑运算对复杂物体进行修改。</p>
<p><a name=.E7.A4.BA.E4.BE.8B.E7.A8.8B.E5.BA.8F></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%9E%84%E9%80%A0%E5%AE%9E%E4%BD%93%E5%87%A0%E4%BD%95&amp;action=edit&amp;section=3" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>示例程序</span></h2>
<ul>
    <li><a title=POV-Ray href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/POV-Ray'))"><u><font color=#0000ff>POV-Ray</font></u></a></li>
</ul>
<p><a name=.E5.A4.96.E9.83.A8.E9.93.BE.E6.8E.A5><u><font color=#0000ff></font></u></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%9E%84%E9%80%A0%E5%AE%9E%E4%BD%93%E5%87%A0%E4%BD%95&amp;action=edit&amp;section=4" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>外部链接</span></h2>
<ul>
    <li><a class="external text" title=http://gts.sourceforge.net/ href="http://gts.sourceforge.net/" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>GNU Triangulated Surface library</font></u></a> - 具有在三角形网格上进行构造实体几何处理能力的开放源代码（<a title=LGPL href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/LGPL'))"><u><font color=#0000ff>LGPL</font></u></a>）库</li>
    <li><a class="external text" title=http://www.cgal.org href="http://www.cgal.org/" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Computational Geometry Algorithms Library</font></u></a> - 有构造实体几何处理能力的开放源代码（<a title=LGPL href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/LGPL'))"><u><font color=#0000ff>LGPL</font></u></a>, <a class=new title="Q Public License" href="http://zh.wikipedia.org/w/index.php?title=Q_Public_License&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>QPL</font></u></a>）库</li>
</ul>
</div>
<img src ="http://www.cppblog.com/yaoming/aggbug/40135.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/yaoming/" target="_blank">姚明</a> 2008-01-01 08:39 <a href="http://www.cppblog.com/yaoming/archive/2008/01/01/40135.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>法向映射</title><link>http://www.cppblog.com/yaoming/archive/2008/01/01/40134.html</link><dc:creator>姚明</dc:creator><author>姚明</author><pubDate>Tue, 01 Jan 2008 00:37:00 GMT</pubDate><guid>http://www.cppblog.com/yaoming/archive/2008/01/01/40134.html</guid><wfw:comment>http://www.cppblog.com/yaoming/comments/40134.html</wfw:comment><comments>http://www.cppblog.com/yaoming/archive/2008/01/01/40134.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/yaoming/comments/commentRss/40134.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/yaoming/services/trackbacks/40134.html</trackback:ping><description><![CDATA[<h1 class=firstHeading>法向映射</h1>
<div id=bodyContent>
<h3 id=siteSub>&nbsp;</h3>
<div id=contentSub></div>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 182px"><a class=image title="Normal mapping used to re-detail simplified meshes." href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Normal_map_example.png'))"><img class=thumbimage height=101 alt="Normal mapping used to re-detail simplified meshes." src="http://upload.wikimedia.org/wikipedia/commons/thumb/3/36/Normal_map_example.png/180px-Normal_map_example.png" width=180 border=0></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=放大 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Normal_map_example.png'))"><img height=11 alt="" src="http://zh.wikipedia.org/skins-1.5/common/images/magnify-clip.png" width=15></a></div>
Normal mapping used to re-detail simplified meshes.</div>
</div>
</div>
<p>在<a title=三维计算机图形学 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E4%B8%89%E7%BB%B4%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9B%BE%E5%BD%A2%E5%AD%A6'))"><u><font color=#800080>三维计算机图形学</font></u></a>中，<strong>法向映射</strong>是<a title=凸凹纹理映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%87%B8%E5%87%B9%E7%BA%B9%E7%90%86%E6%98%A0%E5%B0%84'))"><u><font color=#0000ff>凸凹纹理映射</font></u></a>技术的一种应用，法向映射有时也称为&#8220;Dot3 凸凹纹理映射&#8221;。 凸凹与纹理映射通常是在现有的模型法向添加扰动不同，法向映射要完全更新法向。与凸凹纹理映射类似的是，它也是用来在不增加<a title=多边形 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%A4%9A%E8%BE%B9%E5%BD%A2'))"><u><font color=#0000ff>多边形</font></u></a>的情况下在<a class=new title=浓淡效果 href="http://zh.wikipedia.org/w/index.php?title=%E6%B5%93%E6%B7%A1%E6%95%88%E6%9E%9C&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>浓淡效果</font></u></a>中添加细节。但是凸凹纹理映射通常根据一个单独的<a title=灰度图像 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%81%B0%E5%BA%A6%E5%9B%BE%E5%83%8F'))"><u><font color=#0000ff>灰度图像</font></u></a>通道进行计算，而法向映射的数据源图像通常是从更加细致版本的物体得到的多通道图像，即红、绿、蓝通道都是作为一个单独的颜色对待。</p>
<p>法向映射通常有两个变体，即物体空间与 tangent-space 法向映射，它们的不同之处在于法向测量与储存所用坐标系统。</p>
<p>这项技术的一个有趣的应用是使用高分辨率模型的法向映射表大幅度地提高 <a class=new title="Low poly" href="http://zh.wikipedia.org/w/index.php?title=Low_poly&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>low poly</font></u></a> 模型的显示效果。尽管这种利用该分辨率模型细节创建<a title=位移映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E4%BD%8D%E7%A7%BB%E6%98%A0%E5%B0%84'))"><u><font color=#0000ff>位移映射</font></u></a>取代<a title=非均匀有理B样条 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E9%9D%9E%E5%9D%87%E5%8C%80%E6%9C%89%E7%90%86B%E6%A0%B7%E6%9D%A1'))"><u><font color=#0000ff>非均匀有理B样条</font></u></a>的方法早在 1996 年由 Krishnamurthy 与 Levoy 在 Proc. SIGGRAPH 1996 的文章&#8220;在密集多边形网格上使用光滑曲面&#8221;中已经提出，但是直到后来才开始用到更加普通的三角形网格。1998 年另外两篇论文提出了从高分辨率向低分辨率多边形网格转换细节作为法向映射的论文：Cohen et al. 在 SIGGRAPH 1998 的&#8220;保留外观的简化&#8221;以及Cignoni et al. IEEE Visualization '98 在&#8220;在简化的网格上恢复属性值的通用方法&#8221;。第一篇论文提出了一个特殊的约束简化算法，在化简过程中跟踪如何将丢失的细节映射到简化的网格。第二篇论文提出了分离高低精度多边形网格的简单方法，以及不受低精度模型构建方法影响的丢失细节恢复方法。后一种方法及其变体目前仍然是目前大多数可用工具使用的方法之一。</p>
<table class=toc id=toc summary=目录>
    <tbody>
        <tr>
            <td>
            <div id=toctitle>
            <h2>目录</h2>
            </div>
            <ul>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.B7.A5.E4.BD.9C.E5.8E.9F.E7.90.86"><font color=#800080><u><span class=tocnumber>1</span><span class=toctext>工作原理</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E6.B3.95.E5.90.91.E6.98.A0.E5.B0.84.E5.9C.A8.E8.AE.A1.E7.AE.97.E6.9C.BA.E5.A8.B1.E4.B9.90.E4.B8.AD.E7.9A.84.E5.BA.94.E7.94.A8"><font color=#800080><u><span class=tocnumber>2</span><span class=toctext>法向映射在计算机娱乐中的应用</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.8F.82.E8.80.83.E6.96.87.E7.8C.AE"><font color=#800080><u><span class=tocnumber>3</span><span class=toctext>参考文献</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.A4.96.E9.83.A8.E9.93.BE.E6.8E.A5"><font color=#800080><u><span class=tocnumber>4</span><span class=toctext>外部链接</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.8F.82.E8.80.83.E6.96.87.E7.8C.AE_2"><u><font color=#800080><span class=tocnumber>5</span><span class=toctext>参考文献</span></font></u></a></li>
            </ul>
            </td>
        </tr>
    </tbody>
</table>
<p><a name=.E5.B7.A5.E4.BD.9C.E5.8E.9F.E7.90.86><u><font color=#800080></font></u></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B3%95%E5%90%91%E6%98%A0%E5%B0%84&amp;action=edit&amp;section=1" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>工作原理</span></h2>
<p>为了计算表面光照的<a title=朗伯 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%9C%97%E4%BC%AF'))"><u><font color=#0000ff>朗伯</font></u></a>值，从浓淡点到光源的单位<a title=向量 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%90%91%E9%87%8F'))"><u><font color=#0000ff>向量</font></u></a>与表面法线单位向量做<a title=点积 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%82%B9%E7%A7%AF'))"><u><font color=#0000ff>点积</font></u></a>，得到的结果就是光线在表面上的强度。其它的照明模型也都涉及到与法向向量做点积。假设有一个球体的多边形模型只能近似表示曲面形状。通过在模型上应用<a title=RGB href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/RGB'))"><u><font color=#0000ff>RGB</font></u></a>位图纹理，就可以对更加细致的法线向量进行编码。位图中的每一个通道即红色、绿色、蓝色通道都对应于一个空间尺度 X、Y、Z，这些空间尺度与物体空间法向图的固定的坐标系统相关，或者与 tangenet 空间法向图场合中根据位置相对于纹理坐标平滑变化的坐标系统相关。这使得模型表面更加细致，尤其是与先进的光照技术一起使用的时候更是如此。</p>
<p>在 Valve Source 引擎及 nVidia 硬件卡等法向图最常见的实现中，当从右侧照射的时候红色通道是材料的 relief，当从下部照射的时候绿色是的 relief，当从正面照射的时候蓝色通道是材料的</p>
<p><a name=.E6.B3.95.E5.90.91.E6.98.A0.E5.B0.84.E5.9C.A8.E8.AE.A1.E7.AE.97.E6.9C.BA.E5.A8.B1.E4.B9.90.E4.B8.AD.E7.9A.84.E5.BA.94.E7.94.A8></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B3%95%E5%90%91%E6%98%A0%E5%B0%84&amp;action=edit&amp;section=2" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>法向映射在计算机娱乐中的应用</span></h2>
<p>交互式法向映射最初只能在<a class=new title="北卡莱罗纳大学 Chapel Hill" href="http://zh.wikipedia.org/w/index.php?title=%E5%8C%97%E5%8D%A1%E8%8E%B1%E7%BD%97%E7%BA%B3%E5%A4%A7%E5%AD%A6_Chapel_Hill&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>北卡莱罗纳大学 Chapel Hill</font></u></a>建造的并行图形机器上进行渲染，后来逐渐可以在高端的 SGI 工作站上用多次渲染以或者帧缓冲操作进行法向映射，以及在低端个人计算机硬件上用调色板纹理这样的技巧实现。但是，随着家用电脑以及游戏终端的处理计算能力的不断增强以及功能越来越复杂，法向映射逐渐通过一些鲜活的计算机游戏步入大众的视野，这些游戏包括：<em><a class=new title="Far Cry" href="http://zh.wikipedia.org/w/index.php?title=Far_Cry&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Far Cry</font></u></a></em> (<a class=new title=Crytek href="http://zh.wikipedia.org/w/index.php?title=Crytek&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Crytek</font></u></a>), <em><a class=new title="Deus Ex: Invisible War" href="http://zh.wikipedia.org/w/index.php?title=Deus_Ex:_Invisible_War&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Deus Ex: Invisible War</font></u></a></em> (<a title="Eidos Interactive" href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Eidos_Interactive'))"><u><font color=#0000ff>Eidos Interactive</font></u></a>), <em><a class=new title="Thief: Deadly Shadows" href="http://zh.wikipedia.org/w/index.php?title=Thief:_Deadly_Shadows&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Thief: Deadly Shadows</font></u></a></em> (<a title="Eidos Interactive" href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Eidos_Interactive'))"><u><font color=#0000ff>Eidos Interactive</font></u></a>), <em><a class=new title="The Chronicles of Riddick: Escape from Butcher Bay" href="http://zh.wikipedia.org/w/index.php?title=The_Chronicles_of_Riddick:_Escape_from_Butcher_Bay&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>The Chronicles of Riddick: Escape from Butcher Bay</font></u></a></em> (Vivendi Universal), <em><a class=new title="Halo 2" href="http://zh.wikipedia.org/w/index.php?title=Halo_2&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Halo 2</font></u></a></em> (Microsoft), <em><a title="Doom 3" href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Doom_3'))"><u><font color=#0000ff>Doom 3</font></u></a></em> (<a title="Id Software" href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Id_Software'))"><u><font color=#0000ff>id Software</font></u></a>), <em><a class=new title="Half-Life 2" href="http://zh.wikipedia.org/w/index.php?title=Half-Life_2&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Half-Life 2</font></u></a></em> (<a class=new title="Valve Software" href="http://zh.wikipedia.org/w/index.php?title=Valve_Software&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Valve Software</font></u></a>), <em><a class=new title="Call of Duty 2" href="http://zh.wikipedia.org/w/index.php?title=Call_of_Duty_2&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Call of Duty 2</font></u></a></em> (<a title=Activision href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Activision'))"><u><font color=#0000ff>Activision</font></u></a>), 以及 <em><a class=new title="Tom Clancy\'s Splinter Cell: Chaos Theory" href="http://zh.wikipedia.org/w/index.php?title=Tom_Clancy%27s_Splinter_Cell:_Chaos_Theory&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Tom Clancy\'s Splinter Cell: Chaos Theory</font></u></a></em> (<a title=Ubisoft href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Ubisoft'))"><u><font color=#0000ff>Ubisoft</font></u></a>)。在即将推出的 <a class=new title="Unreal engine" href="http://zh.wikipedia.org/w/index.php?title=Unreal_engine&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Unreal engine</font></u></a> (<a class=new title="Epic Games" href="http://zh.wikipedia.org/w/index.php?title=Epic_Games&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Epic Games</font></u></a>) 中也大量地使用了这项技术。法向映射在视频游戏设计中的流行源自于同时具有的出色图形质量以及与生成类似效果的其它方法相比所需的较少资源。较少的处理资源要求就可以转变成性能的提升，并且使得按照距离索引细节缩放这种降低纹理法向图细节的技术成为可能，基本上这就意味着距离越远所需的光照模拟复杂性越低，这样就可以减少处理工作，而且能够保持与近距纹理同样的细节层次。</p>
<p>目前，法向映射已经在个人电脑以及游戏终端上得到成功而广泛的应邀。最初，微软的 Xbox 是唯一完全支持这种效果的家庭游戏终端，其它一些终端由于硬件上不能直接支持者中功能所以只能通过软件实现。如 Xbox360 这样的下一代终端的开发人员严重依赖于法向映射的技术，并且已经开始着手实现<a title=视差映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%A7%86%E5%B7%AE%E6%98%A0%E5%B0%84'))"><u><font color=#0000ff>视差映射</font></u></a>技术。</p>
<p><a name=.E5.8F.82.E8.80.83.E6.96.87.E7.8C.AE></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B3%95%E5%90%91%E6%98%A0%E5%B0%84&amp;action=edit&amp;section=3" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>参考文献</span></h2>
<ul>
    <li><a title=纹理映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%BA%B9%E7%90%86%E6%98%A0%E5%B0%84'))"><font color=#0000ff><u>纹理映射</u></font></a></li>
    <li><a title=凸凹纹理映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%87%B8%E5%87%B9%E7%BA%B9%E7%90%86%E6%98%A0%E5%B0%84'))"><font color=#0000ff><u>凸凹纹理映射</u></font></a></li>
    <li><a title=视差映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%A7%86%E5%B7%AE%E6%98%A0%E5%B0%84'))"><u><font color=#0000ff>视差映射</font></u></a></li>
    <li><a title=位移映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E4%BD%8D%E7%A7%BB%E6%98%A0%E5%B0%84'))"><u><font color=#0000ff>位移映射</font></u></a></li>
    <li><a title=线性代数 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%BA%BF%E6%80%A7%E4%BB%A3%E6%95%B0'))"><u><font color=#0000ff>线性代数</font></u></a></li>
</ul>
<p><a name=.E5.A4.96.E9.83.A8.E9.93.BE.E6.8E.A5><u><font color=#0000ff></font></u></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B3%95%E5%90%91%E6%98%A0%E5%B0%84&amp;action=edit&amp;section=4" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>外部链接</span></h2>
<ul>
    <li><a class="external text" title=http://mediawiki.blender.org/index.php/Manual/Bump_and_Normal_Maps href="http://mediawiki.blender.org/index.php/Manual/Bump_and_Normal_Maps" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><font color=#0000ff><u>Blender 法向映射</u></font></a></li>
    <li><a class="external text" title=http://nifelheim.dyndns.org/%7ecocidius/normalmap/ href="http://nifelheim.dyndns.org/%7ecocidius/normalmap/" target=_blank rel=nofollow><font color=#0000ff><u><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">GIMP 法向图插件</u></font></a></li>
    <li><a class="external text" title=http://developer.nvidia.com/object/photoshop_dds_plugins.html href="http://developer.nvidia.com/object/photoshop_dds_plugins.html" target=_blank rel=nofollow><font color=#0000ff><u><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Photoshop 法向图插件</u></font></a></li>
    <li><a class="external text" title=http://www.bencloward.com/tutorials_normal_maps1.shtml href="http://www.bencloward.com/tutorials_normal_maps1.shtml" target=_blank rel=nofollow><u><font color=#0000ff><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">艺术家使用法向映射指南</font></u></a>, Ben Cloward</li>
    <li><a class="external text" title=http://www.xnormal.net href="http://www.xnormal.net/" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Free xNormal 法向映射工具</font></u></a>, Santiago Orgaz</li>
    <li><a class="external text" title=http://www.drone.org/tutorials/displacement_maps.html href="http://www.drone.org/tutorials/displacement_maps.html" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Maya 法向映射插件</font></u></a>, Olivier Renouard</li>
    <li><a class="external text" title=http://vcg.isti.cnr.it/activities/geometryegraphics/bumpmapping.html href="http://vcg.isti.cnr.it/activities/geometryegraphics/bumpmapping.html" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>调色板纹理法向映射</font></u></a> 使用旧的 OpenGL 扩展</li>
    <li><a class="external text" title=http://ada.untergrund.net/showdemo.php?demoid=534&amp;pv=1#Comments href="http://ada.untergrund.net/showdemo.php?demoid=534&amp;pv=1#Comments" rel=nofollow><u><font color=#0000ff>没有硬件辅助的法向映射</font></u></a>, Lux aeterna luceat eis Amiga demo from Ephidrena</li>
    <li><a class="external text" title=http://206.145.80.239/zbc/showthread.php?t=031281 href="http://206.145.80.239/zbc/showthread.php?t=031281" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>ZMapper</font></u></a>, Pixologic</li>
    <li><a class="external text" title=http://66.70.170.53/Ryan/nrmphoto/nrmphoto.html href="http://66.70.170.53/Ryan/nrmphoto/nrmphoto.html" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>法向映射照片</font></u></a> 通过数字照片分层手工创建法向图</li>
</ul>
<p><a name=.E5.8F.82.E8.80.83.E6.96.87.E7.8C.AE_2></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B3%95%E5%90%91%E6%98%A0%E5%B0%84&amp;action=edit&amp;section=5" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>参考文献</span></h2>
<ul>
    <li><a class="external text" title=http://www-graphics.stanford.edu/papers/surfacefitting/ href="http://www-graphics.stanford.edu/papers/surfacefitting/" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Fitting Smooth Surfaces to Dense Polygon Meshes</font></u></a>, Krishnamurthy and Levoy, SIGGRAPH 1996</li>
    <li><strong>(PDF)</strong><a class="external text" title=http://www.cs.unc.edu/~geom/APS/APS.pdf href="http://www.cs.unc.edu/%7Egeom/APS/APS.pdf" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Appearance-Preserving Simplification</font></u></a>, Cohen et. al, SIGGRAPH 1998</li>
    <li><strong>(PDF)</strong><a class="external text" title=http://vcg.isti.cnr.it/publications/papers/rocchini.pdf href="http://vcg.isti.cnr.it/publications/papers/rocchini.pdf" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>A general method for recovering attribute values on simplifed meshes</font></u></a>, Cignoni et al, IEEE Visualization 1998</li>
    <li><strong>(PDF)</strong><a class="external text" title=http://www.cs.ubc.ca/~heidrich/Papers/Siggraph.99.pdf href="http://www.cs.ubc.ca/%7Eheidrich/Papers/Siggraph.99.pdf" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Realistic, Hardware-accelerated Shading and Lighting</font></u></a>, Heidrich and Seidel, SIGGRAPH 1999</li>
</ul>
</div>
<img src ="http://www.cppblog.com/yaoming/aggbug/40134.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/yaoming/" target="_blank">姚明</a> 2008-01-01 08:37 <a href="http://www.cppblog.com/yaoming/archive/2008/01/01/40134.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>画家算法</title><link>http://www.cppblog.com/yaoming/archive/2008/01/01/40133.html</link><dc:creator>姚明</dc:creator><author>姚明</author><pubDate>Tue, 01 Jan 2008 00:35:00 GMT</pubDate><guid>http://www.cppblog.com/yaoming/archive/2008/01/01/40133.html</guid><wfw:comment>http://www.cppblog.com/yaoming/comments/40133.html</wfw:comment><comments>http://www.cppblog.com/yaoming/archive/2008/01/01/40133.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/yaoming/comments/commentRss/40133.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/yaoming/services/trackbacks/40133.html</trackback:ping><description><![CDATA[<h1 class=firstHeading>画家算法</h1>
<div id=bodyContent>
<h3 id=siteSub>&nbsp;</h3>
<div id=contentSub></div>
<p><strong>画家算法</strong>也叫作<strong>优先填充</strong>，它是<a title=三维计算机图形 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E4%B8%89%E7%BB%B4%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9B%BE%E5%BD%A2'))"><u><font color=#0000ff>三维计算机图形学</font></u></a>中处理<a class=new title=可见性问题 href="http://zh.wikipedia.org/w/index.php?title=%E5%8F%AF%E8%A7%81%E6%80%A7%E9%97%AE%E9%A2%98&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>可见性问题</font></u></a>的一种解决方法。当将三维场景投影到二维平面的时候，需要确定哪些<a title=多边形 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%A4%9A%E8%BE%B9%E5%BD%A2'))"><u><font color=#0000ff>多边形</font></u></a>是可见的，哪些是不可见的。</p>
<p>&#8220;画家算法&#8221;表示头脑简单的画家首先绘制距离较远的场景，然后用绘制距离较近的场景覆盖较远的部分。画家算法首先将场景中的多边形根据深度进行排序，然后按照顺序进行描绘。这种方法通常会将不可见的部分覆盖，这样就可以解决可见性问题。</p>
<center>
<div class=center>
<div class="thumb tnone">
<div class=thumbinner style="WIDTH: 602px"><a class=image title=首先绘制远山，然后绘制较近的草地，最后绘制场景中最近的树木等 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Painter%27s_algorithm.png'))"><img class=thumbimage height=150 alt=首先绘制远山，然后绘制较近的草地，最后绘制场景中最近的树木等 src="http://upload.wikimedia.org/wikipedia/commons/thumb/8/84/Painter%27s_algorithm.png/600px-Painter%27s_algorithm.png" width=600 border=0></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=放大 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Painter%27s_algorithm.png'))"><img height=11 alt="" src="http://zh.wikipedia.org/skins-1.5/common/images/magnify-clip.png" width=15></a></div>
首先绘制远山，然后绘制较近的草地，最后绘制场景中最近的树木等</div>
</div>
</div>
</div>
</center>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 102px"><a class=image title=画家算法无法处理相互重叠的多边形 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Painters_problem.png'))"><img class=thumbimage height=100 alt=画家算法无法处理相互重叠的多边形 src="http://upload.wikimedia.org/wikipedia/commons/6/64/Painters_problem.png" width=100 border=0></a>
<div class=thumbcaption>画家算法无法处理相互重叠的多边形</div>
</div>
</div>
<p>在有些场合下，画家算法可能无法解决可见性问题。在这个例子中，多边形 A、B、C 互相重叠，我们无法确定哪一个多边形在上面，哪一个在下面，我们也无法确定两个多边形什么时候在三维空间中交叉。在这种情况下必须用一些方法对这些多边形进行切分、排序。<a title=1972年 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/1972%E5%B9%B4'))"><u><font color=#0000ff>1972年</font></u></a>提出的<a class=new title=Newell算法 href="http://zh.wikipedia.org/w/index.php?title=Newell%E7%AE%97%E6%B3%95&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Newell算法</font></u></a>就是切分类似多边形的一种方法，在<a title=计算几何 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%AE%A1%E7%AE%97%E5%87%A0%E4%BD%95'))"><u><font color=#0000ff>计算几何</font></u></a>领域人们已经提出了许许多多的解决方法。</p>
<p>一些基本的画家算法实现方法也可能效率很低，因为这将使得系统将可见多边形集合中的每个点都进行<a title=渲染 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%B8%B2%E6%9F%93'))"><u><font color=#0000ff>渲染</font></u></a>，而没有考虑这些多变性在最终场景中可能被其它部分遮挡。这也就是说，对于细致的场景来说，画家算法可能会过度地消耗计算机资源。</p>
<p>人们有时候也使用<strong>逆向画家算法</strong>进行处理，这种算法首先绘制距离观察者较近的物体，已经进行绘制的部分不再进行其它的绘制过程。在计算机图形系统中，这种方法由于无需根据光照、纹理等参数计算被较近物体遮挡的远处物体的颜色，所以效率非常高。但是，这种方法也有许多与普通画家算法同样的问题。</p>
<p>画家算法的这些缺陷导致了<a title=深度缓冲 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%B7%B1%E5%BA%A6%E7%BC%93%E5%86%B2'))"><u><font color=#0000ff>深度缓冲</font></u></a>技术的发展，深度缓冲技术可以看作是画家算法的一个发展，它根据逐个像素的信息解决深度冲突的问题，并且抛弃了对于深度渲染顺序的依赖。即使在这样的系统中，有时也使用画家算法的变体。由于深度缓冲实现通常是基于硬件中的固定精度深度缓冲寄存器，因此舍入误差就会带来一些显示问题，即在多边形连接的地方会出现重叠或者间隙。为了避免这种问题，一些图形处理引擎使用了&#8220;过度渲染&#8221;的方法，即根据画家算法的顺序绘制两个多边形中受影响的边界。这也就是说有些像素如同在画家算法中那样实际上绘制了两次，但是由于图像中只有很少的一部分才做这样的处理，因此对于性能的影响很小。</p>
</div>
<img src ="http://www.cppblog.com/yaoming/aggbug/40133.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/yaoming/" target="_blank">姚明</a> 2008-01-01 08:35 <a href="http://www.cppblog.com/yaoming/archive/2008/01/01/40133.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>粒子系统</title><link>http://www.cppblog.com/yaoming/archive/2008/01/01/40132.html</link><dc:creator>姚明</dc:creator><author>姚明</author><pubDate>Tue, 01 Jan 2008 00:33:00 GMT</pubDate><guid>http://www.cppblog.com/yaoming/archive/2008/01/01/40132.html</guid><wfw:comment>http://www.cppblog.com/yaoming/comments/40132.html</wfw:comment><comments>http://www.cppblog.com/yaoming/archive/2008/01/01/40132.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/yaoming/comments/commentRss/40132.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/yaoming/services/trackbacks/40132.html</trackback:ping><description><![CDATA[<h1 class=firstHeading>粒子系统</h1>
<div id=bodyContent>
<h3 id=siteSub>&nbsp;</h3>
<div id=contentSub></div>
<p><strong>粒子系统</strong>（<a class=extiw title=en:particle_system href="javascript:void(wb.w._link('http://en.wikipedia.org/wiki/particle_system'))"><u><font color=#0000ff>en:particle system</font></u></a>）表示<a title=三维计算机图形学 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E4%B8%89%E7%BB%B4%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9B%BE%E5%BD%A2%E5%AD%A6'))"><u><font color=#800080>三维计算机图形学</font></u></a>中模拟一些特定的模糊现象的技术，而这些现象用其它传统的渲染技术难以实现的真实感的 <a class=new title="Game physics" href="http://zh.wikipedia.org/w/index.php?title=Game_physics&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>game physics</font></u></a>。经常使用粒子系统模拟的现象有火、爆炸、烟、水流、火花、落叶、云、雾、雪、尘、流星尾迹或者象发光轨迹这样的抽象视觉效果等等。</p>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 182px"><a class=image title=用于渲染火的粒子系统 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Particle_sys_fire.jpg'))"><img class=thumbimage height=157 alt=用于渲染火的粒子系统 src="http://upload.wikimedia.org/wikipedia/commons/thumb/f/f2/Particle_sys_fire.jpg/180px-Particle_sys_fire.jpg" width=180 border=0></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=放大 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Particle_sys_fire.jpg'))"><img height=11 alt="" src="http://zh.wikipedia.org/skins-1.5/common/images/magnify-clip.png" width=15></a></div>
用于渲染火的粒子系统</div>
</div>
</div>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 182px"><a class=image title=用来渲染星系的粒子系统 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Particle_sys_galaxy.jpg'))"><img class=thumbimage height=126 alt=用来渲染星系的粒子系统 src="http://upload.wikimedia.org/wikipedia/commons/thumb/7/70/Particle_sys_galaxy.jpg/180px-Particle_sys_galaxy.jpg" width=180 border=0></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=放大 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Particle_sys_galaxy.jpg'))"><img height=11 alt="" src="http://zh.wikipedia.org/skins-1.5/common/images/magnify-clip.png" width=15></a></div>
用来渲染星系的粒子系统</div>
</div>
</div>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 182px"><a class=image title="abstract 粒子尾迹" href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Particle_sys_trail.jpg'))"><img class=thumbimage height=152 alt="abstract 粒子尾迹" src="http://upload.wikimedia.org/wikipedia/zh/thumb/d/d0/Particle_sys_trail.jpg/180px-Particle_sys_trail.jpg" width=180 border=0></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=放大 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Particle_sys_trail.jpg'))"><img height=11 alt="" src="http://zh.wikipedia.org/skins-1.5/common/images/magnify-clip.png" width=15></a></div>
abstract 粒子尾迹</div>
</div>
</div>
<table class=toc id=toc summary=目录>
    <tbody>
        <tr>
            <td>
            <div id=toctitle>
            <h2>目录</h2>
            </div>
            <ul>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.85.B8.E5.9E.8B.E5.AE.9E.E7.8E.B0"><font color=#800080><u><span class=tocnumber>1</span><span class=toctext>典型实现</span></u></font></a>
                <ul>
                    <li class=toclevel-2><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E6.A8.A1.E6.8B.9F.E9.98.B6.E6.AE.B5"><font color=#800080><u><span class=tocnumber>1.1</span><span class=toctext>模拟阶段</span></u></font></a></li>
                    <li class=toclevel-2><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E6.B8.B2.E6.9F.93.E9.98.B6.E6.AE.B5"><font color=#800080><u><span class=tocnumber>1.2</span><span class=toctext>渲染阶段</span></u></font></a></li>
                </ul>
                </li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.AF.B9.E8.89.BA.E6.9C.AF.E5.AE.B6.E5.8F.8B.E5.A5.BD.E7.9A.84.E7.B2.92.E5.AD.90.E7.B3.BB.E7.BB.9F.E5.B7.A5.E5.85.B7"><font color=#800080><u><span class=tocnumber>2</span><span class=toctext>对艺术家友好的粒子系统工具</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.A4.96.E9.83.A8.E9.93.BE.E6.8E.A5"><u><font color=#800080><span class=tocnumber>3</span><span class=toctext>外部链接</span></font></u></a></li>
            </ul>
            </td>
        </tr>
    </tbody>
</table>
<p><a name=.E5.85.B8.E5.9E.8B.E5.AE.9E.E7.8E.B0><u><font color=#800080></font></u></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E7%B2%92%E5%AD%90%E7%B3%BB%E7%BB%9F&amp;action=edit&amp;section=1" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>典型实现</span></h2>
<p>通常粒子系统在三维空间中的位置与运动是由<strong>发射器</strong>控制的。<strong>发射器</strong>主要由一组粒子行为参数以及在三维空间中的位置所表示。粒子行为参数可以包括粒子生成速度（即单位时间粒子生成的数目）、粒子初始速度向量（例如什么时候向什么方向运动）、粒子寿命（经过多长时间粒子湮灭）、粒子颜色、在粒子生命周期中的变化以及其它参数等等。使用大概值而不是绝对值的模糊参数占据全部或者绝大部分是很正常的，一些参数定义了中心值以及允许的变化。</p>
<p>典型的粒子系统更新循环可以划分为两个不同的阶段：<strong>参数更新/模拟</strong>阶段以及<strong>渲染</strong>阶段。每个循环执行每一帧动画。</p>
<p><a name=.E6.A8.A1.E6.8B.9F.E9.98.B6.E6.AE.B5></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E7%B2%92%E5%AD%90%E7%B3%BB%E7%BB%9F&amp;action=edit&amp;section=2" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>模拟阶段</span></h3>
<p>在<strong>模拟</strong>阶段，根据生成速度以及更新间隔计算新粒子的数目，每个粒子根据发射器的位置及给定的生成区域在特定的三维空间位置生成，并且根据发射器的参数初始化每个粒子的速度、颜色、生命周期等等参数。然后检查每个粒子是否已经超出了生命周期，一旦超出就将这些粒子剔出模拟过程，否则就根据物理模拟更改粒子的位置与特性，这些物理模拟可能象将速度加到当前位置或者调整速度抵消摩擦这样简单，也可能象将外力考虑进取计算正确的物理抛射轨迹那样复杂。另外，经常需要检查与特殊三维物体的碰撞以使粒子从障碍物弹回。由于粒子之间的碰撞计算量很大并且对于大多数模拟来说没有必要，所以很少使用粒子之间的碰撞。</p>
<p>每个粒子系统都有用于其中每个粒子的特定规则，通常这些规则涉及到粒子生命周期的<a title=插值 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%8F%92%E5%80%BC'))"><u><font color=#0000ff>插值</font></u></a>过程。例如，许多系统在粒子生命周期中对离子的<a title=阿尔法通道 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E9%98%BF%E5%B0%94%E6%B3%95%E9%80%9A%E9%81%93'))"><u><font color=#0000ff>阿尔法值</font></u></a>即透明性进行插值直到例子湮灭。</p>
<p><a name=.E6.B8.B2.E6.9F.93.E9.98.B6.E6.AE.B5></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E7%B2%92%E5%AD%90%E7%B3%BB%E7%BB%9F&amp;action=edit&amp;section=3" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>渲染阶段</span></h3>
<p>在更新完成之后，通常每个例子用经过<a title=纹理映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%BA%B9%E7%90%86%E6%98%A0%E5%B0%84'))"><u><font color=#0000ff>纹理映射</font></u></a>的<a title=四边形 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%9B%9B%E8%BE%B9%E5%BD%A2'))"><u><font color=#0000ff>四边形</font></u></a><a class=new title=Sprite href="http://zh.wikipedia.org/w/index.php?title=Sprite&amp;action=edit" target=_blank><u><font color=#0000ff><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">sprite</font></u></a>进行渲染，也就是说四边形总是面向观察者。但是，这个过程不是必须的，在一些低分辨率或者处理能力有限的场合粒子可能仅仅渲染成一个像素，在离线渲染中甚至渲染成一个<a title=元球 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%85%83%E7%90%83'))"><u><font color=#0000ff>元球</font></u></a>，从粒子元球计算出的等值面可以得到相当好的液体表面。另外，也可以用三维网格渲染粒子。</p>
<p><a name=.E5.AF.B9.E8.89.BA.E6.9C.AF.E5.AE.B6.E5.8F.8B.E5.A5.BD.E7.9A.84.E7.B2.92.E5.AD.90.E7.B3.BB.E7.BB.9F.E5.B7.A5.E5.85.B7></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E7%B2%92%E5%AD%90%E7%B3%BB%E7%BB%9F&amp;action=edit&amp;section=4" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>对艺术家友好的粒子系统工具</span></h2>
<p>在许多三维建模及渲染包内部就可以创建、修改粒子系统，如 <a title="3D Studio Max" href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/3D_Studio_Max'))"><u><font color=#0000ff>3D Studio Max</font></u></a>、<a title=Maya href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Maya'))"><u><font color=#0000ff>Maya</font></u></a> 以及 <a title=Blender href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Blender'))"><u><font color=#0000ff>Blender</font></u></a> 等。这些编辑程序使艺术家能够立即看到他们设定的特性或者规则下粒子系统的表现，另外还有一些<a title=插件 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%8F%92%E4%BB%B6'))"><u><font color=#0000ff>插件</font></u></a>能够提供增强的粒子系统效果，例如 <a class=new title=AfterBurn href="http://zh.wikipedia.org/w/index.php?title=AfterBurn&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>AfterBurn</font></u></a> 以及用于流体的 <a class=new title=RealFlow href="http://zh.wikipedia.org/w/index.php?title=RealFlow&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>RealFlow</font></u></a>。<a class=new title="Autodesk Media and Entertainment" href="http://zh.wikipedia.org/w/index.php?title=Autodesk_Media_and_Entertainment&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Combustion</font></u></a> 这样的多用途软件或者只能用于粒子系统的 Particle Studio 等都可以用来生成电影或者视频中的粒子系统。</p>
<p><a name=.E5.A4.96.E9.83.A8.E9.93.BE.E6.8E.A5></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E7%B2%92%E5%AD%90%E7%B3%BB%E7%BB%9F&amp;action=edit&amp;section=5" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>外部链接</span></h2>
<ul>
    <li><a class="external text" title=http://portal.acm.org/citation.cfm?id=357320 href="http://portal.acm.org/citation.cfm?id=357320" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Particle Systems: A Technique for Modeling a Class of Fuzzy Objects</font></u></a> &#8211; William T. Reeves (<a class=new title="ACM Transactions on Graphics" href="http://zh.wikipedia.org/w/index.php?title=ACM_Transactions_on_Graphics&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>ACM Transactions on Graphics</font></u></a>, April 1983)</li>
</ul>
</div>
<img src ="http://www.cppblog.com/yaoming/aggbug/40132.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/yaoming/" target="_blank">姚明</a> 2008-01-01 08:33 <a href="http://www.cppblog.com/yaoming/archive/2008/01/01/40132.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>细节层次</title><link>http://www.cppblog.com/yaoming/archive/2008/01/01/40131.html</link><dc:creator>姚明</dc:creator><author>姚明</author><pubDate>Tue, 01 Jan 2008 00:31:00 GMT</pubDate><guid>http://www.cppblog.com/yaoming/archive/2008/01/01/40131.html</guid><wfw:comment>http://www.cppblog.com/yaoming/comments/40131.html</wfw:comment><comments>http://www.cppblog.com/yaoming/archive/2008/01/01/40131.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/yaoming/comments/commentRss/40131.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/yaoming/services/trackbacks/40131.html</trackback:ping><description><![CDATA[<h1 class=firstHeading>细节层次</h1>
<div id=bodyContent>
<h3 id=siteSub>&nbsp;</h3>
<div id=contentSub></div>
<p>在<a title=程序设计 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%A8%8B%E5%BA%8F%E8%AE%BE%E8%AE%A1'))"><u><font color=#0000ff>程序设计</font></u></a>和<a title=计算机图形学 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9B%BE%E5%BD%A2%E5%AD%A6'))"><u><font color=#0000ff>计算机图形学</font></u></a>领域，<strong>细节层次</strong>（<a class=extiw title=en:Level_of_detail href="javascript:void(wb.w._link('http://en.wikipedia.org/wiki/Level_of_detail'))"><u><font color=#0000ff>en:Level of detail</font></u></a>）随着物体或者模型远离观察者而逐步降低。由于它能够通过减少<a title=多边形 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%A4%9A%E8%BE%B9%E5%BD%A2'))"><u><font color=#0000ff>多边形</font></u></a>的数目从而提升渲染效率，所以在<a title=电子游戏 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%94%B5%E5%AD%90%E6%B8%B8%E6%88%8F'))"><u><font color=#800080>计算机与视频游戏</font></u></a>中使用了这项技术。由于物体距离很远，所以理论上并不会察觉到模型或者物体的视觉质量会有所下降。当然，这根据单个系统或者游戏的不同而有所不同。</p>
<p><em><a class=new title="Messiah (video game)" href="http://zh.wikipedia.org/w/index.php?title=Messiah_%28video_game%29&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Messiah</font></u></a></em> 与 <em><a class=new title="Black &amp; White (game)" href="http://zh.wikipedia.org/w/index.php?title=Black_%26_White_%28game%29&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Black &amp; White</font></u></a></em> 是首先将细节层次效果用于渲染的游戏。每张地图由一个大岛组成，有时还有数以百计的居民。当玩家将场景缩小的时候，逐步降低细节的模型就取代了村民、建筑物甚至是岛屿。尽管这种做法不尽完美，但是这项技术使得在近距观察时能够看到细节，而在远距离观察的时候而不会降低运行速度。<em><a class=new title="Messiah (video game)" href="http://zh.wikipedia.org/w/index.php?title=Messiah_%28video_game%29&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Messiah</font></u></a></em> 使用一种类似的技术，并且它的发布早于 <em>Black &amp; White</em>。<a class="external autonumber" title=http://pc.ign.com/articles/123/123117p1.html href="http://pc.ign.com/articles/123/123117p1.html" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><font color=#0000ff><u>[1]</u></font></a></p>
<p><em><a class=new title="Halo 2" href="http://zh.wikipedia.org/w/index.php?title=Halo_2&amp;action=edit" target=_blank><u><font color=#0000ff><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Halo 2</font></u></a></em> 使用细节层次调整实现 cutscene 以及地图中更高的细节层次，但是牺牲了首次调用这个细节层次时的速度，最初显示的模型细节层次很少甚至没有细节层次，过了一段时间才会出现更加细致的模型及纹理。</p>
<p>为了使得细节降低不再明显，在计算机与视频游戏中经常使用<a title=距离模糊 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%B7%9D%E7%A6%BB%E6%A8%A1%E7%B3%8A'))"><u><font color=#0000ff>距离模糊</font></u></a>减少物体上的可见细节来模拟现实中的物体远离时的模糊现象。当物体处于<a title=可见度 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%8F%AF%E8%A7%81%E5%BA%A6'))"><u><font color=#0000ff>可见</font></u></a>范围之外的时候，将不再需要进行<a title=渲染 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%B8%B2%E6%9F%93'))"><u><font color=#0000ff>渲染</font></u></a>。</p>
<p>在自动细节层次构建中最常用的一种方法是基于三维<a title=多边形网格 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%A4%9A%E8%BE%B9%E5%BD%A2%E7%BD%91%E6%A0%BC'))"><u><font color=#0000ff>多边形网格</font></u></a>的边缘折叠变换。三维网格中的每一对顶点都根据曲率或者其它准则给定一个误差度量权重，具有最小误差的一对顶点合并或者折叠到同一个<a title=顶点 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E9%A1%B6%E7%82%B9'))"><u><font color=#0000ff>顶点</font></u></a>。重复这个过程直到达到所期望的三角形数目。</p>
<p>其它一些更加先进的方法带有生成预先计算的边缘折叠或者顶点分割数值的列表，这样的列表可以用于物体细节层次的实时计算。这种方法经常称为渐进网格。</p>
<p>更加先进的细节层次运行系统使用的算法为了增加衰减能够合并几个三维物体或者简化合并的物体，这样的算法叫作分级细节层次算法。</p>
<p><a name=.E5.A4.96.E9.83.A8.E9.93.BE.E6.8E.A5></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E7%BB%86%E8%8A%82%E5%B1%82%E6%AC%A1&amp;action=edit&amp;section=1" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>外部链接</span></h2>
<ul>
    <li><em><a class="external text" title=http://lodbook.com/ href="http://lodbook.com/" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>三维计算机图形中的细节层次</font></u></a></em>, D. Luebke et. al. 著; 计算机图形学中关于细节层次最全的图书之一</li>
    <li><a class="external text" title=http://www.cs.unc.edu/~geom/HLOD/Dissertation/Dissertation.pdf href="http://www.cs.unc.edu/%7Egeom/HLOD/Dissertation/Dissertation.pdf" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><font color=#0000ff><u>分级细节层次博士论文 (PDF)</u></font></a></li>
    <li><a class="external text" title=http://www.donya.se href="http://www.donya.se/" target=_blank rel=nofollow><u><font color=#0000ff><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Donya research</font></u></a>; 从事细节层次研究与开发的软件公司</li>
</ul>
</div>
<img src ="http://www.cppblog.com/yaoming/aggbug/40131.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/yaoming/" target="_blank">姚明</a> 2008-01-01 08:31 <a href="http://www.cppblog.com/yaoming/archive/2008/01/01/40131.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>视差映射</title><link>http://www.cppblog.com/yaoming/archive/2008/01/01/40130.html</link><dc:creator>姚明</dc:creator><author>姚明</author><pubDate>Tue, 01 Jan 2008 00:30:00 GMT</pubDate><guid>http://www.cppblog.com/yaoming/archive/2008/01/01/40130.html</guid><wfw:comment>http://www.cppblog.com/yaoming/comments/40130.html</wfw:comment><comments>http://www.cppblog.com/yaoming/archive/2008/01/01/40130.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/yaoming/comments/commentRss/40130.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/yaoming/services/trackbacks/40130.html</trackback:ping><description><![CDATA[<h1 class=firstHeading>视差映射</h1>
<div id=bodyContent>
<h3 id=siteSub>&nbsp;</h3>
<div id=contentSub></div>
<p><strong>视差映射</strong>（<a class=extiw title=en:Parallax_Mapping href="javascript:void(wb.w._link('http://en.wikipedia.org/wiki/Parallax_Mapping'))"><u><font color=#0000ff>en:Parallax Mapping</font></u></a>）是<a title=电子游戏 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%94%B5%E5%AD%90%E6%B8%B8%E6%88%8F'))"><u><font color=#800080>视频游戏</font></u></a>这样的三维<a title=渲染 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%B8%B2%E6%9F%93'))"><u><font color=#0000ff>渲染</font></u></a>应用中使用的一种改进的<a title=凸凹纹理映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%87%B8%E5%87%B9%E7%BA%B9%E7%90%86%E6%98%A0%E5%B0%84'))"><u><font color=#0000ff>凸凹纹理映射</font></u></a>或者<a title=法向映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%B3%95%E5%90%91%E6%98%A0%E5%B0%84'))"><u><font color=#0000ff>法向映射</font></u></a>技术。对于最终用户来说，这就意味着可以在不太影响游戏速度的情况下，如木质地板这样的<a title=纹理映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%BA%B9%E7%90%86%E6%98%A0%E5%B0%84'))"><u><font color=#0000ff>纹理</font></u></a>可以有更加明显的图像深度与真实感。</p>
<p>通过改变纹理坐标实现纹理根据一个高度表进行排列，从而就可以实现视差映射。下一代的三维应用程序就可以使用视差映射作为新开发的图形<a title=算法 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%AE%97%E6%B3%95'))"><u><font color=#0000ff>算法</font></u></a>。</p>
<table class=gallery cellSpacing=0 cellPadding=0>
    <tbody>
        <tr>
            <td>
            <div class=gallerybox style="WIDTH: 155px">
            <div class=thumb style="PADDING-RIGHT: 0pt; PADDING-LEFT: 0pt; PADDING-BOTTOM: 28px; WIDTH: 150px; PADDING-TOP: 28px">
            <div style="MARGIN-LEFT: auto; WIDTH: 120px; MARGIN-RIGHT: auto"><a class=image title=Fear-pmapping1.jpg href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Fear-pmapping1.jpg'))"><img height=90 alt="" src="http://upload.wikimedia.org/wikipedia/zh/thumb/5/56/Fear-pmapping1.jpg/120px-Fear-pmapping1.jpg" width=120 border=0></a></div>
            </div>
            <div class=gallerytext>
            <p>From <em><a title=F.E.A.R. href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/F.E.A.R.'))"><u><font color=#0000ff>F.E.A.R.</font></u></a></em>, 用视差映射生成立体感的弹孔</p>
            <p><br></p>
            </div>
            </div>
            </td>
            <td>
            <div class=gallerybox style="WIDTH: 155px">
            <div class=thumb style="PADDING-RIGHT: 0pt; PADDING-LEFT: 0pt; PADDING-BOTTOM: 28px; WIDTH: 150px; PADDING-TOP: 28px">
            <div style="MARGIN-LEFT: auto; WIDTH: 120px; MARGIN-RIGHT: auto"><a class=image title=Fear-pmapping2.jpg href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Fear-pmapping2.jpg'))"><img height=90 alt="" src="http://upload.wikimedia.org/wikipedia/zh/thumb/b/ba/Fear-pmapping2.jpg/120px-Fear-pmapping2.jpg" width=120 border=0></a></div>
            </div>
            <div class=gallerytext>
            <p>From<em><a title=F.E.A.R. href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/F.E.A.R.'))"><u><font color=#0000ff>F.E.A.R.</font></u></a></em>, 从一个角度进行观察</p>
            <p><br></p>
            </div>
            </div>
            </td>
            <td>
            <div class=gallerybox style="WIDTH: 155px">
            <div class=thumb style="PADDING-RIGHT: 0pt; PADDING-LEFT: 0pt; PADDING-BOTTOM: 28px; WIDTH: 150px; PADDING-TOP: 28px">
            <div style="MARGIN-LEFT: auto; WIDTH: 120px; MARGIN-RIGHT: auto"><a class=image title=Fear-pmapping3.jpg href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Fear-pmapping3.jpg'))"><img height=90 alt="" src="http://upload.wikimedia.org/wikipedia/zh/thumb/f/fc/Fear-pmapping3.jpg/120px-Fear-pmapping3.jpg" width=120 border=0></a></div>
            </div>
            <div class=gallerytext>
            <p>From<em><a title=F.E.A.R. href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/F.E.A.R.'))"><u><font color=#0000ff>F.E.A.R.</font></u></a></em>, 当从一个非常大的角度观察时，立体感就消失了</p>
            <p><br></p>
            </div>
            </div>
            </td>
        </tr>
    </tbody>
</table>
<p>一个理解这个概念的简单方法就是闭上一只眼睛，拿一支铅笔指向眼睛，然后脑袋左右移动。在铅笔正对着测试者的时候，视察映射选取铅笔最左边的像素，然后不断地对它进行拉伸以模拟观察者相对于铅笔的角度。</p>
<p>视差映射也是模仿<a title=位移映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E4%BD%8D%E7%A7%BB%E6%98%A0%E5%B0%84'))"><u><font color=#0000ff>位移映射</font></u></a>的一种方法，根据纹理中保存的数值表面点的实际几何位置沿着表面法线发生偏移。在视差映射中，与<a title=法向映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%B3%95%E5%90%91%E6%98%A0%E5%B0%84'))"><u><font color=#0000ff>法向映射</font></u></a>和<a title=凸凹纹理映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%87%B8%E5%87%B9%E7%BA%B9%E7%90%86%E6%98%A0%E5%B0%84'))"><u><font color=#0000ff>凸凹纹理映射</font></u></a>一样，物体的<a class=new title=轮廓 href="http://zh.wikipedia.org/w/index.php?title=%E8%BD%AE%E5%BB%93&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>轮廓</font></u></a>都不受影响。</p>
<p><a name=.E5.8F.82.E8.A7.81></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E8%A7%86%E5%B7%AE%E6%98%A0%E5%B0%84&amp;action=edit&amp;section=1" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>参见</span></h2>
<ul>
    <li><a title=视差 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%A7%86%E5%B7%AE'))"><u><font color=#0000ff>视差</font></u></a></li>
</ul>
<p><a name=.E5.A4.96.E9.83.A8.E9.93.BE.E6.8E.A5><u><font color=#0000ff></font></u></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E8%A7%86%E5%B7%AE%E6%98%A0%E5%B0%84&amp;action=edit&amp;section=2" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>外部链接</span></h2>
<ul>
    <li><a class="external text" title=http://vrsj.t.u-tokyo.ac.jp/ic-at/ICAT2003/papers/01205.pdf href="http://vrsj.t.u-tokyo.ac.jp/ic-at/ICAT2003/papers/01205.pdf" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><font color=#0000ff><u>用视差映射实现形状细节表示</u></font></a></li>
    <li><a class="external text" title=http://www.gamedev.net/community/forums/topic.asp?topic_id=387447 href="http://www.gamedev.net/community/forums/topic.asp?topic_id=387447" target=_blank rel=nofollow><u><font color=#0000ff><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">在 DirectX 中实现视差映射，论坛主题</font></u></a></li>
</ul>
</div>
<img src ="http://www.cppblog.com/yaoming/aggbug/40130.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/yaoming/" target="_blank">姚明</a> 2008-01-01 08:30 <a href="http://www.cppblog.com/yaoming/archive/2008/01/01/40130.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>阴影映射</title><link>http://www.cppblog.com/yaoming/archive/2008/01/01/40129.html</link><dc:creator>姚明</dc:creator><author>姚明</author><pubDate>Tue, 01 Jan 2008 00:26:00 GMT</pubDate><guid>http://www.cppblog.com/yaoming/archive/2008/01/01/40129.html</guid><wfw:comment>http://www.cppblog.com/yaoming/comments/40129.html</wfw:comment><comments>http://www.cppblog.com/yaoming/archive/2008/01/01/40129.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/yaoming/comments/commentRss/40129.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/yaoming/services/trackbacks/40129.html</trackback:ping><description><![CDATA[<h1 class=firstHeading>阴影映射</h1>
<div id=bodyContent>
<h3 id=siteSub>&nbsp;</h3>
<div id=contentSub></div>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 182px"><a class=image title=有阴影映射的场景 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:7fin.png'))"><img class=thumbimage height=144 alt=有阴影映射的场景 src="http://upload.wikimedia.org/wikipedia/zh/thumb/3/32/7fin.png/180px-7fin.png" width=180 border=0></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=放大 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:7fin.png'))"><img height=11 alt="" src="http://zh.wikipedia.org/skins-1.5/common/images/magnify-clip.png" width=15></a></div>
有阴影映射的场景</div>
</div>
</div>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 182px"><a class=image title=没有阴影的场景 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:3noshadow.png'))"><img class=thumbimage height=144 alt=没有阴影的场景 src="http://upload.wikimedia.org/wikipedia/zh/thumb/7/74/3noshadow.png/180px-3noshadow.png" width=180 border=0></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=放大 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:3noshadow.png'))"><img height=11 alt="" src="http://zh.wikipedia.org/skins-1.5/common/images/magnify-clip.png" width=15></a></div>
没有阴影的场景</div>
</div>
</div>
<p><strong>阴影映射</strong>是在<a title=三维计算机图形 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E4%B8%89%E7%BB%B4%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9B%BE%E5%BD%A2'))">三维计算机图形</a>中加入<a class=new title=阴影 href="http://zh.wikipedia.org/w/index.php?title=%E9%98%B4%E5%BD%B1&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">阴影</a>的过程。阴影映射的概念最初是由 <a class=new title="Lance Williams" href="http://zh.wikipedia.org/w/index.php?title=Lance_Williams&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Lance Williams</a> 于 <a title=1978年 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/1978%E5%B9%B4'))">1978年</a>在&#8220;在曲面上投射阴影&#8221;这篇论文中提出的。从那时开始，这种方法就已经用于场景预渲染、实时甚至是许多游戏设备以及高端电脑游戏中。在<a title=Pixar href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Pixar'))">Pixar</a> 的 <a title=RenderMan href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/RenderMan'))">RenderMan</a> 中就使用了阴影映射技术，同样，在 <em><a title=玩具总动员 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%8E%A9%E5%85%B7%E6%80%BB%E5%8A%A8%E5%91%98'))">玩具总动员</a></em> 这样的游戏中也使用了这项技术。</p>
<p>像素与以<a class=new title=纹理 href="http://zh.wikipedia.org/w/index.php?title=%E7%BA%B9%E7%90%86&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">纹理</a>形式保存的光照<a title=深度缓冲 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%B7%B1%E5%BA%A6%E7%BC%93%E5%86%B2'))">深度缓冲</a>区或者深度图像比较，通过这种方式计算像素是否处于光源照射范围之内，从而生成阴影。</p>
<table class=toc id=toc summary=目录>
    <tbody>
        <tr>
            <td>
            <div id=toctitle>
            <h2>目录</h2>
            </div>
            <ul>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E9.98.B4.E5.BD.B1.E5.8F.8A.E9.98.B4.E5.BD.B1.E5.9B.BE.E7.9A.84.E5.8E.9F.E7.90.86"><span class=tocnumber>1</span><span class=toctext>阴影及阴影图的原理</span></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E7.AE.97.E6.B3.95.E7.BB.BC.E8.BF.B0"><span class=tocnumber>2</span><span class=toctext>算法综述</span></a>
                <ul>
                    <li class=toclevel-2><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E7.94.9F.E6.88.90.E9.98.B4.E5.BD.B1.E5.9B.BE"><span class=tocnumber>2.1</span><span class=toctext>生成阴影图</span></a></li>
                    <li class=toclevel-2><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.9C.BA.E6.99.AF.E7.9A.84.E6.B5.93.E6.B7.A1.E5.A4.84.E7.90.86"><span class=tocnumber>2.2</span><span class=toctext>场景的浓淡处理</span></a>
                    <ul>
                        <li class=toclevel-3><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.85.89.E7.85.A7.E7.A9.BA.E9.97.B4.E5.9D.90.E6.A0.87"><span class=tocnumber>2.2.1</span><span class=toctext>光照空间坐标</span></a></li>
                        <li class=toclevel-3><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E6.B7.B1.E5.BA.A6.E5.9B.BE.E6.A3.80.E9.AA.8C"><span class=tocnumber>2.2.2</span><span class=toctext>深度图检验</span></a></li>
                        <li class=toclevel-3><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E7.BB.98.E5.88.B6.E5.9C.BA.E6.99.AF"><span class=tocnumber>2.2.3</span><span class=toctext>绘制场景</span></a></li>
                    </ul>
                    </li>
                </ul>
                </li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.8F.82.E8.A7.81"><span class=tocnumber>3</span><span class=toctext>参见</span></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.A4.96.E9.83.A8.E9.93.BE.E6.8E.A5"><span class=tocnumber>4</span><span class=toctext>外部链接</span></a></li>
            </ul>
            </td>
        </tr>
    </tbody>
</table>
<p><a name=.E9.98.B4.E5.BD.B1.E5.8F.8A.E9.98.B4.E5.BD.B1.E5.9B.BE.E7.9A.84.E5.8E.9F.E7.90.86></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E9%98%B4%E5%BD%B1%E6%98%A0%E5%B0%84&amp;action=edit&amp;section=1" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>阴影及阴影图的原理</span></h2>
<p>从光源位置看出去，所有能够看到的物体都处在光照之中，但是这些物体后面的东西将处于阴影这种。这就是生成阴影图的最基本的原理。光照场景进行渲染，保存能够看到的物体表面深度，即为阴影图。然后，正常的场景中的每个点都与这个深度图进行比较，就好像判断场景中的每个点能否被光线看到，从而进行正常场景的渲染。</p>
<p>对于实时阴影来说，这项技术要比<a title=阴影体 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E9%98%B4%E5%BD%B1%E4%BD%93'))">阴影体</a>的精度差一些，但是根据在特定应用中每种技术所需填充时间的不同，阴影图有些情况下是一种速度比较快的选择。并且，阴影图不需要额外的<a class=new title=模板缓存 href="http://zh.wikipedia.org/w/index.php?title=%E6%A8%A1%E6%9D%BF%E7%BC%93%E5%AD%98&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">模板缓存</a>，并且可以经过修改生成柔和边界的阴影。但是，与阴影体不同，阴影图的精度受到分辨率的限制。</p>
<p><a name=.E7.AE.97.E6.B3.95.E7.BB.BC.E8.BF.B0></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E9%98%B4%E5%BD%B1%E6%98%A0%E5%B0%84&amp;action=edit&amp;section=2" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>算法综述</span></h2>
<p>对于阴影场景的渲染需要两个步骤来完成。第一步是产生阴影图本身，第二步是将阴影图应用到场景中。根据实现方式以及光源数目的不同，阴影场景渲染过程可能需要两个或者更多的绘制过程。</p>
<p><a name=.E7.94.9F.E6.88.90.E9.98.B4.E5.BD.B1.E5.9B.BE></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E9%98%B4%E5%BD%B1%E6%98%A0%E5%B0%84&amp;action=edit&amp;section=3" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>生成阴影图</span></h3>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 152px"><a class=image title=从光源视角渲染的场景 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:1light.png'))"><img class=thumbimage height=120 alt=从光源视角渲染的场景 src="http://upload.wikimedia.org/wikipedia/zh/thumb/b/bf/1light.png/150px-1light.png" width=150 border=0></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=放大 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:1light.png'))"><img height=11 alt="" src="http://zh.wikipedia.org/skins-1.5/common/images/magnify-clip.png" width=15></a></div>
从光源视角渲染的场景</div>
</div>
</div>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 152px"><a class=image title=光源视角的场景深度图 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:2shadowmap.png'))"><img class=thumbimage height=120 alt=光源视角的场景深度图 src="http://upload.wikimedia.org/wikipedia/commons/thumb/2/23/2shadowmap.png/150px-2shadowmap.png" width=150 border=0></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=放大 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:2shadowmap.png'))"><img height=11 alt="" src="http://zh.wikipedia.org/skins-1.5/common/images/magnify-clip.png" width=15></a></div>
光源视角的场景深度图</div>
</div>
</div>
<p>第一步是从光源的视角渲染场景。对于点光源来说，视场是一个视角足够宽的<a title=透视投影 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E9%80%8F%E8%A7%86%E6%8A%95%E5%BD%B1'))">透视投影</a>。对于象<a title=太阳 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%A4%AA%E9%98%B3'))">太阳</a>光这样的定向光来说，需要使用<a class=new title=正投影 href="http://zh.wikipedia.org/w/index.php?title=%E6%AD%A3%E6%8A%95%E5%BD%B1&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">正投影</a>。</p>
<p>根据这个渲染结果提取、保存深度缓冲。因为只与深度信息相关，因此通常避免更改颜色缓冲区，并且不对光线及纹理进行计算以及节省时间。这个<strong>深度图</strong>经常在图形卡的内存中保存为纹理。</p>
<p>一旦场景中的光源或者物体发生变动，就必须重新更新深度图，但是在其它场合下也可以重复使用深度图，例如只有照相机运动的场合。如果场景中有多个光源，必须针对每个光源分别生成深度图。</p>
<p>在许多实现方法中为了节省重绘深度图所花费的时间，可以只对场景中的一部分物体进行渲染来生成阴影图。另外，为了解决当前深度值与下一步绘制的表面深度太接近产生的<a class=new title=深度冲突 href="http://zh.wikipedia.org/w/index.php?title=%E6%B7%B1%E5%BA%A6%E5%86%B2%E7%AA%81&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">深度冲突</a>问题（Z-fighting），也可能在阴影图渲染过程中对物体的照明深度添加一个偏移。实现这种效果的另外一种可选方法是裁剪掉前面的物体，仅对后面的物体进行渲染生成阴影图。</p>
<p><a name=.E5.9C.BA.E6.99.AF.E7.9A.84.E6.B5.93.E6.B7.A1.E5.A4.84.E7.90.86></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E9%98%B4%E5%BD%B1%E6%98%A0%E5%B0%84&amp;action=edit&amp;section=4" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>场景的浓淡处理</span></h3>
<p>第二步就是使用阴影图按照普通的<a title=透视投影 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E9%80%8F%E8%A7%86%E6%8A%95%E5%BD%B1'))">透视投影</a>绘制场景。这个过程分为三个主要的部分，第一是找出物体在光照视景中的坐标，第二是将这个坐标与深度图中的对应值进行比较，最后就是根据处于阴影或者光照下的位置将物体绘制出来。</p>
<p><a name=.E5.85.89.E7.85.A7.E7.A9.BA.E9.97.B4.E5.9D.90.E6.A0.87></a></p>
<h4><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E9%98%B4%E5%BD%B1%E6%98%A0%E5%B0%84&amp;action=edit&amp;section=5" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>光照空间坐标</span></h4>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 152px"><a class=image title=投影到场景的深度图的可见性 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:4overmap.png'))"><img class=thumbimage height=120 alt=投影到场景的深度图的可见性 src="http://upload.wikimedia.org/wikipedia/zh/thumb/9/9c/4overmap.png/150px-4overmap.png" width=150 border=0></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=放大 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:4overmap.png'))"><img height=11 alt="" src="http://zh.wikipedia.org/skins-1.5/common/images/magnify-clip.png" width=15></a></div>
投影到场景的深度图的可见性</div>
</div>
</div>
<p>为了将物体点与深度图进行比较，物体在场景坐标系中的位置必须要转换到光照空间中的对应位置，这个变换可以用<a title=矩陣乘法 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%9F%A9%E9%99%A3%E4%B9%98%E6%B3%95'))">矩阵乘法</a>实现。物体在屏幕上的位置可以通过普通的<a title=坐标变换 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%9D%90%E6%A0%87%E5%8F%98%E6%8D%A2'))">坐标变换</a>确定，但是必须要生成第二套坐标来定位物体在光照空间中的位置。</p>
<p>将世界坐标系变换到光照空间坐标系的变换矩阵与第一步中用于渲染阴影图的变换矩阵相同，在<a title=OpenGL href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/OpenGL'))">OpenGL</a>中它是模型视图与投影矩阵之积。这样就生成一组<a title=齐次坐标 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E9%BD%90%E6%AC%A1%E5%9D%90%E6%A0%87'))">齐次坐标</a>，如果可见的话经过透视除法（perspective division）转换成<em>归一化设备坐标</em>，每个分量（<em>x</em>、<em>y</em>、<em>z</em>）都落在 -1 到 1 之间。有许多的实现方法要进行另外的<em>缩放及偏移</em>矩阵乘法将 -1 到 1 之间的数值转换到深度图或纹理图中更常用的 0 到 1 之间的数值。这个缩放过程也可以在透视除法之前完成，并且可以通过那个矩阵与下面的矩阵相乘很容易地将前面的变换计算融合到一起： <img class=tex alt="\begin{bmatrix}&#10;0.5 &amp; 0 &amp; 0 &amp; 0.5 \\&#10;0 &amp; 0.5 &amp; 0 &amp; 0.5 \\&#10;0 &amp; 0 &amp; 0.5 &amp; 0.5 \\&#10;0 &amp; 0 &amp; 0 &amp; 1 \end{bmatrix}" src="http://www.gollumbrowser.com/tc/math/7/c/e/7ced35c6602473fc2f64bac729fe45f1.png"></p>
<p>如果使用<a class=new title=Shader href="http://zh.wikipedia.org/w/index.php?title=Shader&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">shader</a>或者其它的图形硬件扩展完成这项工作的话，那么通常在顶点级进行这样的变换，生成的数值在其它定点之间进行插值，然后传递到片断处理的部分。</p>
<p><a name=.E6.B7.B1.E5.BA.A6.E5.9B.BE.E6.A3.80.E9.AA.8C></a></p>
<h4><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E9%98%B4%E5%BD%B1%E6%98%A0%E5%B0%84&amp;action=edit&amp;section=6" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>深度图检验</span></h4>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 152px"><a class=image title=深度图检验失败 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:5failed.png'))"><img class=thumbimage height=120 alt=深度图检验失败 src="http://upload.wikimedia.org/wikipedia/zh/thumb/e/e2/5failed.png/150px-5failed.png" width=150 border=0></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=放大 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:5failed.png'))"><img height=11 alt="" src="http://zh.wikipedia.org/skins-1.5/common/images/magnify-clip.png" width=15></a></div>
深度图检验失败</div>
</div>
</div>
<p>找到光照空间的坐标之后，<em>x</em> 与 <em>y</em> 通常对应于深度图纹理的位置，<em>z</em> 对应于相应的深度，这样就可以与深度图进行比较。</p>
<p>如果 <em>z</em> 大于深度图中相应位置保存的数值，那么就认为物体被其它物体所遮挡，这个点就标记为<em>失败</em>，在绘制过程中将它描绘成阴影状态；否则的话，就将它绘制成照亮状态。</p>
<p>如果位置落在深度图之外，那么程序就需要确定表面要用缺省的照亮或者阴影方式绘制，通常是绘制成照亮的状态。</p>
<p>在 <a class=new title=Shader href="http://zh.wikipedia.org/w/index.php?title=Shader&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">shader</a> 的实现中，这个过程是在片断层次完成的。另外，当选择硬件所用的纹理图存储类型的时候需要注意：如果无法进行插值，那么阴影将会出现明显的锯齿边界，可以通过使用较高的阴影图分辨率来减少这种现象。</p>
<p>根据与阴影边界的接近程度使用一个取值范围而不是简单的通过或者失败，通过这样的修改就可以实现更加平滑的阴影边界。</p>
<p>阴影映射技术也可以经过修改用于在照亮区域生成纹理，这样就可以模拟<a class=new title=投影机 href="http://zh.wikipedia.org/w/index.php?title=%E6%8A%95%E5%BD%B1%E6%9C%BA&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">投影机</a>的效果。上面标题为&#8220;投影到场景中的深度图的可见性&#8221;的图片就是这样的一个例子。</p>
<p><a name=.E7.BB.98.E5.88.B6.E5.9C.BA.E6.99.AF></a></p>
<h4><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E9%98%B4%E5%BD%B1%E6%98%A0%E5%B0%84&amp;action=edit&amp;section=7" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>绘制场景</span></h4>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 152px"><a class=image title=带有环境光的最终渲染场景 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:7fin.png'))"><img class=thumbimage height=120 alt=带有环境光的最终渲染场景 src="http://upload.wikimedia.org/wikipedia/zh/thumb/3/32/7fin.png/150px-7fin.png" width=150 border=0></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=放大 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:7fin.png'))"><img height=11 alt="" src="http://zh.wikipedia.org/skins-1.5/common/images/magnify-clip.png" width=15></a></div>
带有环境光的最终渲染场景</div>
</div>
</div>
<p>带有阴影的场景的可以通过几种不同的方法进行绘制。如果有可用的可编程 <a class=new title=Shader href="http://zh.wikipedia.org/w/index.php?title=Shader&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">shader</a>，深度图检验可以用碎片 shader 完成。在最初的生成阴影图之后，它一次就可以根据结果完成阴影或者被照亮物体的绘制。</p>
<p>如果没有可以使用的阴影工具，通常必须使用一些硬件扩展如 <a class="external text" title=http://www.opengl.org/registry/specs/ARB/shadow.txt href="http://www.opengl.org/registry/specs/ARB/shadow.txt" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><em>GL_ARB_shadow</em></a> 等进行阴影图检验，它们通常不允许在两个光照模型之间进行选择，并且需要更多的渲染过程：</p>
<ol>
    <li>将整个场景渲染到阴影。对于大多数的光照模型（参见<a class=new title=Phong反射模型 href="http://zh.wikipedia.org/w/index.php?title=Phong%E5%8F%8D%E5%B0%84%E6%A8%A1%E5%9E%8B&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Phong反射模型</a>）来说，在技术上仅仅使用光照中的环境光成分就可以完成，但是通常加入一个模糊的漫射光使得阴影中平坦的表面看起来有一定的弧度。</li>
    <li>使用深度图检验，然后渲染照亮的场景。深度图检验失败的区域不要覆盖，仍然保持在阴影状态。</li>
    <li>对于每一个额外的光照都可能需要额外的处理过程，用加性<a title=阿尔法通道 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E9%98%BF%E5%B0%94%E6%B3%95%E9%80%9A%E9%81%93'))">混合</a>方法它们的效果与已经绘制的效果合成在一起。每个这样的过程都需要前面的生成相应阴影图的过程。</li>
</ol>
<p>这篇文章中的例图是使用 <a title=OpenGL href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/OpenGL'))">OpenGL</a> 的扩展 <a class="external text" title=http://www.opengl.org/registry/specs/ARB/shadow_ambient.txt href="http://www.opengl.org/registry/specs/ARB/shadow_ambient.txt" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><em>GL_ARB_shadow_ambient</em></a> 完成阴影映射过程的。</p>
<p><a name=.E5.8F.82.E8.A7.81></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E9%98%B4%E5%BD%B1%E6%98%A0%E5%B0%84&amp;action=edit&amp;section=8" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>参见</span></h2>
<ul>
    <li><a title=阴影体 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E9%98%B4%E5%BD%B1%E4%BD%93'))">阴影体</a>，另外一种阴影技术</li>
    <li><a class=new title=光线投射 href="http://zh.wikipedia.org/w/index.php?title=%E5%85%89%E7%BA%BF%E6%8A%95%E5%B0%84&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">光线投射</a>，<a title=光线跟踪 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%85%89%E7%BA%BF%E8%B7%9F%E8%B8%AA'))">光线跟踪</a>中经常使用的一种速度较慢的技术</li>
    <li><a class=new title="Photon mapping" href="http://zh.wikipedia.org/w/index.php?title=Photon_mapping&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Photon mapping</a>，一种速度较慢、能够实现非常真实的光照的技术</li>
    <li><a title=辐射着色 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%BE%90%E5%B0%84%E7%9D%80%E8%89%B2'))">辐射着色</a>，另外一种速度很慢，但真实感非常好的技术</li>
</ul>
<p><a name=.E5.A4.96.E9.83.A8.E9.93.BE.E6.8E.A5></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E9%98%B4%E5%BD%B1%E6%98%A0%E5%B0%84&amp;action=edit&amp;section=9" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>外部链接</span></h2>
<ul>
    <li><a class="external text" title=http://developer.nvidia.com/attach/8456 href="http://developer.nvidia.com/attach/8456" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">硬件阴影映射</a>, <a title=NVIDIA href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/NVIDIA'))">nVidia</a></li>
    <li><a class="external text" title=http://developer.nvidia.com/attach/6769 href="http://developer.nvidia.com/attach/6769" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">当今 OpenGL 硬件的阴影映射</a>, nVidia</li>
</ul>
</div>
<img src ="http://www.cppblog.com/yaoming/aggbug/40129.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/yaoming/" target="_blank">姚明</a> 2008-01-01 08:26 <a href="http://www.cppblog.com/yaoming/archive/2008/01/01/40129.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>阴影体</title><link>http://www.cppblog.com/yaoming/archive/2008/01/01/40128.html</link><dc:creator>姚明</dc:creator><author>姚明</author><pubDate>Tue, 01 Jan 2008 00:25:00 GMT</pubDate><guid>http://www.cppblog.com/yaoming/archive/2008/01/01/40128.html</guid><wfw:comment>http://www.cppblog.com/yaoming/comments/40128.html</wfw:comment><comments>http://www.cppblog.com/yaoming/archive/2008/01/01/40128.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/yaoming/comments/commentRss/40128.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/yaoming/services/trackbacks/40128.html</trackback:ping><description><![CDATA[<h1 class=firstHeading>阴影体</h1>
<div id=bodyContent>
<h3 id=siteSub>&nbsp;</h3>
<div id=contentSub></div>
<p><strong>阴影体（阴影锥）</strong>是<a title=三维计算机图形 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E4%B8%89%E7%BB%B4%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9B%BE%E5%BD%A2'))"><u><font color=#0000ff>三维计算机图形</font></u></a>中所使用的一种技术，始于1977年，用于在绘制的场景中加入阴影。它通常被认为是现代三维图形硬件的能力下的最实用的通用实时阴影系统之一，并已随着<a title=毁灭战士3 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%AF%81%E7%81%AD%E6%88%98%E5%A3%AB3'))"><u><font color=#0000ff>毁灭战士3</font></u></a>而流行开来。</p>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 401px"><a class=image title=图1.阴影体示意图 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Shadow-volumes.png'))"><img class=thumbimage height=365 alt=图1.阴影体示意图 src="http://upload.wikimedia.org/wikipedia/zh/0/09/Shadow-volumes.png" width=399 border=0></a>
<div class=thumbcaption>图1.阴影体示意图</div>
</div>
</div>
<p>阴影体将虚拟世界分成两部分；在某光源的阴影中的部分和不在阴影中的部分。</p>
<table class=toc id=toc summary=目录>
    <tbody>
        <tr>
            <td>
            <div id=toctitle>
            <h2>目录</h2>
            </div>
            <ul>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E6.9E.84.E9.80.A0"><font color=#800080><u><span class=tocnumber>1</span><span class=toctext>构造</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E7.94.A8.E6.B3.95"><font color=#800080><u><span class=tocnumber>2</span><span class=toctext>用法</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.8F.82.E7.9C.8B"><font color=#800080><u><span class=tocnumber>3</span><span class=toctext>参看</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.A4.96.E9.83.A8.E9.93.BE.E6.8E.A5"><u><font color=#800080><span class=tocnumber>4</span><span class=toctext>外部链接</span></font></u></a></li>
            </ul>
            </td>
        </tr>
    </tbody>
</table>
<p><a name=.E6.9E.84.E9.80.A0><u><font color=#800080></font></u></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E9%98%B4%E5%BD%B1%E4%BD%93&amp;action=edit&amp;section=1" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>构造</span></h2>
<p>要构造一个阴影体，先从光源投射一条射线穿过产生阴影的物体中的每个顶点到某个点（通常在无穷远点）。这些射线一起组成一个体；每个该体中的点都在阴影中，所有在外部的物体被该光源照亮。</p>
<p>实际的阴影体如下计算：</p>
<ul>
    <li>找到所有的<a class=new title=轮廓边 href="http://zh.wikipedia.org/w/index.php?title=%E8%BD%AE%E5%BB%93%E8%BE%B9&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>轮廓边</font></u></a>（将前向面和后向面隔开的边）</li>
    <li>将所有的轮廓边向远离光源的方向伸展形成一个四边形。</li>
    <li>加入<em>前盖</em>和<em>后盖</em>到这些表面上形成一个闭合体（不是必要的，是否采用取决于所采用的实现方法）</li>
</ul>
<p><a name=.E7.94.A8.E6.B3.95></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E9%98%B4%E5%BD%B1%E4%BD%93&amp;action=edit&amp;section=2" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>用法</span></h2>
<p>当前的研究和实现方法侧重于使用硬件的<a class=new title=模版缓存 href="http://zh.wikipedia.org/w/index.php?title=%E6%A8%A1%E7%89%88%E7%BC%93%E5%AD%98&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>模版缓存</font></u></a>（stencil buffer）来优化算法以利用硬件加速 - 参看<a class=new title=模版阴影体 href="http://zh.wikipedia.org/w/index.php?title=%E6%A8%A1%E7%89%88%E9%98%B4%E5%BD%B1%E4%BD%93&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>模版阴影体</font></u></a>。</p>
<p>为测试绘制的图像的给定像素是否在阴影中，阴影体本身需要被绘制，但它是绘制到模板缓存，而不是最终的图像中。对于每个阴影体中的前向面，模板缓存中的值是增加的；对于后向面，它是减少的。</p>
<p>一旦所有阴影体中的面被绘制到模版缓存，任何值非零的像素将处于阴影中。</p>
<p>要理解其原因，考虑从像素到屏幕的光线反向回到物体的射线 - 若它穿入阴影体，它将会穿过一个前向面，所以模版缓存对应像素的值会增加。若它又穿出阴影体（通过一个后向面）该值将会再次减少。</p>
<p>但是如果该像素在阴影中则该值只在它从后面离开阴影体时被减少，所以该值非零。</p>
<p>图1显示了一个包含一个镜头，一个光源，一个阴影产生物体（蓝色圆圈）和三个阴影接受物体（绿色的方块），全部用二维示意。粗黑线表示阴影体的轮廓。从相机（笑脸）投射的线表示视线。</p>
<p>该视线首先击中物体a；在该点它没有达到阴影体的任何面，所以帧缓存会有0值 - 不在阴影中。在点1阴影体的一个前向面被穿过因而增加了模版缓存中的值。然后我们击中物体b;在该点我们在缓存中有一个值为1，所以该物体在阴影中。沿着视线继续前进，我们会在点2到达阴影体的后向面，因而把模版缓存中的值减少到0。最后我们击中物体c，模版缓存中的值又是0，所以该物体也不在阴影中。</p>
<p>该算法的一个问题在于若相机（眼睛）本身在阴影体中则该方法回失败 - 视线首先穿过阴影体的后向面，将模版缓存中的值减少1，使得它在到达物体c的时候有非零值，虽然该物体不应该在阴影中。</p>
<p>这个问题的一个解决办法是从无穷远的某点返回到相机。该技术由一些人独立发现，但是由<a class=new title="John Carmack" href="http://zh.wikipedia.org/w/index.php?title=John_Carmack&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>John Carmack</font></u></a>推广，并经常被称为<a class=new title=Carmack的翻转 href="http://zh.wikipedia.org/w/index.php?title=Carmack%E7%9A%84%E7%BF%BB%E8%BD%AC&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Carmack的翻转</font></u></a>。</p>
<p><a name=.E5.8F.82.E7.9C.8B></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E9%98%B4%E5%BD%B1%E4%BD%93&amp;action=edit&amp;section=3" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>参看</span></h2>
<ul>
    <li><a class=new title=模版阴影体 href="http://zh.wikipedia.org/w/index.php?title=%E6%A8%A1%E7%89%88%E9%98%B4%E5%BD%B1%E4%BD%93&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>模版阴影体</font></u></a>，描述了如何使用<em>模版缓存</em>实现阴影体算法</li>
    <li><a class=new title=轮廓边 href="http://zh.wikipedia.org/w/index.php?title=%E8%BD%AE%E5%BB%93%E8%BE%B9&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><font color=#0000ff><u>轮廓边</u></font></a></li>
    <li><a title=阴影映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E9%98%B4%E5%BD%B1%E6%98%A0%E5%B0%84'))"><u><font color=#0000ff>阴影映射</font></u></a>，一个较简单的技术</li>
</ul>
<p><a name=.E5.A4.96.E9.83.A8.E9.93.BE.E6.8E.A5></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E9%98%B4%E5%BD%B1%E4%BD%93&amp;action=edit&amp;section=4" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>外部链接</span></h2>
<ul>
    <li><a class="external free" title=http://www.gamedev.net/reference/articles/article1873.asp href="http://www.gamedev.net/reference/articles/article1873.asp" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>http://www.gamedev.net/reference/articles/article1873.asp</font></u></a> - 一篇优秀的介绍文章</li>
    <li><a class="external free" title=http://www.gamedev.net/reference/articles/article2036.asp href="http://www.gamedev.net/reference/articles/article2036.asp" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>http://www.gamedev.net/reference/articles/article2036.asp</font></u></a> - 基本算法的另一解释</li>
    <li><a class="external free" title=http://developer.nvidia.com/object/fast_shadow_volumes.html href="http://developer.nvidia.com/object/fast_shadow_volumes.html" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><font color=#0000ff><u>http://developer.nvidia.com/object/fast_shadow_volumes.html</u></font></a></li>
    <li><a class="external free" title=http://developer.nvidia.com/object/robust_shadow_volumes.html href="http://developer.nvidia.com/object/robust_shadow_volumes.html" target=_blank rel=nofollow><font color=#0000ff><u><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">http://developer.nvidia.com/object/robust_shadow_volumes.html</u></font></a></li>
    <li><a class="external free" title=http://www.sgi.com/software/opengl/advanced96/node48.html href="http://www.sgi.com/software/opengl/advanced96/node48.html" target=_blank rel=nofollow><u><font color=#0000ff><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">http://www.sgi.com/software/opengl/advanced96/node48.html</font></u></a></li>
</ul>
</div>
<img src ="http://www.cppblog.com/yaoming/aggbug/40128.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/yaoming/" target="_blank">姚明</a> 2008-01-01 08:25 <a href="http://www.cppblog.com/yaoming/archive/2008/01/01/40128.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>高动态范围成像</title><link>http://www.cppblog.com/yaoming/archive/2008/01/01/40116.html</link><dc:creator>姚明</dc:creator><author>姚明</author><pubDate>Mon, 31 Dec 2007 23:44:00 GMT</pubDate><guid>http://www.cppblog.com/yaoming/archive/2008/01/01/40116.html</guid><wfw:comment>http://www.cppblog.com/yaoming/comments/40116.html</wfw:comment><comments>http://www.cppblog.com/yaoming/archive/2008/01/01/40116.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/yaoming/comments/commentRss/40116.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/yaoming/services/trackbacks/40116.html</trackback:ping><description><![CDATA[<h1 class=firstHeading>高动态范围成像</h1>
<div id=bodyContent>
<h3 id=siteSub>&nbsp;</h3>
<div id=contentSub></div>
<p>在<a title=计算机图形学 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9B%BE%E5%BD%A2%E5%AD%A6'))"><u><font color=#0000ff>计算机图形学</font></u></a>与<a class=new title=电影摄影术 href="http://zh.wikipedia.org/w/index.php?title=%E7%94%B5%E5%BD%B1%E6%91%84%E5%BD%B1%E6%9C%AF&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>电影摄影术</font></u></a>中，<strong>高动态范围成像</strong>是用来实现比普通数字图像技术更大曝光<a class=new title=动态范围 href="http://zh.wikipedia.org/w/index.php?title=%E5%8A%A8%E6%80%81%E8%8C%83%E5%9B%B4&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>动态范围</font></u></a>（即更大的明暗差别）的一组技术。高动态范围成像的目的就是要正确地表示真实世界中从太阳光直射到最暗的阴影这样大的范围亮度。</p>
<p>高动态范围成像最初只用于纯粹由计算机生成的图像。后来，人们开发出了一些从不同曝光范围照片中生成高动态范围图像的方法。随着<a title=数码相机 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%95%B0%E7%A0%81%E7%9B%B8%E6%9C%BA'))"><u><font color=#0000ff>数码相机</font></u></a>的日渐流行以及桌面软件变得易于使用，许多业余摄影师使用高动态范围成像的方法生成高动态范围场景的照片，但是，不要将这作为它唯一的用途，实际上高动态范围还有许多其它的应用。</p>
<p>当用于显示的时候，高动态范围图像经常要进行<a title=色调映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%89%B2%E8%B0%83%E6%98%A0%E5%B0%84'))"><u><font color=#0000ff>色调映射</font></u></a>，并且要与其它几种<a class=new title=全屏显示效果 href="http://zh.wikipedia.org/w/index.php?title=%E5%85%A8%E5%B1%8F%E6%98%BE%E7%A4%BA%E6%95%88%E6%9E%9C&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>全屏显示效果</font></u></a>（full screen effect）一起使用。</p>
<table class=toc id=toc summary=目录>
    <tbody>
        <tr>
            <td>
            <div id=toctitle>
            <h2>目录</h2>
            </div>
            <ul>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.8E.86.E5.8F.B2"><font color=#800080><u><span class=tocnumber>1</span><span class=toctext>历史</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E4.B8.8E.E4.BC.A0.E7.BB.9F.E6.95.B0.E5.AD.97.E5.9B.BE.E5.83.8F.E7.9A.84.E6.AF.94.E8.BE.83"><font color=#800080><u><span class=tocnumber>2</span><span class=toctext>与传统数字图像的比较</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.9B.BE.E5.83.8F.E6.9D.A5.E6.BA.90"><font color=#800080><u><span class=tocnumber>3</span><span class=toctext>图像来源</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E8.89.B2.E8.B0.83.E6.98.A0.E5.B0.84"><font color=#800080><u><span class=tocnumber>4</span><span class=toctext>色调映射</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E4.BE.8B.E5.AD.90"><font color=#800080><u><span class=tocnumber>5</span><span class=toctext>例子</span></u></font></a>
                <ul>
                    <li class=toclevel-2><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E6.9B.9D.E5.85.89"><font color=#800080><u><span class=tocnumber>5.1</span><span class=toctext>曝光</span></u></font></a></li>
                    <li class=toclevel-2><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E6.A8.A1.E7.B3.8A"><font color=#800080><u><span class=tocnumber>5.2</span><span class=toctext>模糊</span></u></font></a></li>
                </ul>
                </li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.85.B6.E4.BB.96.E4.BE.8B.E5.AD.90"><font color=#800080><u><span class=tocnumber>6</span><span class=toctext>其他例子</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.8F.82.E8.80.83.E6.96.87.E7.8C.AE"><font color=#800080><u><span class=tocnumber>7</span><span class=toctext>参考文献</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.8F.82.E8.A7.81"><font color=#800080><u><span class=tocnumber>8</span><span class=toctext>参见</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.A4.96.E9.83.A8.E9.93.BE.E6.8E.A5"><font color=#800080><u><span class=tocnumber>9</span><span class=toctext>外部链接</span></u></font></a>
                <ul>
                    <li class=toclevel-2><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E6.91.84.E5.BD.B1"><font color=#800080><u><span class=tocnumber>9.1</span><span class=toctext>摄影</span></u></font></a></li>
                    <li class=toclevel-2><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E9.AB.98.E5.8A.A8.E6.80.81.E8.8C.83.E5.9B.B4.E6.98.BE.E7.A4.BA"><font color=#800080><u><span class=tocnumber>9.2</span><span class=toctext>高动态范围显示</span></u></font></a></li>
                    <li class=toclevel-2><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#On_rendering"><u><font color=#800080><span class=tocnumber>9.3</span><span class=toctext>On rendering</span></font></u></a></li>
                </ul>
                </li>
            </ul>
            </td>
        </tr>
    </tbody>
</table>
<p><a name=.E5.8E.86.E5.8F.B2><u><font color=#800080></font></u></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E9%AB%98%E5%8A%A8%E6%80%81%E8%8C%83%E5%9B%B4%E6%88%90%E5%83%8F&amp;action=edit&amp;section=1" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>历史</span></h2>
<p>在计算机图形学中开创高动态范围成像的先驱是 <a class=new title="Paul Debevec" href="http://zh.wikipedia.org/w/index.php?title=Paul_Debevec&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Paul Debevec</font></u></a>，据说 Debevec 是第一个使用高动态范围成像图生成计算机图像以逼真地对计算机图形物体进行照明与动画处理。<sup class="noprint Template-Fact"><a title=Wikipedia:列明來源 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Wikipedia:%E5%88%97%E6%98%8E%E4%BE%86%E6%BA%90'))"><span title=来源请求开始于2007年7月16日。><span style="WHITE-SPACE: nowrap"><u><font color=#0000ff>[來源請求]</font></u></span></span></a></sup>人们普遍认为 Gregory Ward 是高动态范围成像文件格式的奠基人。<sup class="noprint Template-Fact"><a title=Wikipedia:列明來源 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Wikipedia:%E5%88%97%E6%98%8E%E4%BE%86%E6%BA%90'))"><span title=来源请求开始于2007年7月16日。><span style="WHITE-SPACE: nowrap"><u><font color=#0000ff>[來源請求]</font></u></span></span></a></sup></p>
<p><a name=.E4.B8.8E.E4.BC.A0.E7.BB.9F.E6.95.B0.E5.AD.97.E5.9B.BE.E5.83.8F.E7.9A.84.E6.AF.94.E8.BE.83><u><font color=#0000ff></font></u></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E9%AB%98%E5%8A%A8%E6%80%81%E8%8C%83%E5%9B%B4%E6%88%90%E5%83%8F&amp;action=edit&amp;section=2" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>与传统数字图像的比较</span></h2>
<p>通常保存在高动态范围图像中的信息对应于真实世界可以观察到的<a title=亮度 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E4%BA%AE%E5%BA%A6'))"><u><font color=#0000ff>亮度</font></u></a>（luminance）或者<a class=new title=Radiance href="http://zh.wikipedia.org/w/index.php?title=Radiance&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>radiance</font></u></a>值，这与传统的<a title=数字图像 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%95%B0%E5%AD%97%E5%9B%BE%E5%83%8F'))"><u><font color=#800080>数字图像</font></u></a>保存的在显示器或者打印纸上显示的颜色不同。所以，高动态范围图像格式也经常成为&#8220;与场景相关&#8221;，以区别于传统的&#8220;与设备相关&#8221;或者&#8220;与输出相关&#8221;的数字图像。另外，传统图像通常经常针对人类<a title=视觉系统 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%A7%86%E8%A7%89%E7%B3%BB%E7%BB%9F'))"><u><font color=#0000ff>视觉系统</font></u></a>进行编码（最大化保存在固定数据位中的可视信息），这些编码通常称作&#8220;伽玛编码&#8221;或者&#8220;<a class=new title="Gamma 校正" href="http://zh.wikipedia.org/w/index.php?title=Gamma_%E6%A0%A1%E6%AD%A3&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>gamma 校正</font></u></a>&#8221;。保存在高动态范围图像中的数据经常是<a title=線性 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%B7%9A%E6%80%A7'))"><u><font color=#0000ff>线性</font></u></a>的，这就意味着它们表示亮度或者radiance 的相对或者绝对值（gamma 1.0）。</p>
<p>高动态范围图像每个颜色通道需要比传统图像更多的数据位，这是因为它的线性编码以及需要表示从 <span class=texhtml>10 <sup>&#8722; 4</sup></span> 到 <span class=texhtml>10<sup>8</sup></span> 人眼可见亮度范围甚至是更大范围的数值。经常使用 16 位&#8220;<a class=new title="Half precision" href="http://zh.wikipedia.org/w/index.php?title=Half_precision&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>half precision</font></u></a>&#8221;或者 32 位<a title=浮点数 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%B5%AE%E7%82%B9%E6%95%B0'))"><u><font color=#0000ff>浮点数</font></u></a>表示高动态范围像素。但是，如果使用合适的<a title=传递函数 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E4%BC%A0%E9%80%92%E5%87%BD%E6%95%B0'))"><u><font color=#0000ff>传递函数</font></u></a>进行变换，一些应用中的高动态范围像素可以用 10-12 位表示亮度，用 8 位表示<a title=色度 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%89%B2%E5%BA%A6'))"><u><font color=#0000ff>色度</font></u></a>，并且不会带来任何可见的量化误差<sup class=reference id=_ref-0><a title="" href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#_note-0"><u><font color=#800080>[1]</font></u></a></sup><sup class=reference id=_ref-1><a title="" href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#_note-1"><u><font color=#800080>[2]</font></u></a></sup>。</p>
<p><a name=.E5.9B.BE.E5.83.8F.E6.9D.A5.E6.BA.90></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E9%AB%98%E5%8A%A8%E6%80%81%E8%8C%83%E5%9B%B4%E6%88%90%E5%83%8F&amp;action=edit&amp;section=3" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>图像来源</span></h2>
<p>高动态范围图像最初使用不同的<a class=new title=渲染工具 href="http://zh.wikipedia.org/w/index.php?title=%E6%B8%B2%E6%9F%93%E5%B7%A5%E5%85%B7&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>渲染工具</font></u></a>生成，其中著名的一个是 <a class=new title=Radiance href="http://zh.wikipedia.org/w/index.php?title=Radiance&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Radiance</font></u></a> 。由于所使用单位都是基于如 <a title=瓦 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%93%A6'))"><u><font color=#0000ff>瓦</font></u></a>/<a title=球面度 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%90%83%E9%9D%A2%E5%BA%A6'))"><u><font color=#0000ff>球面度</font></u></a>/<a title=米 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%B1%B3'))"><u><font color=#0000ff>米</font></u></a><sup>2</sup> 这样的实际物理单位，所以这种方法可以实现更加逼真的模型场景表现。这种方法可以模拟真实场景的光照，以及利用这个结果选择照明（假设几何形状、照明以及材料都是真实场景的精确表现）。</p>
<p>在 <a title=1997年 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/1997%E5%B9%B4'))"><u><font color=#0000ff>1997年</font></u></a> 的 <a title=SIGGRAPH href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/SIGGRAPH'))"><u><font color=#0000ff>SIGGRAPH</font></u></a> 上，Paul Debevec 提交了题为&#8220;从照片中恢复高动态范围辐射图&#8221;的论文。这篇论文描述了按照不同的曝光设置对同一个场景进行拍照，然后将这些采用不同曝光的照片组合成高动态范围图像。这种高动态范围图像可以捕捉从黑暗的阴影到亮光源或者高反光的更大动态范围的场景。</p>
<p>在 SIGGRAPH '98 一年之后，Debevec 又提交了一篇论文&#8220;将人造物体渲染成真实场景：沟通基于图像的传统图形与全局照明以及高动态范围照片&#8221;。在这篇论文中，他使用以前的技术对光滑的铬球照相以生成他所称作的&#8220;light probe&#8221;，即本质上的高动态范围<a class=new title=环境图 href="http://zh.wikipedia.org/w/index.php?title=%E7%8E%AF%E5%A2%83%E5%9B%BE&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>环境图</font></u></a>。然后将这个 light probe 用于合成场景的渲染。与普通的环境图简单地提供反射或者折射信息不同，light probe 还提供了场景中的照明，实际上，这是唯一的光源。这种方法实现了一种前所未有的真实感效果，为整体照明模型提供了真实世界的照明数据。</p>
<p><a name=.E8.89.B2.E8.B0.83.E6.98.A0.E5.B0.84></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E9%AB%98%E5%8A%A8%E6%80%81%E8%8C%83%E5%9B%B4%E6%88%90%E5%83%8F&amp;action=edit&amp;section=4" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>色调映射</span></h2>
<dl>
<dd>
<div class=noprint style="FONT-SIZE: small">主条目：<a title=色调映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%89%B2%E8%B0%83%E6%98%A0%E5%B0%84'))"><u><font color=#0000ff>色调映射</font></u></a></div>
</dd></dl>
<p>在查看高动态范围图像的时候经总是会遇到一个问题，CRT、LCD、打印机以及其它图像显示方法只能显示有限动态范围的图像。因此，人们开发了各种将高动态范围图像&#8220;转换&#8221;成可以查看的图像的方法，这些方法统称为&#8220;色调映射&#8221;。</p>
<p>早期的色调映射非常简单，这些方法设置一个动态范围窗口，按照最大值、最小值对图像进行裁剪。最近出现的方法试图显示更大的动态范围，一些更加复杂的方法已经在研究人眼及视神经感知场景的机制，并且争取在保持真实的颜色与对比度前提下显示全部的动态范围。</p>
<p><a name=.E4.BE.8B.E5.AD.90></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E9%AB%98%E5%8A%A8%E6%80%81%E8%8C%83%E5%9B%B4%E6%88%90%E5%83%8F&amp;action=edit&amp;section=5" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>例子</span></h2>
<p>一些图像实例可以用来帮助说明高动态范围成像的用途。下面的实例所用的图片是用 <a class=new title=Uffizi href="http://zh.wikipedia.org/w/index.php?title=Uffizi&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Uffizi</font></u></a> 图库中著名的 <a class=new title="Paul Debevec" href="http://zh.wikipedia.org/w/index.php?title=Paul_Debevec&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Paul Debevec</font></u></a> 光探头在 <a class=new title=Radiance href="http://zh.wikipedia.org/w/index.php?title=Radiance&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Radiance</font></u></a> 中渲染生成。</p>
<p><a name=.E6.9B.9D.E5.85.89></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E9%AB%98%E5%8A%A8%E6%80%81%E8%8C%83%E5%9B%B4%E6%88%90%E5%83%8F&amp;action=edit&amp;section=6" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>曝光</span></h3>
<div class=center>
<div class="thumb tnone">
<div class=thumbinner style="WIDTH: 182px"><a class=new title="Image:HDR example - exposure.jpeg" href="javascript:void(wb.w._link('http://zh.wikipedia.org/w/index.php?title=Special:Upload&amp;wpDestFile=HDR_example_-_exposure.jpeg'))"><u><font color=#0000ff>Image:HDR example - exposure.jpeg</font></u></a>
<div class=thumbcaption>同一幅图像的三种不同曝光效果</div>
</div>
</div>
</div>
<p>在将高动态范围图像通过色调映射生成用于显示的低动态范围图像的过程中，通过调整曝光展示了高动态范围图像。中间的曝光是所期望的曝光，也最有可能是场景正常显示的效果。左侧较暗图像使用<a title=光圈 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%85%89%E5%9C%88'))"><u><font color=#0000ff>光圈</font></u></a> 4 曝光，只能显示天空较亮云彩的一些细节。右侧较亮图像使用光圈 3 曝光，可以显示场景中较暗的部分。</p>
<p><a name=.E6.A8.A1.E7.B3.8A></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E9%AB%98%E5%8A%A8%E6%80%81%E8%8C%83%E5%9B%B4%E6%88%90%E5%83%8F&amp;action=edit&amp;section=7" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>模糊</span></h3>
<div class=center>
<div class="thumb tnone">
<div class=thumbinner style="WIDTH: 182px"><a class=new title="Image:HDR example-gauss blur.jpeg" href="javascript:void(wb.w._link('http://zh.wikipedia.org/w/index.php?title=Special:Upload&amp;wpDestFile=HDR_example-gauss_blur.jpeg'))"><u><font color=#0000ff>Image:HDR example-gauss blur.jpeg</font></u></a>
<div class=thumbcaption>同一图像的低动态范围与高动态范围高斯模糊</div>
</div>
</div>
</div>
<p>这里的<a title=高斯模糊 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E9%AB%98%E6%96%AF%E6%A8%A1%E7%B3%8A'))"><u><font color=#0000ff>高斯模糊</font></u></a>展示了高动态范围图像中超出取值范围的数值也是有用的，即使它们在转换成低动态范围图像的时候通常都要被裁掉。左侧图像是原始图像首先经过色调映射成的低动态范围版本，然后在<a title=GIMP href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/GIMP'))"><u><font color=#0000ff>GIMP</font></u></a>中进行模糊得到，右侧的图像是原始高动态范围图像在 <tt>pgblur</tt> 中进行模糊，然后经过色调映射得到。</p>
<p>尽管两幅图像非常相似，但是明显的区别就是光滑铬球上的高亮光部分。在原始的高动态范围图像中，这些像素都有非常大的亮度值。当图像模糊的时候，周围的像素亮度被&#8220;拉高&#8221;并且在色度映射时裁剪成最大值，当然高亮像素的亮度也会被周围像素&#8220;拉低&#8221;，但是它们的亮度非常高所以在色度映射的时候仍然要超出最大值。这样的结果就是更大的区域变成了白色。</p>
<p>但是对于低动态范围模糊来说，高亮区域的像素在模糊处理之前已经裁剪成了最大值，这就从总体上大幅度地降低了亮度值。因此，在模糊处理之后，光亮区域周围的像素将不再有非常高的亮度，即使是高亮区域内的像素也由于周围像素的影响而被拉低。这样高亮区域就变得比较模糊，开起来不再非常明亮。</p>
<div class=center>
<div class="thumb tnone">
<div class=thumbinner style="WIDTH: 182px"><a class=new title="Image:HDR example-motion blur.jpeg" href="javascript:void(wb.w._link('http://zh.wikipedia.org/w/index.php?title=Special:Upload&amp;wpDestFile=HDR_example-motion_blur.jpeg'))"><u><font color=#0000ff>Image:HDR example-motion blur.jpeg</font></u></a>
<div class=thumbcaption>同一图像的低动态范围与高动态范围运动模糊</div>
</div>
</div>
</div>
<p>对于常见的<a class=new title=运动模糊 href="http://zh.wikipedia.org/w/index.php?title=%E8%BF%90%E5%8A%A8%E6%A8%A1%E7%B3%8A&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>运动模糊</font></u></a>也是同样的结果。</p>
<p><a name=.E5.85.B6.E4.BB.96.E4.BE.8B.E5.AD.90></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E9%AB%98%E5%8A%A8%E6%80%81%E8%8C%83%E5%9B%B4%E6%88%90%E5%83%8F&amp;action=edit&amp;section=8" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>其他例子</span></h2>
<table class=gallery cellSpacing=0 cellPadding=0>
    <tbody>
        <tr>
            <td>
            <div class=gallerybox style="WIDTH: 155px">
            <div class=thumb style="PADDING-RIGHT: 0pt; PADDING-LEFT: 0pt; PADDING-BOTTOM: 40px; WIDTH: 150px; PADDING-TOP: 40px">
            <div style="MARGIN-LEFT: auto; WIDTH: 120px; MARGIN-RIGHT: auto"><a class=image title="Maria Theresien Platz, Vienna HDR.jpg" href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Maria_Theresien_Platz%2C_Vienna_HDR.jpg'))"><img height=66 alt="" src="http://upload.wikimedia.org/wikipedia/commons/thumb/1/1a/Maria_Theresien_Platz%2C_Vienna_HDR.jpg/120px-Maria_Theresien_Platz%2C_Vienna_HDR.jpg" width=120 border=0></a></div>
            </div>
            <div class=gallerytext>
            <p>奧地利維也納</p>
            <p>&#160;</p>
            </div>
            </div>
            </td>
            <td>
            <div class=gallerybox style="WIDTH: 155px">
            <div class=thumb style="PADDING-RIGHT: 0pt; PADDING-LEFT: 0pt; PADDING-BOTTOM: 33px; WIDTH: 150px; PADDING-TOP: 33px">
            <div style="MARGIN-LEFT: auto; WIDTH: 120px; MARGIN-RIGHT: auto"><a class=image title="Old saint pauls 1.jpg" href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Old_saint_pauls_1.jpg'))"><img height=80 alt="" src="http://upload.wikimedia.org/wikipedia/commons/thumb/6/6e/Old_saint_pauls_1.jpg/120px-Old_saint_pauls_1.jpg" width=120 border=0></a></div>
            </div>
            <div class=gallerytext>
            <p>教堂</p>
            <p>&#160;</p>
            </div>
            </div>
            </td>
        </tr>
    </tbody>
</table>
<p><a name=.E5.8F.82.E8.80.83.E6.96.87.E7.8C.AE></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E9%AB%98%E5%8A%A8%E6%80%81%E8%8C%83%E5%9B%B4%E6%88%90%E5%83%8F&amp;action=edit&amp;section=9" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>参考文献</span></h2>
<ol class=references>
    <li id=_note-0><a title="" href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#_ref-0"><u><font color=#800080>&#8593;</font></u></a>&nbsp;<a class="external text" title=http://www.anyhere.com/gward/hdrenc/hdr_encodings.html href="http://www.anyhere.com/gward/hdrenc/hdr_encodings.html" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>"High Dynamic Range Image Encodings"</font></u></a> by Greg Ward, Anyhere Software</li>
    <li id=_note-1><a title="" href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#_ref-1"><u><font color=#800080>&#8593;</font></u></a>&nbsp;<a class="external text" title=http://www.mpi-sb.mpg.de/resources/hdrvideo/ href="http://www.mpi-sb.mpg.de/resources/hdrvideo/" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>"Perception-motivated High Dynamic Range Video Encoding"</font></u></a> from <a class=new title=Informatik href="http://zh.wikipedia.org/w/index.php?title=Informatik&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Informatik</font></u></a></li>
</ol>
<p><a name=.E5.8F.82.E8.A7.81><u><font color=#0000ff></font></u></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E9%AB%98%E5%8A%A8%E6%80%81%E8%8C%83%E5%9B%B4%E6%88%90%E5%83%8F&amp;action=edit&amp;section=10" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>参见</span></h2>
<ul>
    <li><a title=高动态光照渲染 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E9%AB%98%E5%8A%A8%E6%80%81%E5%85%89%E7%85%A7%E6%B8%B2%E6%9F%93'))"><u><font color=#0000ff>高動態光照渲染</font></u></a>（用高动态范围照明计算渲染虚拟场景，尤其是在计算机游戏场合）</li>
    <li><a class=new title=OpenEXR href="http://zh.wikipedia.org/w/index.php?title=OpenEXR&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><font color=#0000ff><u>OpenEXR</u></font></a></li>
    <li><a class=new title=Radiance href="http://zh.wikipedia.org/w/index.php?title=Radiance&amp;action=edit" target=_blank><u><font color=#0000ff><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Radiance</font></u></a> 及其文件格式</li>
    <li><a class=new title="Logluv TIFF" href="http://zh.wikipedia.org/w/index.php?title=Logluv_TIFF&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Logluv TIFF</font></u></a> 文件格式</li>
    <li><a class=new title=CinePaint href="http://zh.wikipedia.org/w/index.php?title=CinePaint&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>CinePaint</font></u></a> 图像编辑器</li>
    <li><a class=new title="Pixel image editor" href="http://zh.wikipedia.org/w/index.php?title=Pixel_image_editor&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><font color=#0000ff><u>Pixel image editor</u></font></a></li>
    <li><a class=new title=Panoscan href="http://zh.wikipedia.org/w/index.php?title=Panoscan&amp;action=edit" target=_blank><font color=#0000ff><u><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Panoscan</u></font></a></li>
    <li><a class=new title=VectorWorks href="http://zh.wikipedia.org/w/index.php?title=VectorWorks&amp;action=edit" target=_blank><u><font color=#0000ff><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">VectorWorks</font></u></a></li>
    <li>高動態範圍（HDR）軟體
    <ul>
        <li><a title="Photoshop CS2" href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Photoshop_CS2'))"><font color=#0000ff><u>Photoshop CS2</u></font></a></li>
        <li><a class=new title=Photoimpact href="http://zh.wikipedia.org/w/index.php?title=Photoimpact&amp;action=edit" target=_blank><u><font color=#0000ff><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Photoimpact</font></u></a> 11</li>
        <li><a class=new title="Photomatix Pro" href="http://zh.wikipedia.org/w/index.php?title=Photomatix_Pro&amp;action=edit" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><font color=#0000ff><u>Photomatix Pro</u></font></a></li>
        <li><a class=new title="Image stacker" href="http://zh.wikipedia.org/w/index.php?title=Image_stacker&amp;action=edit" target=_blank><u><font color=#0000ff><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Image stacker</font></u></a></li>
    </ul>
    </li>
</ul>
<p><a name=.E5.A4.96.E9.83.A8.E9.93.BE.E6.8E.A5><u><font color=#0000ff></font></u></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E9%AB%98%E5%8A%A8%E6%80%81%E8%8C%83%E5%9B%B4%E6%88%90%E5%83%8F&amp;action=edit&amp;section=11" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>外部链接</span></h2>
<ul>
    <li><a class="external text" title=http://www.supportingcomputers.net/ href="http://www.supportingcomputers.net/" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Artizen HDR</font></u></a> 高动态范围图像编辑及<a title=色调映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%89%B2%E8%B0%83%E6%98%A0%E5%B0%84'))"><u><font color=#0000ff>色调映射</font></u></a>软件</li>
    <li><a class="external text" title=http://www.hdrsoft.com/ href="http://www.hdrsoft.com/" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Photomatix</font></u></a> 高动态范围图像合成及<a title=色调映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%89%B2%E8%B0%83%E6%98%A0%E5%B0%84'))"><u><font color=#0000ff>色调映射</font></u></a>软件</li>
    <li><a class="external text" title=http://www.daionet.gr.jp/~masa/rthdribl/ href="http://www.daionet.gr.jp/%7Emasa/rthdribl/" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><font color=#0000ff><u>基于演示照明的实时高动态范围图像</u></font></a></li>
    <li><a class="external text" title=http://www.anyhere.com/gward/hdrenc/hdr_encodings.html href="http://www.anyhere.com/gward/hdrenc/hdr_encodings.html" target=_blank rel=nofollow><u><font color=#0000ff><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">高动态范围图像编码</font></u></a>，Greg Ward, Anyhere Software</li>
    <li><a class="external text" title=http://www.linux.com/article.pl?sid=05/12/06/2115258 href="http://www.linux.com/article.pl?sid=05/12/06/2115258" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Linux 中的高动态范围图像</font></u></a>，Nathan Willis</li>
    <li><a class="external text" title=http://www.hyperfocaldesign.com href="http://www.hyperfocaldesign.com/" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Hyperfocal Design</font></u></a> 商用高动态范围图像、教程、软件评估以及新闻</li>
    <li><a class="external text" title=http://www.mpi-inf.mpg.de/resources/hdr/ href="http://www.mpi-inf.mpg.de/resources/hdr/" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>高动态范围图像与视频的处理——从获取到显示</font></u></a></li>
    <li><a class="external text" title=http://www.cs.uh.edu/~somalley/hdri_images.html href="http://www.cs.uh.edu/%7Esomalley/hdri_images.html" target=_blank rel=nofollow><u><font color=#0000ff><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">AHDRIA</font></u></a> 使用标准数码相机捕获高动态范围图像的软件</li>
    <li><a class="external text" title=http://www.gregdowning.com/HDRI/stitched/ href="http://www.gregdowning.com/HDRI/stitched/" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><font color=#0000ff><u>全自动梯度域高动态范围压缩描述</u></font></a></li>
    <li><a class="external text" title=http://www.hdrshop.com href="http://www.hdrshop.com/" target=_blank rel=nofollow><u><font color=#0000ff><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">HDRShop</font></u></a> 高动态范围图像处理软件资源</li>
    <li><a class="external text" title=http://www.acm.uiuc.edu/siggraph/eoh_projects/eoh2002.html href="http://www.acm.uiuc.edu/siggraph/eoh_projects/eoh2002.html" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>HDRIE</font></u></a>（高动态范围图像编辑器）- 受 HDRShop 启发的开发源代码项目</li>
    <li><a class="external text" title=http://www.rendermania.com/HDRI/ href="http://www.rendermania.com/HDRI/" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><font color=#0000ff><u>Renderman 中高动态范围图像渲染</u></font></a></li>
    <li><a class="external text" title=http://www.mpi-inf.mpg.de/resources/pfstools/ href="http://www.mpi-inf.mpg.de/resources/pfstools/" target=_blank rel=nofollow><u><font color=#0000ff><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">PFStools</font></u></a> - 创建、编辑高动态范围图像的开放源代码包</li>
    <li><a class="external text" title=http://www.nytimes.com/2006/08/03/technology/03basics.side.html href="http://www.nytimes.com/2006/08/03/technology/03basics.side.html" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Where to Go for More H.D.R.</font></u></a></li>
</ul>
<p><a name=.E6.91.84.E5.BD.B1><u><font color=#0000ff></font></u></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E9%AB%98%E5%8A%A8%E6%80%81%E8%8C%83%E5%9B%B4%E6%88%90%E5%83%8F&amp;action=edit&amp;section=12" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>摄影</span></h3>
<ul>
    <li><a class="external text" title=http://www.popphoto.com/howto/3038/how-to-create-high-dynamic-range-images.html href="http://www.popphoto.com/howto/3038/how-to-create-high-dynamic-range-images.html" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>如何生成高动态范围图像</font></u></a> - Tutorial Compares Photomatix and Photoshop CS2 Bridge</li>
    <li><a class="external text" title=http://www.cambridgeincolour.com/tutorials/high-dynamic-range.htm href="http://www.cambridgeincolour.com/tutorials/high-dynamic-range.htm" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>高动态范围照相</font></u></a> - Photoshop CS2 实现</li>
    <li><a class="external text" title=http://www.cypherxero.net/blog/?page_id=436 href="http://www.cypherxero.net/blog/?page_id=436" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Photoshop CS2 高动态范围图像介绍</font></u></a> - 用 Photoshop CS2 生成 32 位高动态范围图像</li>
    <li><a class="external text" title=http://www.farrarfocus.com/ffdd/shooting.htm href="http://www.farrarfocus.com/ffdd/shooting.htm" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Exposure Bracketing Technique for HDR Photography</font></u></a></li>
</ul>
<p><a name=.E9.AB.98.E5.8A.A8.E6.80.81.E8.8C.83.E5.9B.B4.E6.98.BE.E7.A4.BA><u><font color=#0000ff></font></u></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E9%AB%98%E5%8A%A8%E6%80%81%E8%8C%83%E5%9B%B4%E6%88%90%E5%83%8F&amp;action=edit&amp;section=13" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>高动态范围显示</span></h3>
<ul>
    <li><a class="external free" title=http://www.brightsidetech.com/ href="http://www.brightsidetech.com/" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>http://www.brightsidetech.com/</font></u></a> 高动态范围显示</li>
    <li><a class="external text" title=http://www.cs.ubc.ca/~heidrich/Projects/HDRDisplay href="http://www.cs.ubc.ca/%7Eheidrich/Projects/HDRDisplay" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><font color=#0000ff><u>高动态范围显示技术信息</u></font></a></li>
    <li><a class="external text" title=http://www.bit-tech.net/hardware/2005/10/04/brightside_hdr_edr/1.html href="http://www.bit-tech.net/hardware/2005/10/04/brightside_hdr_edr/1.html" target=_blank rel=nofollow><u><font color=#0000ff><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">高动态范围 LCD 显示原理</font></u></a></li>
</ul>
<p>Studio rendering:</p>
<ul>
    <li><a class="external free" title=http://www.hdri-studio.com href="http://www.hdri-studio.com/" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>http://www.hdri-studio.com</font></u></a> Commercial HDR maps derived from studio lighting setups</li>
    <li><a class="external free" title=http://www.sachform.com href="http://www.sachform.com/" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>http://www.sachform.com</font></u></a> Commercial HDR panoramas and viewer.</li>
    <li><a class="external text" title=http://pbacademy.com.sapo.pt/tutorials/renderman/hdri.htm href="http://pbacademy.com.sapo.pt/tutorials/renderman/hdri.htm" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>PixelBox Academy HDRI Tutorial</font></u></a> HDRI in PRMan using Image Based Illumination</li>
</ul>
<p><a id=On_rendering name=On_rendering></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E9%AB%98%E5%8A%A8%E6%80%81%E8%8C%83%E5%9B%B4%E6%88%90%E5%83%8F&amp;action=edit&amp;section=14" target=_blank><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>On rendering</span></h3>
<ul>
    <li><a class="external free" title=http://www.myanimator.com/research/hdri_ibi/MFA_Thesis.pdf href="http://www.myanimator.com/research/hdri_ibi/MFA_Thesis.pdf" target=_blank rel=nofollow><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><font color=#0000ff><u>http://www.myanimator.com/research/hdri_ibi/MFA_Thesis.pdf</u></font></a></li>
    <li><a class="external free" title=http://www.myanimator.com/research/hdri_ibi/tutorial/index.html href="http://www.myanimator.com/research/hdri_ibi/tutorial/index.html" target=_blank rel=nofollow><font color=#0000ff><u><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">http://www.myanimator.com/research/hdri_ibi/tutorial/index.html</u></font></a></li>
    <li><a class="external free" title=http://www.acm.uiuc.edu/siggraph/HDRIE/ href="http://www.acm.uiuc.edu/siggraph/HDRIE/" target=_blank rel=nofollow><u><font color=#0000ff><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">http://www.acm.uiuc.edu/siggraph/HDRIE/</font></u></a></li>
</ul>
</div>
<img src ="http://www.cppblog.com/yaoming/aggbug/40116.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/yaoming/" target="_blank">姚明</a> 2008-01-01 07:44 <a href="http://www.cppblog.com/yaoming/archive/2008/01/01/40116.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>色调映射</title><link>http://www.cppblog.com/yaoming/archive/2008/01/01/40113.html</link><dc:creator>姚明</dc:creator><author>姚明</author><pubDate>Mon, 31 Dec 2007 22:30:00 GMT</pubDate><guid>http://www.cppblog.com/yaoming/archive/2008/01/01/40113.html</guid><wfw:comment>http://www.cppblog.com/yaoming/comments/40113.html</wfw:comment><comments>http://www.cppblog.com/yaoming/archive/2008/01/01/40113.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/yaoming/comments/commentRss/40113.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/yaoming/services/trackbacks/40113.html</trackback:ping><description><![CDATA[<h1 class=firstHeading>色调映射</h1>
<div id=bodyContent>
<h3 id=siteSub>&nbsp;</h3>
<div id=contentSub></div>
<p><strong>色调映射</strong>是在有限动态范围媒介上近似显示<a title=高动态范围成像 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E9%AB%98%E5%8A%A8%E6%80%81%E8%8C%83%E5%9B%B4%E6%88%90%E5%83%8F'))" ??>高动态范围图像</a>的一项<a title=计算机图形学 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9B%BE%E5%BD%A2%E5%AD%A6'))" ??>计算机图形学</a>技术。打印结果、CRT 或者 LCD 显示器以及投影仪等都只有有限的动态范围。</p>
<p>本质上来讲，色调映射是要解决的问题是进行大幅度的对比度衰减将场景亮度变换到可以显示的范围，同时要保持图像细节与颜色等对于表现原始场景非常重要的信息。</p>
<p>根据应用的不同，色调映射的目标可以有不同的表述。在有些场合，生成&#8220;好看&#8221;的图像是主要目的，而在其它一些场合可能会强调生成尽可能多的细节或者最大的图像对比度。在实际的渲染应用中可能是要在真实场景与显示图像中达到匹配，尽管显示设备可能并不能够显示整个的亮度范围。</p>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 177px"><a class=image title=显示新西兰惠灵顿圣保罗教堂南凹室彩色玻璃的色调映射的高动态范围图像实例 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Old_saint_pauls_1.jpg'))" ??><img class=thumbimage height=117 alt=显示新西兰惠灵顿圣保罗教堂南凹室彩色玻璃的色调映射的高动态范围图像实例 src="http://upload.wikimedia.org/wikipedia/commons/thumb/6/6e/Old_saint_pauls_1.jpg/175px-Old_saint_pauls_1.jpg" width=175 border=0></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=放大 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Old_saint_pauls_1.jpg'))" ??><img height=11 alt="" src="http://zh.wikipedia.org/skins-1.5/common/images/magnify-clip.png" width=15></a></div>
显示<a title=新西兰 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%96%B0%E8%A5%BF%E5%85%B0'))" ??>新西兰</a><a title=惠灵顿 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%83%A0%E7%81%B5%E9%A1%BF'))" ??>惠灵顿</a><a class=new title=圣保罗教堂（惠灵顿） href="http://zh.wikipedia.org/w/index.php?title=%E5%9C%A3%E4%BF%9D%E7%BD%97%E6%95%99%E5%A0%82%EF%BC%88%E6%83%A0%E7%81%B5%E9%A1%BF%EF%BC%89&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">圣保罗教堂</a>南凹室彩色玻璃的色调映射的<a title=高动态范围成像 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E9%AB%98%E5%8A%A8%E6%80%81%E8%8C%83%E5%9B%B4%E6%88%90%E5%83%8F'))" ??>高动态范围图像</a>实例</div>
</div>
</div>
<p>在最近几年中已经开发了各种各样的色调映射算法<span class="reference plainlinksneverexpand" id=ref_devlin><sup><a class="external autonumber" title=http://zh.wikipedia.org/wiki/%E8%89%B2%E8%B0%83%E6%98%A0%E5%B0%84#endnote_devlin href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%89%B2%E8%B0%83%E6%98%A0%E5%B0%84#endnote_devlin'))" rel=nofollow ??>[1]</a></sup></span>，其中一个简单的色调映射滤波器例子是 <span class=texhtml><em>L</em> = <em>Y</em> / (<em>Y</em> + 1)</span>，这个函数将场景在 <img class=tex alt=[0,\infty) src="http://www.gollumbrowser.com/tc/math/b/1/4/b14ef532a91b6a826c93e81adefa66cd.png"> 域内的 radiance 值 <span class=texhtml><em>Y</em></span> 映射到显示输出范围 <span class=texhtml>[0,1)</span>。</p>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 302px"><a class=image title=用于生成前一幅图像的六幅不同曝光程度的图像 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:HDRI-Example.jpg'))" ??><img class=thumbimage height=133 alt=用于生成前一幅图像的六幅不同曝光程度的图像 src="http://upload.wikimedia.org/wikipedia/commons/thumb/b/b3/HDRI-Example.jpg/300px-HDRI-Example.jpg" width=300 border=0></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=放大 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:HDRI-Example.jpg'))" ??><img height=11 alt="" src="http://zh.wikipedia.org/skins-1.5/common/images/magnify-clip.png" width=15></a></div>
用于生成前一幅图像的六幅不同曝光程度的图像</div>
</div>
</div>
<p>另外一组更加复杂的算法是基于对比度或者梯度域的方法，这些算法的侧重点在于对比度的保持而不是亮度的映射，这种方法的思路起源于人眼对于对比度或者不同亮度区域的亮度比例最为敏感。这种色调映射由于较好地保存了对比度细节，所以通常会产生非常锐利的图像，但是这样做的代价是使得整体的图像对比度变得平缓。这种色调映射方法的例子包括：<a class=new title=梯度域高动态范围压缩 href="http://zh.wikipedia.org/w/index.php?title=%E6%A2%AF%E5%BA%A6%E5%9F%9F%E9%AB%98%E5%8A%A8%E6%80%81%E8%8C%83%E5%9B%B4%E5%8E%8B%E7%BC%A9&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">梯度域高动态范围压缩</a><span class="reference plainlinksneverexpand" id=ref_fattal><sup><a class="external autonumber" title=http://zh.wikipedia.org/wiki/%E8%89%B2%E8%B0%83%E6%98%A0%E5%B0%84#endnote_fattal href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%89%B2%E8%B0%83%E6%98%A0%E5%B0%84#endnote_fattal'))" rel=nofollow ??>[2]</a></sup></span>以及高动态范围图像感知框架<span class="reference plainlinksneverexpand" id=ref_mantiuk><sup><a class="external autonumber" title=http://zh.wikipedia.org/wiki/%E8%89%B2%E8%B0%83%E6%98%A0%E5%B0%84#endnote_mantiuk href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%89%B2%E8%B0%83%E6%98%A0%E5%B0%84#endnote_mantiuk'))" rel=nofollow ??>[3]</a></sup></span>（有一种色调映射就是这种框架的一个应用）。</p>
<p>一个有趣的高动态范围图像色调映射实现方法是从<a class=new title="Anchoring theory of lightness perception" href="http://zh.wikipedia.org/w/index.php?title=Anchoring_theory_of_lightness_perception&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">anchoring theory of lightness perception</a><span class="reference plainlinksneverexpand" id=ref_gilchrist><sup><a class="external autonumber" title=http://zh.wikipedia.org/wiki/%E8%89%B2%E8%B0%83%E6%98%A0%E5%B0%84#endnote_gilchrist href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%89%B2%E8%B0%83%E6%98%A0%E5%B0%84#endnote_gilchrist'))" rel=nofollow ??>[4]</a></sup></span>得到的灵感。这个理论全面地解释了人类视觉系统中如 lightness constancy 以及 its spectacular failures 这些对于感知图像非常重要部分的特点。这个色调映射方法（色调重建中的亮度感知<span class="reference plainlinksneverexpand" id=ref_krawczyk><sup><a class="external autonumber" title=http://zh.wikipedia.org/wiki/%E8%89%B2%E8%B0%83%E6%98%A0%E5%B0%84#endnote_krawczyk href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%89%B2%E8%B0%83%E6%98%A0%E5%B0%84#endnote_krawczyk'))" rel=nofollow ??>[5]</a></sup></span>）的核心概念是将高动态范围图像分解成照明一致的区域或结构以及计算局部亮度值。根据各个区域亮度的比例进行合并，从而计算图像的纯亮度值。其中尤其重要的是亮度定位（anchoring）——将照明的亮度对应于已知的亮度值，也就是说哪个亮度值在场景中感知为白色。这种色调映射实现方法不影响局部对比度，并且由于对亮度进行线性处理所以也保留了高动态图像的自然颜色。</p>
<table class=toc id=toc summary=目录>
    <tbody>
        <tr>
            <td>
            <div id=toctitle>
            <h2>目录</h2>
            </div>
            <ul>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.9B.BE.E5.BA.93"><span class=tocnumber>1</span><span class=toctext>图库</span></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.8F.82.E8.80.83.E6.96.87.E7.8C.AE"><span class=tocnumber>2</span><span class=toctext>参考文献</span></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.A4.96.E9.83.A8.E9.93.BE.E6.8E.A5"><span class=tocnumber>3</span><span class=toctext>外部链接</span></a>
                <ul>
                    <li class=toclevel-2><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E8.89.B2.E8.B0.83.E6.98.A0.E5.B0.84.E7.AE.97.E6.B3.95"><span class=tocnumber>3.1</span><span class=toctext>色调映射算法</span></a></li>
                </ul>
                </li>
            </ul>
            </td>
        </tr>
    </tbody>
</table>
<p><a name=.E5.9B.BE.E5.BA.93></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E8%89%B2%E8%B0%83%E6%98%A0%E5%B0%84&amp;action=edit&amp;section=1" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>图库</span></h2>
<table class=gallery cellSpacing=0 cellPadding=0>
    <tbody>
        <tr>
            <td>
            <div class=gallerybox style="WIDTH: 155px">
            <div class=thumb style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 13px; WIDTH: 150px; PADDING-TOP: 13px">
            <div style="MARGIN-LEFT: auto; WIDTH: 120px; MARGIN-RIGHT: auto"><a class=image title="Old saint pauls 2.jpg" href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Old_saint_pauls_2.jpg'))" ??><img height=120 alt="" src="http://upload.wikimedia.org/wikipedia/commons/thumb/4/48/Old_saint_pauls_2.jpg/80px-Old_saint_pauls_2.jpg" width=80 border=0></a></div>
            </div>
            <div class=gallerytext>
            <p><a title=新西兰 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%96%B0%E8%A5%BF%E5%85%B0'))" ??>新西兰</a><a title=惠灵顿 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%83%A0%E7%81%B5%E9%A1%BF'))" ??>惠灵顿</a>&nbsp;<a class=new title=圣保罗教堂（惠灵顿） href="http://zh.wikipedia.org/w/index.php?title=%E5%9C%A3%E4%BF%9D%E7%BD%97%E6%95%99%E5%A0%82%EF%BC%88%E6%83%A0%E7%81%B5%E9%A1%BF%EF%BC%89&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">圣保罗教堂</a> 大堂，从 1/20 秒到 30 秒的曝光的八幅照片</p>
            <p>&#160;</p>
            </div>
            </div>
            </td>
            <td>
            <div class=gallerybox style="WIDTH: 155px">
            <div class=thumb style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 47px; WIDTH: 150px; PADDING-TOP: 47px">
            <div style="MARGIN-LEFT: auto; WIDTH: 120px; MARGIN-RIGHT: auto"><a class=image title="Grand Canyon HDR imaging.jpg" href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Grand_Canyon_HDR_imaging.jpg'))" ??><img height=52 alt="" src="http://upload.wikimedia.org/wikipedia/commons/thumb/1/13/Grand_Canyon_HDR_imaging.jpg/120px-Grand_Canyon_HDR_imaging.jpg" width=120 border=0></a></div>
            </div>
            <div class=gallerytext>
            <p>两幅四级曝光差别的照片组合在一起，然后动态范围进行压缩以在标准显示器上显示</p>
            <p>&#160;</p>
            </div>
            </div>
            </td>
            <td>
            <div class=gallerybox style="WIDTH: 155px">
            <div class=thumb style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 53px; WIDTH: 150px; PADDING-TOP: 53px">
            <div style="MARGIN-LEFT: auto; WIDTH: 120px; MARGIN-RIGHT: auto"><a class=image title="Sunset hdr combined.jpg" href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Sunset_hdr_combined.jpg'))" ??><img height=40 alt="" src="http://upload.wikimedia.org/wikipedia/commons/thumb/c/c3/Sunset_hdr_combined.jpg/120px-Sunset_hdr_combined.jpg" width=120 border=0></a></div>
            </div>
            <div class=gallerytext>
            <p>高动态范围落日图像。Taken as an exposure bracket of three images 2 stops apart.</p>
            <p>&#160;</p>
            </div>
            </div>
            </td>
            <td>
            <div class=gallerybox style="WIDTH: 155px">
            <div style="HEIGHT: 152px">San Francisco HDR.jpg</div>
            <div class=gallerytext>
            <p>A nighttime picture of <a class=new title="San Francisco" href="http://zh.wikipedia.org/w/index.php?title=San_Francisco&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">San Francisco</a> taken from an 8th floor hotel room using 3 exposures bracketed two stops apart.</p>
            <p>&#160;</p>
            </div>
            </div>
            </td>
        </tr>
        <tr>
            <td>
            <div class=gallerybox style="WIDTH: 155px">
            <div style="HEIGHT: 152px">Village alsacien.jpg</div>
            <div class=gallerytext>
            <p>An evening picture of <a class=new title=Colmar href="http://zh.wikipedia.org/w/index.php?title=Colmar&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Colmar</a> using 5 exposures.</p>
            <p>&#160;</p>
            </div>
            </div>
            </td>
        </tr>
    </tbody>
</table>
<p><a name=.E5.8F.82.E8.80.83.E6.96.87.E7.8C.AE></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E8%89%B2%E8%B0%83%E6%98%A0%E5%B0%84&amp;action=edit&amp;section=2" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>参考文献</span></h2>
<ol>
    <li><cite id=endnote_devlin style="FONT-STYLE: normal"><a title="" href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#ref_devlin"><strong>^</strong></a></cite>&nbsp; Kate Devlin, Alan Chalmers, Alexander Wilkie, Werner Purgathofer. "STAR Report on Tone Reproduction and Physically Based Spectral Rendering" in <a class=new title=Eurographics href="http://zh.wikipedia.org/w/index.php?title=Eurographics&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Eurographics</a> 2002. <a title="Digital object identifier" href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Digital_object_identifier'))" ??>DOI</a>: <a class="external text" title=http://doi.acm.org/10.1145/1073204.1073242 href="http://doi.acm.org/10.1145/1073204.1073242" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">10.1145/1073204.1073242</a></li>
    <li><cite id=endnote_fattal style="FONT-STYLE: normal"><a title="" href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#ref_fattal"><strong>^</strong></a></cite>&nbsp; Raanan Fattal, Dani Lischinski, Michael Werman. <a class="external text" title=http://www.cs.huji.ac.il/~danix/hdr/ href="http://www.cs.huji.ac.il/~danix/hdr/" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">"梯度域高动态范围压缩"</a></li>
    <li><cite id=endnote_mantiuk style="FONT-STYLE: normal"><a title="" href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#ref_mantiuk"><strong>^</strong></a></cite>&nbsp; Rafal Mantiuk, Karol Myszkowski, Hans-Peter Seidel. <a class="external text" title=http://www.mpi-sb.mpg.de/~mantiuk/contrast_domain/ href="http://www.mpi-sb.mpg.de/~mantiuk/contrast_domain/" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">"高动态范围图像对比度处理的感知架构"</a></li>
    <li><cite id=endnote_gilchrist style="FONT-STYLE: normal"><a title="" href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#ref_gilchrist"><strong>^</strong></a></cite>&nbsp; Alan Gilchrist. <a class="external text" title=http://psychology.rutgers.edu/~alan/theory3/ href="http://psychology.rutgers.edu/~alan/theory3/" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">"An Anchoring Theory of Lightness Perception"</a>.</li>
    <li><cite id=endnote_krawczyk style="FONT-STYLE: normal"><a title="" href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#ref_krawczyk"><strong>^</strong></a></cite>&nbsp; Grzegorz Krawczyk, Karol Myszkowski, Hans-Peter Seidel. <a class="external text" title=http://www.mpi-inf.mpg.de/resources/hdr/lightness/ href="http://www.mpi-inf.mpg.de/resources/hdr/lightness/" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">"高动态范围图像色调重现中的亮度感知"</a></li>
</ol>
<p><a name=.E5.A4.96.E9.83.A8.E9.93.BE.E6.8E.A5></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E8%89%B2%E8%B0%83%E6%98%A0%E5%B0%84&amp;action=edit&amp;section=3" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>外部链接</span></h2>
<ul>
    <li><a class="external text" title=http://www.mpii.mpg.de/resources/tmo/ href="http://www.mpii.mpg.de/resources/tmo/" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">pfstmo: 色调映射算子的实现</a></li>
    <li><a class="external text" title=http://scanline.ca/exrtools/ href="http://scanline.ca/exrtools/" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">exrtools: OpenEXR 图像处理工具集合</a>（包括一些色调映射算子）</li>
</ul>
<p><a name=.E8.89.B2.E8.B0.83.E6.98.A0.E5.B0.84.E7.AE.97.E6.B3.95></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E8%89%B2%E8%B0%83%E6%98%A0%E5%B0%84&amp;action=edit&amp;section=4" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>色调映射算法</span></h3>
<ul>
    <li><a class="external text" title=http://www.cs.utah.edu/~reinhard/cdrom/ href="http://www.cs.utah.edu/~reinhard/cdrom/" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">数字图像的摄影色调重现</a></li>
    <li><a class="external text" title=http://www.mpi-inf.mpg.de/resources/hdr/lightness/ href="http://www.mpi-inf.mpg.de/resources/hdr/lightness/" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">高动态范围图像色调重现中的亮度感知</a></li>
    <li><a class="external text" title=http://www.mpi-inf.mpg.de/~mantiuk/contrast_domain/ href="http://www.mpi-inf.mpg.de/~mantiuk/contrast_domain/" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">高动态范围图像对比度处理</a></li>
    <li><a class="external text" title=http://people.csail.mit.edu/fredo/PUBLI/Siggraph2002/ href="http://people.csail.mit.edu/fredo/PUBLI/Siggraph2002/" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">高动态范围图像显示的快速双边滤波</a></li>
    <li><a class="external text" title=http://www.cs.huji.ac.il/~danix/hdr/ href="http://www.cs.huji.ac.il/~danix/hdr/" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">梯度域高动态范围压缩</a></li>
    <li><a class="external text" title=http://www.mpii.mpg.de/resources/tmo/ href="http://www.mpii.mpg.de/resources/tmo/" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">色调映射算子技术的实现</a></li>
</ul>
</div>
<img src ="http://www.cppblog.com/yaoming/aggbug/40113.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/yaoming/" target="_blank">姚明</a> 2008-01-01 06:30 <a href="http://www.cppblog.com/yaoming/archive/2008/01/01/40113.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>深度缓冲</title><link>http://www.cppblog.com/yaoming/archive/2008/01/01/40112.html</link><dc:creator>姚明</dc:creator><author>姚明</author><pubDate>Mon, 31 Dec 2007 22:22:00 GMT</pubDate><guid>http://www.cppblog.com/yaoming/archive/2008/01/01/40112.html</guid><wfw:comment>http://www.cppblog.com/yaoming/comments/40112.html</wfw:comment><comments>http://www.cppblog.com/yaoming/archive/2008/01/01/40112.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/yaoming/comments/commentRss/40112.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/yaoming/services/trackbacks/40112.html</trackback:ping><description><![CDATA[<h1 class=firstHeading>深度缓冲</h1>
<div id=bodyContent>
<h3 id=siteSub>&nbsp;</h3>
<div id=contentSub></div>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 182px"><a class=image title=深度缓冲 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Z-buffer.jpg'))" ??><img class=thumbimage height=299 alt=深度缓冲 src="http://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Z-buffer.jpg/180px-Z-buffer.jpg" width=180 border=0></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=放大 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Z-buffer.jpg'))" ??><img height=11 alt="" src="http://zh.wikipedia.org/skins-1.5/common/images/magnify-clip.png" width=15></a></div>
深度缓冲</div>
</div>
</div>
<p>在<a title=计算机图形学 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9B%BE%E5%BD%A2%E5%AD%A6'))" ??><u><font color=#0000ff>计算机图形学</font></u></a>中，<strong>深度缓冲</strong>是在三维图形中处理图像深度坐标的过程，这个过程通常在<a title=硬件 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%A1%AC%E4%BB%B6'))" ??><u><font color=#0000ff>硬件</font></u></a>中完成，它也可以在<a title=软件 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%BD%AF%E4%BB%B6'))" ??><u><font color=#0000ff>软件</font></u></a>中完成，它是<a class=new title=可见性问题 href="http://zh.wikipedia.org/w/index.php?title=%E5%8F%AF%E8%A7%81%E6%80%A7%E9%97%AE%E9%A2%98&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>可见性问题</font></u></a>的一个解决方法。可见性问题是确定渲染场景中哪部分可见、哪部分不可见的问题。<a title=画家算法 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%94%BB%E5%AE%B6%E7%AE%97%E6%B3%95'))" ??><u><font color=#0000ff>画家算法</font></u></a>是另外一种常用的方法，尽管效率较低，但是也可以处理透明场景元素。深度缓冲也称为 Z 缓冲。</p>
<p>当<a title=GPU href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/GPU'))" ??><u><font color=#0000ff>三维图形卡</font></u></a>渲染物体的时候，每一个所生成的<a title=像素 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%83%8F%E7%B4%A0'))" ??><u><font color=#0000ff>像素</font></u></a>的深度（即 z 坐标）就保存在一个<a title=缓冲区 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%BC%93%E5%86%B2%E5%8C%BA'))" ??><u><font color=#0000ff>缓冲区</font></u></a>中。这个缓冲区叫作 <strong>z 缓冲区</strong>或者<strong>深度缓冲区</strong>，这个缓冲区通常组织成一个保存每个屏幕像素深度的 x-y 二维数组。如果场景中的另外一个物体也在同一个像素生成渲染结果，那么图形处理卡就会比较二者的深度，并且保留距离观察者较近的物体。然后这个所保留的物体点深度保存到深度缓冲区中。最后，图形卡就可以根据深度缓冲区正确地生成通常的深度感知效果：较近的物体遮挡较远的物体。这个过程叫作 <strong>z 消隐</strong>。</p>
<p>深度缓冲的分辨率对于场景质量有很大的影响：当两个物体非常接近的时候，16 位的深度缓冲区可能会导致&#8220;z 缓冲区 fighting&#8221;的<a class=new title=人为噪声 href="http://zh.wikipedia.org/w/index.php?title=%E4%BA%BA%E4%B8%BA%E5%99%AA%E5%A3%B0&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>人为噪声</font></u></a>；使用 24 位或者 32 位的深度缓冲区就会表现得较好；由于精度太低，所以很少使用 8 位的深度缓冲区。</p>
<table class=toc id=toc summary=目录>
    <tbody>
        <tr>
            <td>
            <div id=toctitle>
            <h2>目录</h2>
            </div>
            <ul>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.8F.91.E5.B1.95"><font color=#800080><u><span class=tocnumber>1</span><span class=toctext>发展</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#z_.E6.B6.88.E9.9A.90"><font color=#800080><u><span class=tocnumber>2</span><span class=toctext>z 消隐</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E6.95.B0.E5.AD.A6.E5.9F.BA.E7.A1.80"><u><font color=#800080><span class=tocnumber>3</span><span class=toctext>数学基础</span></font></u></a>
                <ul>
                    <li class=toclevel-2><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#w_.E7.BC.93.E5.86.B2"><font color=#800080><u><span class=tocnumber>3.1</span><span class=toctext>w 缓冲</span></u></font></a></li>
                </ul>
                </li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#Javascript"><font color=#800080><u><span class=tocnumber>4</span><span class=toctext>Javascript</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.8F.82.E8.A7.81"><font color=#800080><u><span class=tocnumber>5</span><span class=toctext>参见</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.A4.96.E9.83.A8.E9.93.BE.E6.8E.A5"><font color=#800080><u><span class=tocnumber>6</span><span class=toctext>外部链接</span></u></font></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#Notes"><u><font color=#800080><span class=tocnumber>7</span><span class=toctext>Notes</span></font></u></a></li>
            </ul>
            </td>
        </tr>
    </tbody>
</table>
<p><a name=.E5.8F.91.E5.B1.95><u><font color=#800080></font></u></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B7%B1%E5%BA%A6%E7%BC%93%E5%86%B2&amp;action=edit&amp;section=1" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>发展</span></h2>
<p>即使深度缓冲区有足够大的分辨率，但是如果 z 缓冲区中距离<a class=new title=精度 href="http://zh.wikipedia.org/w/index.php?title=%E7%B2%BE%E5%BA%A6&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>精度</font></u></a>不随距离均匀分布的话图像质量也可能会出现问题。距离较近的部分通常精度较高，这样近距离的物体显示质量也较高。通常这是所期望得到的结果，但是当物体距离变得较远时可能会出现人为误差。一种能够得到更加均匀分布精度的深度缓冲变体是 <strong>w缓冲</strong>。</p>
<p>在场景开始的时候，必须将深度缓冲区初始化为一个特定的值，通常初始化为 1.0，这是因为 1.0 是深度范围 0 到 1 的上限，它意味着在整个<a class=new title=视体 href="http://zh.wikipedia.org/w/index.php?title=%E8%A7%86%E4%BD%93&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>视体</font></u></a>（viewing frustum）之内没有任何物体。</p>
<p>通常认为深度缓冲概念的发明主要归功于 <a class=new title="Edwin Catmull" href="http://zh.wikipedia.org/w/index.php?title=Edwin_Catmull&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Edwin Catmull</font></u></a>，虽然 Wolfgang Stra&#223;er 也在 <a title=1974年 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/1974%E5%B9%B4'))" ??><u><font color=#0000ff>1974年</font></u></a> 所写的博士论文 <sup id=fn_1_back><a title="" href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#fn_1"><u><font color=#800080>1</font></u></a></sup> 中提到了同样的思想。</p>
<p>在最近几年的 PC 图形卡上，深度缓冲管理需要使用大量的<a title=内存 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%86%85%E5%AD%98'))" ??><u><font color=#0000ff>内存</font></u></a><a title=带宽 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%B8%A6%E5%AE%BD'))" ??><u><font color=#0000ff>带宽</font></u></a>。人们采用了各种各样的方法减少深度缓冲的影响，其中的方法有<a title=无损数据压缩 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%97%A0%E6%8D%9F%E6%95%B0%E6%8D%AE%E5%8E%8B%E7%BC%A9'))" ??><u><font color=#0000ff>无损数据压缩</font></u></a>（因为压缩/解压所消耗的计算机资源要比带宽的占用更加合算）。另外还使用了极快的硬件工具清除深度信息，这种方法完全取代了&#8220;一帧正、一帧负&#8221;这种利用有符号数巧妙地绕过帧间深度信息清除的技巧。</p>
<p><a id=z_.E6.B6.88.E9.9A.90 name=z_.E6.B6.88.E9.9A.90></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B7%B1%E5%BA%A6%E7%BC%93%E5%86%B2&amp;action=edit&amp;section=2" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>z 消隐</span></h2>
<p>在<a title=渲染 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%B8%B2%E6%9F%93'))" ??><u><font color=#800080>渲染</font></u></a>过程中，z 消隐是根据深度信息对像素的早期剔除。当渲染隐藏表面所需要的计算量很大的时候，这种方法可以提升处理性能。z 消隐是深度缓冲的一个直接结果，在这种方法中每个待定像素的深度都要与相同位置的现存像素的深度进行比较。</p>
<p>使用深度缓冲区，一旦像素的深度已经确定，那么就可以对这个像素进行裁剪，这样如果该像素不可见的话就可以完全跳过照明与纹理处理的过程，并且需要消耗许多时间的像素浓淡工具通常也会跳过对于裁剪掉的像素的处理。这样 z 消隐就成为了在<a class=new title=填充速度 href="http://zh.wikipedia.org/w/index.php?title=%E5%A1%AB%E5%85%85%E9%80%9F%E5%BA%A6&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>填充速度</font></u></a>、光照、纹理或者像素浓淡处理是主要瓶颈的场合的一种很好的优化工具。</p>
<p>尽管深度缓冲可以处理未经排序的几何体，但是按照深度不断增加的方式（与<a title=画家算法 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%94%BB%E5%AE%B6%E7%AE%97%E6%B3%95'))" ??><u><font color=#0000ff>画家算法</font></u></a>排序方式相反）对多边形进行排序，每个像素就可以只渲染一次。对于填充速度有限但是有大量重复绘制场合，这种方法就可以提高处理性能。</p>
<p><a name=.E6.95.B0.E5.AD.A6.E5.9F.BA.E7.A1.80></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B7%B1%E5%BA%A6%E7%BC%93%E5%86%B2&amp;action=edit&amp;section=3" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>数学基础</span></h2>
<p>待渲染的照相机<a title=空间 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%A9%BA%E9%97%B4'))" ??><u><font color=#0000ff>空间</font></u></a>中的深度经常定义为近距 near 到远距 far 之间的 z 值，在<a class=new title=透视变换 href="http://zh.wikipedia.org/w/index.php?title=%E9%80%8F%E8%A7%86%E5%8F%98%E6%8D%A2&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>透视变换</font></u></a>之后，得到新的 z' 值：</p>
<p><img class=tex alt="z'=&#10;\frac{\mathit{far}+\mathit{near}}{\mathit{far\mathit{near}} +&#10;\frac{1}{z} (\frac{-2 \cdot \mathit{far} \cdot \mathit{near}}{\mathit{far}-\mathit{near}} )&#10;" src="http://www.gollumbrowser.com/tc/math/a/b/4/ab4afb6c410b637e7282f77c1c557da0.png">}-</p>
<p>其中 <span class=texhtml><em>z</em></span> 是照相机空间的值，它有时候也表示为 w 或者 w'。</p>
<p>结果 z' 是在 -1 到 1 之间<a class=new title=归一化 href="http://zh.wikipedia.org/w/index.php?title=%E5%BD%92%E4%B8%80%E5%8C%96&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>归一化</font></u></a>之后的值，其中近距 near <a title=平面 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%B9%B3%E9%9D%A2'))" ??><u><font color=#0000ff>平面</font></u></a>位于 -1 处，远距 far 平面位于 1 处。在这个范围之外的相应点在<a class=new title=视图体 href="http://zh.wikipedia.org/w/index.php?title=%E8%A7%86%E5%9B%BE%E4%BD%93&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>视图体</font></u></a>之外，不需要进行渲染。</p>
<p>为了实现深度缓冲，在整个屏幕空间上的对当前<a title=多边形 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%A4%9A%E8%BE%B9%E5%BD%A2'))" ??><u><font color=#0000ff>多边形</font></u></a><a title=顶点 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E9%A1%B6%E7%82%B9'))" ??><u><font color=#0000ff>顶点</font></u></a>之间进行插值来计算 z' 的值，通常这些中间数值在深度缓冲区中用<a class=new title=定点数 href="http://zh.wikipedia.org/w/index.php?title=%E5%AE%9A%E7%82%B9%E6%95%B0&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>定点数</font></u></a>格式保存。距离近距 near 平面越近，z' 值越密；距离越远，z' 值越稀。这样距离照相机越近精度越高。near 平面距离照相机越近，则远距离位置的精度越低。near 平面距离照相机太近是在远距离物体产生人为误差的一个常见因素。</p>
<p><a id=w_.E7.BC.93.E5.86.B2 name=w_.E7.BC.93.E5.86.B2></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B7%B1%E5%BA%A6%E7%BC%93%E5%86%B2&amp;action=edit&amp;section=4" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>w 缓冲</span></h3>
<p>为了实现 w 缓冲，通常照相机空间中的 z 值或者 w 值都保存成<a title=浮点数 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%B5%AE%E7%82%B9%E6%95%B0'))" ??><u><font color=#0000ff>浮点数</font></u></a>格式，但是这些数值无法根据顶点在整个屏幕上进行线性插值——通常对它的<a title=倒数 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%80%92%E6%95%B0'))" ??><u><font color=#0000ff>倒数</font></u></a>进行插值，然后再取倒数。这样得到的结果 w 值与 z' 不同，它们在 near 平面与 far 平面之间均匀分布。</p>
<p>根据应用的不同 z 缓冲与 w 缓冲生成的图像质量也有所不同。</p>
<p><a id=Javascript name=Javascript></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B7%B1%E5%BA%A6%E7%BC%93%E5%86%B2&amp;action=edit&amp;section=5" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>Javascript</span></h2>
<p>当在 <a title=JavaScript href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/JavaScript'))" ??><u><font color=#0000ff>JavaScript</font></u></a> 中使用 <code>&lt;canvas&gt;</code> 标签的时候，可以将下面的程序作为深度缓冲的公式。</p>
<pre>f=0;
n=0;
z=0;
z=((f+n)/(f-n))+((1/z)*((-2*f*n)/(f-n)));</pre>
<p><a name=.E5.8F.82.E8.A7.81></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B7%B1%E5%BA%A6%E7%BC%93%E5%86%B2&amp;action=edit&amp;section=6" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>参见</span></h2>
<ul>
    <li><a class=new title="Edwin Catmull" href="http://zh.wikipedia.org/w/index.php?title=Edwin_Catmull&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Edwin Catmull</font></u></a> -- 深度缓冲概念的发明人</li>
    <li><a title=三维计算机图形 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E4%B8%89%E7%BB%B4%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9B%BE%E5%BD%A2'))" ??><font color=#0000ff><u>三维计算机图形</u></font></a></li>
    <li><a class=new title=不规则深度缓冲 href="http://zh.wikipedia.org/w/index.php?title=%E4%B8%8D%E8%A7%84%E5%88%99%E6%B7%B1%E5%BA%A6%E7%BC%93%E5%86%B2&amp;action=edit" target=_blank ?><font color=#0000ff><u><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">不规则深度缓冲</u></font></a></li>
    <li><a class=new title=Z-order href="http://zh.wikipedia.org/w/index.php?title=Z-order&amp;action=edit" target=_blank ?><u><font color=#0000ff><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Z-order</font></u></a></li>
</ul>
<p><a name=.E5.A4.96.E9.83.A8.E9.93.BE.E6.8E.A5><u><font color=#0000ff></font></u></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B7%B1%E5%BA%A6%E7%BC%93%E5%86%B2&amp;action=edit&amp;section=7" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>外部链接</span></h2>
<ul>
    <li><a class="external text" title=http://www.sjbaker.org/steve/omniv/love_your_z_buffer.html href="http://www.sjbaker.org/steve/omniv/love_your_z_buffer.html" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>Learning to Love your Z-buffer</font></u></a></li>
    <li><a class="external text" title=http://www.sjbaker.org/steve/omniv/alpha_sorting.html href="http://www.sjbaker.org/steve/omniv/alpha_sorting.html" target=_blank rel=nofollow ?><u><font color=#0000ff><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Alpha-blending and the Z-buffer</font></u></a></li>
</ul>
<p><a id=Notes name=Notes><u><font color=#0000ff></font></u></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B7%B1%E5%BA%A6%E7%BC%93%E5%86%B2&amp;action=edit&amp;section=8" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>Notes</span></h2>
<p><cite id=1><a title="" href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#fn_1_back"><u><font color=#800080>Note 1:</font></u></a></cite> see W.K. Giloi, J.L. Encarna&#231;&#227;o, W. Stra&#223;er. "The Giloi&#8217;s School of Computer Graphics". Computer Graphics 35 4:12&#8211;16.</p>
</div>
<img src ="http://www.cppblog.com/yaoming/aggbug/40112.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/yaoming/" target="_blank">姚明</a> 2008-01-01 06:22 <a href="http://www.cppblog.com/yaoming/archive/2008/01/01/40112.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>立体渲染</title><link>http://www.cppblog.com/yaoming/archive/2008/01/01/40111.html</link><dc:creator>姚明</dc:creator><author>姚明</author><pubDate>Mon, 31 Dec 2007 22:18:00 GMT</pubDate><guid>http://www.cppblog.com/yaoming/archive/2008/01/01/40111.html</guid><wfw:comment>http://www.cppblog.com/yaoming/comments/40111.html</wfw:comment><comments>http://www.cppblog.com/yaoming/archive/2008/01/01/40111.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/yaoming/comments/commentRss/40111.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/yaoming/services/trackbacks/40111.html</trackback:ping><description><![CDATA[<h1 class=firstHeading>立体渲染</h1>
<div id=bodyContent>
<h3 id=siteSub>&nbsp;</h3>
<div id=contentSub></div>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 252px"><a class=image title=使用纹理映射以及漫反射渲染的头颅 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:CTSkullImage.png'))" ??><img class=thumbimage height=232 alt=使用纹理映射以及漫反射渲染的头颅 src="http://upload.wikimedia.org/wikipedia/zh/thumb/d/d2/CTSkullImage.png/250px-CTSkullImage.png" width=250 border=0></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=放大 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:CTSkullImage.png'))" ??><img height=11 alt="" src="http://zh.wikipedia.org/skins-1.5/common/images/magnify-clip.png" width=15></a></div>
使用<a title=纹理映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%BA%B9%E7%90%86%E6%98%A0%E5%B0%84'))" ??>纹理映射</a>以及<a class=new title=漫反射 href="http://zh.wikipedia.org/w/index.php?title=%E6%BC%AB%E5%8F%8D%E5%B0%84&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">漫反射</a>渲染的头颅</div>
</div>
</div>
<p><strong>立体渲染</strong>（<a class=extiw title=en:Volume_rendering href="javascript:void(wb.w._link('http://en.wikipedia.org/wiki/Volume_rendering'))" ??>en:Volume rendering</a>）是用来显示离散三维采样数据集的二维投影的技术。</p>
<p>一个典型的三维数据集是 <a title=CT href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/CT'))" ??>CT</a> 或者 <a title=MRI href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/MRI'))" ??>MRI</a> 采集的一组二维切面图像。通常这些数据是按照一定规则如每毫米一个切面，并且通常有一定数目的图像像素。这是一个常见的立体晶格的例子，每个体素用当前体素附近区域的采样值表示。</p>
<p>为了渲染三维数据集的二维投影，首先需要定义相机相对于立体的空间位置。另外，需要定义每个点即<a title=體素 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E9%AB%94%E7%B4%A0'))" ??>体素</a>的不透明性以及颜色，这通常使用<strong>RGBA</strong>（red, green, blue, alpha）传递函数定义每个体素可能值对应的 RGBA 值。</p>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 252px"><a class=image title="用不同颜色表示肌肉、脂肪、骨骼以及血液进行立体渲染的前臂 CT 图" href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:CTWristImage.png'))" ??><img class=thumbimage height=199 alt="用不同颜色表示肌肉、脂肪、骨骼以及血液进行立体渲染的前臂 CT 图" src="http://upload.wikimedia.org/wikipedia/zh/thumb/0/06/CTWristImage.png/250px-CTWristImage.png" width=250 border=0></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=放大 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:CTWristImage.png'))" ??><img height=11 alt="" src="http://zh.wikipedia.org/skins-1.5/common/images/magnify-clip.png" width=15></a></div>
用不同颜色表示肌肉、脂肪、骨骼以及血液进行立体渲染的前臂 <a title=CT href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/CT'))" ??>CT</a> 图</div>
</div>
</div>
<p>通过提取立体中等值的曲面并且将它们作为多边形进行渲染，或者直接将立体作为数据块进行渲染，这两种方法都可以使立体可见。<a class=new title="Marching Cubes" href="http://zh.wikipedia.org/w/index.php?title=Marching_Cubes&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Marching Cubes</a> 算法是从立体数据中提取曲面的常用技术。直接立体渲染是一件计算量很大的工作，可以用几种不同的方法来实现。</p>
<table class=toc id=toc summary=目录>
    <tbody>
        <tr>
            <td>
            <div id=toctitle>
            <h2>目录</h2>
            </div>
            <ul>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E7.9B.B4.E6.8E.A5.E7.AB.8B.E4.BD.93.E6.B8.B2.E6.9F.93"><span class=tocnumber>1</span><span class=toctext>直接立体渲染</span></a>
                <ul>
                    <li class=toclevel-2><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E7.AB.8B.E4.BD.93.E5.85.89.E7.BA.BF.E6.8A.95.E5.B0.84"><span class=tocnumber>1.1</span><span class=toctext>立体光线投射</span></a></li>
                    <li class=toclevel-2><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#Splatting"><span class=tocnumber>1.2</span><span class=toctext>Splatting</span></a></li>
                    <li class=toclevel-2><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#Shear_Warp"><span class=tocnumber>1.3</span><span class=toctext>Shear Warp</span></a></li>
                    <li class=toclevel-2><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E7.BA.B9.E7.90.86.E6.98.A0.E5.B0.84"><span class=tocnumber>1.4</span><span class=toctext>纹理映射</span></a></li>
                    <li class=toclevel-2><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E7.A1.AC.E4.BB.B6.E5.8A.A0.E9.80.9F.E7.AB.8B.E4.BD.93.E6.B8.B2.E6.9F.93"><span class=tocnumber>1.5</span><span class=toctext>硬件加速立体渲染</span></a></li>
                </ul>
                </li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E4.BC.98.E5.8C.96.E6.8A.80.E6.9C.AF"><span class=tocnumber>2</span><span class=toctext>优化技术</span></a>
                <ul>
                    <li class=toclevel-2><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E8.B7.B3.E8.BF.87.E7.A9.BA.E9.97.B2.E7.A9.BA.E9.97.B4"><span class=tocnumber>2.1</span><span class=toctext>跳过空闲空间</span></a></li>
                    <li class=toclevel-2><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.85.89.E7.BA.BF.E6.8F.90.E5.89.8D.E7.BB.88.E6.AD.A2"><span class=tocnumber>2.2</span><span class=toctext>光线提前终止</span></a></li>
                    <li class=toclevel-2><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.85.AB.E5.8F.89.E6.A0.91.E5.8F.8A.E4.BA.8C.E5.85.83.E7.A9.BA.E9.97.B4.E5.88.86.E5.89.B2"><span class=tocnumber>2.3</span><span class=toctext>八叉树及二元空间分割</span></a></li>
                    <li class=toclevel-2><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E7.AB.8B.E4.BD.93.E5.88.86.E5.89.B2"><span class=tocnumber>2.4</span><span class=toctext>立体分割</span></a></li>
                </ul>
                </li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E6.9D.A5.E6.BA.90"><span class=tocnumber>3</span><span class=toctext>来源</span></a></li>
            </ul>
            </td>
        </tr>
    </tbody>
</table>
<p><a name=.E7.9B.B4.E6.8E.A5.E7.AB.8B.E4.BD.93.E6.B8.B2.E6.9F.93></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E7%AB%8B%E4%BD%93%E6%B8%B2%E6%9F%93&amp;action=edit&amp;section=1" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>直接立体渲染</span></h2>
<p>直接立体渲染要求每个采样值都必须映射到对应的不透明性以及颜色，这是通过一个&#8220;传递函数&#8221;实现的，这个传递函数可能是简单的斜面、也可能是分段线性函数或这是任意的表格。一旦转换到<strong>RGBA</strong>值之后，对应的 RGBA 结果就会映射到帧缓冲中对应的像素。根据渲染技术的不同这个做法也有所不同。</p>
<p>使用多种技术的组合也是可行的。例如去除扭曲的实现可以用纹理硬件在屏幕外的缓存中绘制排列好的片断。</p>
<p><a name=.E7.AB.8B.E4.BD.93.E5.85.89.E7.BA.BF.E6.8A.95.E5.B0.84></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E7%AB%8B%E4%BD%93%E6%B8%B2%E6%9F%93&amp;action=edit&amp;section=2" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>立体光线投射</span></h3>
<p><em>主条目：<a class=new title=立体光线投射 href="http://zh.wikipedia.org/w/index.php?title=%E7%AB%8B%E4%BD%93%E5%85%89%E7%BA%BF%E6%8A%95%E5%B0%84&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">立体光线投射</a>。</em></p>
<p>投影图像最简单的方法就是立体光线投射。在这种方法中，每个图像点都生成对应的光线。按照一个简单的照相机模型，光线从照相机（通常是眼睛位置）中心开始投射，经过照相机与需要渲染的立体之间的假象平面上的图像。光线在立体的边界进行剪切以节约处理时间，然后在整个立体空间上按照一定规则对光线进行采样。在每个采样点数据进行插值计算，经过传递函数变换成 RGBA 采样值，这个采样添加到光线的 RGBA 数据集中，然后重复这个过程直到光线抵达立体内部。RGBA 颜色转换到 RGB 颜色并且放到对应的图像像素上。屏幕上的每个像素都重复这个过程直到形成完整的图像。在 <a class="external autonumber" title=http://www.fovia.com/ href="http://www.fovia.com/" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">[1]</a> 上可以看到高质量的光线投射渲染立体的实例。</p>
<p><a id=Splatting name=Splatting></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E7%AB%8B%E4%BD%93%E6%B8%B2%E6%9F%93&amp;action=edit&amp;section=3" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>Splatting</span></h3>
<p>这是一个通过牺牲质量换取速度的方法。每个立体元素都象雪球那样按照从后到前的顺序 splatted 到观察表面。这些 splats 按照颜色与透明度特性在直径方向正态即高斯变化渲染成圆盘。平盘与其它特性也根据应用的不同而不同。</p>
<p><a id=Shear_Warp name=Shear_Warp></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E7%AB%8B%E4%BD%93%E6%B8%B2%E6%9F%93&amp;action=edit&amp;section=4" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>Shear Warp</span></h3>
<p>一个新的立体渲染实现方法是 Philippe Lacroute 与 <a class=new title="Marc Levoy" href="http://zh.wikipedia.org/w/index.php?title=Marc_Levoy&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Marc Levoy</a> 一起开发的在论文&#8220;使用 Shear-Warp 分解观察角度变换的快速立体渲染&#8221;<a class="external autonumber" title=http://graphics.stanford.edu/papers/shear/ href="http://graphics.stanford.edu/papers/shear/" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">[2]</a>中描述的方法。在这种技术中，观察角度进行变换使得最近的立体表面成为后台图像缓冲区按照体素到像素的固定尺度排列的轴，然后渲染的立体按照方便的内存排列、固定的缩放及过渡因子放到这个缓冲区中。一旦立体的所有的切片已经渲染完毕，缓冲数据就会转换到在前台显示图像中所要的方向及尺度。</p>
<p>这种方法通过牺牲采样精度得到了相对较快的处理速度，但是这种方法生成的图像潜在质量要比光线投射方法生成的图像质量差。</p>
<p><a name=.E7.BA.B9.E7.90.86.E6.98.A0.E5.B0.84></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E7%AB%8B%E4%BD%93%E6%B8%B2%E6%9F%93&amp;action=edit&amp;section=5" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>纹理映射</span></h3>
<p>许多三维图形系统都通过<a title=纹理映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%BA%B9%E7%90%86%E6%98%A0%E5%B0%84'))" ??>纹理映射</a>将图像、纹理用于几何物体。日常所用 PC 的<a title=GPU href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/GPU'))" ??>图形处理卡</a>处理纹理非常快速并且能够高效地渲染三维立体切片，并且具有实时的交互能力。</p>
<p>这些切片可以根据立体进行排列然后按照观察者的角度进行渲染，也可以根据观察平面进行排列然后从立体中未经排列的切片进行采样。对于第二种技术来说需要图形硬件支持三维纹理处理。</p>
<p>根据立体排列纹理的方式能够生成合理的图像质量，但是当立体旋转的时候经常会产生明显的过渡。根据视角排列纹理的方式可以得到类似于光线投射的高质量图像，并且采样图案也是相同的。</p>
<p><a name=.E7.A1.AC.E4.BB.B6.E5.8A.A0.E9.80.9F.E7.AB.8B.E4.BD.93.E6.B8.B2.E6.9F.93></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E7%AB%8B%E4%BD%93%E6%B8%B2%E6%9F%93&amp;action=edit&amp;section=6" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>硬件加速立体渲染</span></h3>
<p>最近出现的一项加速渲染的技术是使用图形处理卡加速如光线投射这样的传统立体渲染算法。从 2000（？）年左右开始出现的可编程 <a class=new title="Pixel shaders" href="http://zh.wikipedia.org/w/index.php?title=Pixel_shaders&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">pixel shaders</a> 开始，人们逐渐认识到多点并行运算的威力并且开始在图形芯片上执行更加普通的计算。曾经一度叫作&#8220;寄存器组合器&#8221;的 <a class=new title="Pixel shaders" href="http://zh.wikipedia.org/w/index.php?title=Pixel_shaders&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">pixel shaders</a> 能够随机地读写纹理内存并且执行一些基本的算术与逻辑计算。这些现在称为 <a title=GPU href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/GPU'))" ??>GPU</a> 的<a title=单指令流多数据流 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%8D%95%E6%8C%87%E4%BB%A4%E6%B5%81%E5%A4%9A%E6%95%B0%E6%8D%AE%E6%B5%81'))" ??>单指令流多数据流</a>处理器用于如光线跟踪多边形以及信号处理中的普通计算。在 OpenGL 2.0 版上，pixel shaders 现在能够作为<a title=多指令流多数据流 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%A4%9A%E6%8C%87%E4%BB%A4%E6%B5%81%E5%A4%9A%E6%95%B0%E6%8D%AE%E6%B5%81'))" ??>多指令流多数据流</a>处理器使用并且能够独立进行分支切换，能够使用高达 48 个并行处理单元，并且能够使用高达 1 GB 的纹理内存以及 high bit depth 数字格式。通过这样的能力，理论上象立体光线投射或者 CT 重建这样的算法都能够得到极大的加速。</p>
<p><a name=.E4.BC.98.E5.8C.96.E6.8A.80.E6.9C.AF></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E7%AB%8B%E4%BD%93%E6%B8%B2%E6%9F%93&amp;action=edit&amp;section=7" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>优化技术</span></h2>
<p><a name=.E8.B7.B3.E8.BF.87.E7.A9.BA.E9.97.B2.E7.A9.BA.E9.97.B4></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E7%AB%8B%E4%BD%93%E6%B8%B2%E6%9F%93&amp;action=edit&amp;section=8" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>跳过空闲空间</span></h3>
<p>立体渲染系统经常带有一个识别立体区域是否包含可见物体的部分，这个信息可以用于避免在这些透明区域进行渲染。</p>
<p><a name=.E5.85.89.E7.BA.BF.E6.8F.90.E5.89.8D.E7.BB.88.E6.AD.A2></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E7%AB%8B%E4%BD%93%E6%B8%B2%E6%9F%93&amp;action=edit&amp;section=9" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>光线提前终止</span></h3>
<p>这是按照从前到后顺序渲染立体的时候所用的一项技术。对于穿过一个像素的光线，一旦达到一定程度的浓度，那么后面的采样点对于这点来说就起不到多大作用，因此可以忽略。</p>
<p><a name=.E5.85.AB.E5.8F.89.E6.A0.91.E5.8F.8A.E4.BA.8C.E5.85.83.E7.A9.BA.E9.97.B4.E5.88.86.E5.89.B2></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E7%AB%8B%E4%BD%93%E6%B8%B2%E6%9F%93&amp;action=edit&amp;section=10" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>八叉树及二元空间分割</span></h3>
<p>使用如<a title=八叉树 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%85%AB%E5%8F%89%E6%A0%91'))" ??>八叉树</a>或者<a class=new title=二元空间分割 href="http://zh.wikipedia.org/w/index.php?title=%E4%BA%8C%E5%85%83%E7%A9%BA%E9%97%B4%E5%88%86%E5%89%B2&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">二元空间分割</a>树的层次结构对于立体数据压缩以及优化立体光线投影过程来说都非常有用。</p>
<p><a name=.E7.AB.8B.E4.BD.93.E5.88.86.E5.89.B2></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E7%AB%8B%E4%BD%93%E6%B8%B2%E6%9F%93&amp;action=edit&amp;section=11" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>立体分割</span></h3>
<p>通过分割出渲染前不需要关心的部分，就可以大幅度地减少光线投影或者纹理混合所需要的计算量。</p>
<p><a name=.E6.9D.A5.E6.BA.90></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E7%AB%8B%E4%BD%93%E6%B8%B2%E6%9F%93&amp;action=edit&amp;section=12" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>来源</span></h2>
<ul>
    <li>R. A. Drebin, L. Carpenter, P. Hanrahan: <em>Volume Rendering.</em> 1988</li>
</ul>
</div>
<img src ="http://www.cppblog.com/yaoming/aggbug/40111.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/yaoming/" target="_blank">姚明</a> 2008-01-01 06:18 <a href="http://www.cppblog.com/yaoming/archive/2008/01/01/40111.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>光线跟踪</title><link>http://www.cppblog.com/yaoming/archive/2008/01/01/40110.html</link><dc:creator>姚明</dc:creator><author>姚明</author><pubDate>Mon, 31 Dec 2007 22:16:00 GMT</pubDate><guid>http://www.cppblog.com/yaoming/archive/2008/01/01/40110.html</guid><wfw:comment>http://www.cppblog.com/yaoming/comments/40110.html</wfw:comment><comments>http://www.cppblog.com/yaoming/archive/2008/01/01/40110.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/yaoming/comments/commentRss/40110.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/yaoming/services/trackbacks/40110.html</trackback:ping><description><![CDATA[<h1 class=firstHeading>光线跟踪</h1>
<div id=bodyContent>
<h3 id=siteSub>&nbsp;</h3>
<div id=contentSub></div>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 252px"><a class=image title=光线跟踪场景 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Raytraced_image_jawray.jpg'))" ??><img class=thumbimage height=250 alt=光线跟踪场景 src="http://upload.wikimedia.org/wikipedia/commons/thumb/e/ed/Raytraced_image_jawray.jpg/250px-Raytraced_image_jawray.jpg" width=250 border=0></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=放大 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Raytraced_image_jawray.jpg'))" ??><img height=11 alt="" src="http://zh.wikipedia.org/skins-1.5/common/images/magnify-clip.png" width=15></a></div>
光线跟踪场景</div>
</div>
</div>
<p><strong>光线跟踪</strong>（<a class=extiw title=en:Ray_tracing href="javascript:void(wb.w._link('http://en.wikipedia.org/wiki/Ray_tracing'))" ??>en:Ray tracing</a>）来自于<a title=几何光学 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%87%A0%E4%BD%95%E5%85%89%E5%AD%A6'))" ??>几何光学</a>的一项通用技术，它通过跟踪与光学表面发生交互作用的<a title=光線 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%85%89%E7%B7%9A'))" ??>光线</a>从而得到光线经过路径的模型。它用于光学系统设计，如<a title=鏡頭 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E9%8F%A1%E9%A0%AD'))" ??>照相机镜头</a>、<a title=显微镜 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%98%BE%E5%BE%AE%E9%95%9C'))" ??>显微镜</a>、<a title=望远镜 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%9C%9B%E8%BF%9C%E9%95%9C'))" ??>望远镜</a>以及<a class=new title=双目镜 href="http://zh.wikipedia.org/w/index.php?title=%E5%8F%8C%E7%9B%AE%E9%95%9C&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">双目镜</a>等。这个术语也用于表示<a title=三维计算机图形学 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E4%B8%89%E7%BB%B4%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9B%BE%E5%BD%A2%E5%AD%A6'))" ??>三维计算机图形学</a>中的特殊<a title=渲染 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%B8%B2%E6%9F%93'))" ??>渲染</a>算法，跟踪从眼睛发出的光线而不是光源发出的光线，通过这样一项技术生成编排好的场景的数学模型显现出来。这样得到的结果类似于<a class=new title=光线投射 href="http://zh.wikipedia.org/w/index.php?title=%E5%85%89%E7%BA%BF%E6%8A%95%E5%B0%84&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">光线投射</a>与<a title=扫描线渲染 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%89%AB%E6%8F%8F%E7%BA%BF%E6%B8%B2%E6%9F%93'))" ??>扫描线渲染</a>方法的结果，但是这种方法有更好的光学效果，例如对于<a title=反射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%8F%8D%E5%B0%84'))" ??>反射</a>与<a title=折射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%8A%98%E5%B0%84'))" ??>折射</a>有更准确的模拟效果，并且效率非常高，所以当追求这样高质量结果时候经常使用这种方法。</p>
<table class=toc id=toc summary=目录>
    <tbody>
        <tr>
            <td>
            <div id=toctitle>
            <h2>目录</h2>
            </div>
            <ul>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.85.89.E7.BA.BF.E8.B7.9F.E8.B8.AA.E8.AE.A1.E7.AE.97.E6.9C.BA.E7.AE.97.E6.B3.95.E7.9A.84.E4.B8.80.E8.88.AC.E6.8F.8F.E8.BF.B0"><span class=tocnumber>1</span><span class=toctext>光线跟踪计算机算法的一般描述</span></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.85.89.E7.BA.BF.E8.B7.9F.E8.B8.AA.E8.AE.A1.E7.AE.97.E6.9C.BA.E7.AE.97.E6.B3.95.E5.8F.8A.E5.85.B6.E8.B5.B7.E6.BA.90.E7.9A.84.E8.AF.A6.E7.BB.86.E6.8F.8F.E8.BF.B0"><span class=tocnumber>2</span><span class=toctext>光线跟踪计算机算法及其起源的详细描述</span></a>
                <ul>
                    <li class=toclevel-2><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E8.87.AA.E7.84.B6.E7.8E.B0.E8.B1.A1"><span class=tocnumber>2.1</span><span class=toctext>自然现象</span></a></li>
                    <li class=toclevel-2><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.85.89.E7.BA.BF.E6.8A.95.E5.B0.84.E7.AE.97.E6.B3.95"><span class=tocnumber>2.2</span><span class=toctext>光线投射算法</span></a></li>
                    <li class=toclevel-2><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.85.89.E7.BA.BF.E8.B7.9F.E8.B8.AA.E7.AE.97.E6.B3.95"><span class=tocnumber>2.3</span><span class=toctext>光线跟踪算法</span></a></li>
                    <li class=toclevel-2><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.85.89.E7.BA.BF.E8.B7.9F.E8.B8.AA.E7.9A.84.E4.BC.98.E7.82.B9"><span class=tocnumber>2.4</span><span class=toctext>光线跟踪的优点</span></a></li>
                    <li class=toclevel-2><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.85.89.E7.BA.BF.E8.B7.9F.E8.B8.AA.E7.9A.84.E7.BC.BA.E7.82.B9"><span class=tocnumber>2.5</span><span class=toctext>光线跟踪的缺点</span></a></li>
                    <li class=toclevel-2><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.85.89.E7.BA.BF.E7.A9.BF.E8.BF.87.E5.9C.BA.E6.99.AF.E7.9A.84.E5.8F.8D.E6.96.B9.E5.90.91"><span class=tocnumber>2.6</span><span class=toctext>光线穿过场景的反方向</span></a></li>
                    <li class=toclevel-2><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E7.BB.8F.E5.85.B8.E9.80.92.E5.BD.92.E5.85.89.E7.BA.BF.E8.B7.9F.E8.B8.AA.E7.AE.97.E6.B3.95"><span class=tocnumber>2.7</span><span class=toctext>经典递归光线跟踪算法</span></a></li>
                </ul>
                </li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.AE.9E.E6.97.B6.E5.85.89.E7.BA.BF.E8.B7.9F.E8.B8.AA"><span class=tocnumber>3</span><span class=toctext>实时光线跟踪</span></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.85.89.E5.AD.A6.E8.AE.BE.E8.AE.A1.E4.B8.AD.E7.9A.84.E5.85.89.E7.BA.BF.E8.B7.9F.E8.B8.AA"><span class=tocnumber>4</span><span class=toctext>光学设计中的光线跟踪</span></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E4.BE.8B.E5.AD.90"><span class=tocnumber>5</span><span class=toctext>例子</span></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.8F.82.E8.A7.81"><span class=tocnumber>6</span><span class=toctext>参见</span></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.8F.82.E8.80.83.E6.96.87.E7.8C.AE"><span class=tocnumber>7</span><span class=toctext>参考文献</span></a></li>
                <li class=toclevel-1><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.A4.96.E9.83.A8.E9.93.BE.E6.8E.A5"><span class=tocnumber>8</span><span class=toctext>外部链接</span></a>
                <ul>
                    <li class=toclevel-2><a href="http://gollum.easycp.de/gollum/gollum.php?a=core&amp;l=zh-cn&amp;wl=zh&amp;q=#.E5.85.89.E7.BA.BF.E8.B7.9F.E8.B8.AA.E8.BD.AF.E4.BB.B6"><span class=tocnumber>8.1</span><span class=toctext>光线跟踪软件</span></a></li>
                </ul>
                </li>
            </ul>
            </td>
        </tr>
    </tbody>
</table>
<p><a name=.E5.85.89.E7.BA.BF.E8.B7.9F.E8.B8.AA.E8.AE.A1.E7.AE.97.E6.9C.BA.E7.AE.97.E6.B3.95.E7.9A.84.E4.B8.80.E8.88.AC.E6.8F.8F.E8.BF.B0></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%85%89%E7%BA%BF%E8%B7%9F%E8%B8%AA&amp;action=edit&amp;section=1" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>光线跟踪计算机算法的一般描述</span></h2>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 322px"><a class=image title=反射地板并且相互反射的三个球体 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:3chromeballs.png'))" ??><img class=thumbimage height=240 alt=反射地板并且相互反射的三个球体 src="http://upload.wikimedia.org/wikipedia/commons/thumb/7/77/3chromeballs.png/320px-3chromeballs.png" width=320 border=0></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=放大 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:3chromeballs.png'))" ??><img height=11 alt="" src="http://zh.wikipedia.org/skins-1.5/common/images/magnify-clip.png" width=15></a></div>
反射地板并且相互反射的三个球体</div>
</div>
</div>
<p>为了生成在<a title=三维计算机图形学 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E4%B8%89%E7%BB%B4%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9B%BE%E5%BD%A2%E5%AD%A6'))" ??>三维计算机图形</a>环境中的可见图像，光线跟踪是一个比光线投射或者扫描线渲染更加逼真的实现方法。这种方法通过逆向跟踪与假象的照相机镜头相交的光路进行工作，由于大量的类似光线横穿场景，所以从照相机角度看到的场景可见信息以及软件特定的光照条件，就可以构建起来。当光线与场景中的物体或者媒介相交的时候计算光线的反射、折射以及吸收。</p>
<p>光线跟踪的场景经常是由程序员用数学工具进行描述，也可以由视觉艺术家使用中间工具描述，也可以使用从数码相机等不同技术方法捕捉到的图像或者模型数据。</p>
<p>由于一个光源发射出的光线的绝大部分不会在观察者看到的光线中占很大比例，这些光线大部分经过多次反射逐渐消失或者至无限小，所以对于构建可见信息来说，逆向跟踪光线要比真实地模拟光线相互作用的效率要高很多倍。计算机模拟程序从光源发出的光线开始查询与观察点相交的光线从执行与获得正确的图像来说是不现实的。</p>
<p>这种方法的一个明显缺点就是需要假设光线在观察点处终止，然后进行逆向跟踪。在一定数量的最大反射之后，最后交点处的光线强度使用多种算法进行估计，这些算法可能包括经典的渲染算法，也可能包括如<a title=辐射着色 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%BE%90%E5%B0%84%E7%9D%80%E8%89%B2'))" ??>辐射着色</a>这样的技术。</p>
<p><a name=.E5.85.89.E7.BA.BF.E8.B7.9F.E8.B8.AA.E8.AE.A1.E7.AE.97.E6.9C.BA.E7.AE.97.E6.B3.95.E5.8F.8A.E5.85.B6.E8.B5.B7.E6.BA.90.E7.9A.84.E8.AF.A6.E7.BB.86.E6.8F.8F.E8.BF.B0></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%85%89%E7%BA%BF%E8%B7%9F%E8%B8%AA&amp;action=edit&amp;section=2" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>光线跟踪计算机算法及其起源的详细描述</span></h2>
<p><a name=.E8.87.AA.E7.84.B6.E7.8E.B0.E8.B1.A1></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%85%89%E7%BA%BF%E8%B7%9F%E8%B8%AA&amp;action=edit&amp;section=3" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>自然现象</span></h3>
<p>在自然界中，光源发出的光线向前传播，最后到达一个妨碍它继续传播的物体表面，我们可以将&#8220;光线&#8221;看作在同样的路径传输的<a title=光子 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%85%89%E5%AD%90'))" ??>光子</a>流，在完全真空中，这条光线将是一条直线。但是在现实中，在光路上会受到三个因素的影响：<a title=吸收 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%90%B8%E6%94%B6'))" ??>吸收</a>、<a title=反射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%8F%8D%E5%B0%84'))" ??>反射</a>与<a title=折射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%8A%98%E5%B0%84'))" ??>折射</a>。物体表面可能在一个或者多个方向反射全部或者部分光线，它也可能吸收部分光线，使得反射或者折射的光线强度减弱。如果物体表面是<a title=透明 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E9%80%8F%E6%98%8E'))" ??>透明</a>的或者<a title=半透明 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%8D%8A%E9%80%8F%E6%98%8E'))" ??>半透明</a>的，那么它就会将一部分光线按照不同的方向折射到物体内部，同时吸收部分或者全部<a title=光谱 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%85%89%E8%B0%B1'))" ??>光谱</a>或者改变光线的颜色。吸收、反射以及折射的光线都来自于入射光线，而不会超出入射光线的强度。例如，一个物体表面不可能反射 66% 的输入光线，然后再折射 50% 的输入光线，因为这二者相加将会达到 116%。这样，反射或者折射的光线可以到达其它的物体表面，同样，吸收、反射、折射的光线重新根据入射光线进行计算。其中一部分光线通过这样的途径传播到我们的眼睛，我们就能够看到最终的渲染图像及场景。</p>
<p><a name=.E5.85.89.E7.BA.BF.E6.8A.95.E5.B0.84.E7.AE.97.E6.B3.95></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%85%89%E7%BA%BF%E8%B7%9F%E8%B8%AA&amp;action=edit&amp;section=4" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>光线投射算法</span></h3>
<p><a class=new title="Arthur Appel" href="http://zh.wikipedia.org/w/index.php?title=Arthur_Appel&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Arthur Appel</a> 于 1968 年首次提出用于渲染的光线投射算法。光线投射的基础就是从眼睛投射光线到物体上的每个点，查找阻挡光线的最近物体，也就是将图像当作一个屏风，每个点就是屏风上的一个正方形。通常这就是眼睛看到的那个点的物体。根据材料的特性以及场景中的光线效果，这个算法可以确定物体的<a class=new title=浓淡效果 href="http://zh.wikipedia.org/w/index.php?title=%E6%B5%93%E6%B7%A1%E6%95%88%E6%9E%9C&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">浓淡效果</a>。其中一个简单假设就是如果表面面向光线，那么这个表面就会被照亮而不会处于阴影中。表面的浓淡效果根据传统的三维计算机图形学的浓淡模型进行计算。光线投射超出<a title=扫描线渲染 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%89%AB%E6%8F%8F%E7%BA%BF%E6%B8%B2%E6%9F%93'))" ??>扫描线渲染</a>的一个重要优点是它能够很容易地处理非平面的表面以及实体，如<a title=圆锥 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%9C%86%E9%94%A5'))" ??>圆锥</a>和<a title=球体 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%90%83%E4%BD%93'))" ??>球体</a>等。如果一个数学表面与光线相交，那么就可以用光线投射进行渲染。复杂的物体可以用<a title=实体造型 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%AE%9E%E4%BD%93%E9%80%A0%E5%9E%8B'))" ??>实体造型</a>技术构建，并且可以很容易地进行渲染。</p>
<p>位于<a title=纽约 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%BA%BD%E7%BA%A6'))" ??>纽约</a>&nbsp;<a class=new title="Elmsford, New York" href="http://zh.wikipedia.org/w/index.php?title=Elmsford%2C_New_York&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Elmsford, New York</a>&nbsp;<a class=new title="Mathematical Applications Group, Inc." href="http://zh.wikipedia.org/w/index.php?title=Mathematical_Applications_Group%2C_Inc.&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Mathematical Applications Group, Inc.</a>（MAGI）的科学家首次将光线投射技术用于生成计算机图形。1966 年，为了替<a title=美国国防部 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%BE%8E%E5%9B%BD%E5%9B%BD%E9%98%B2%E9%83%A8'))" ??>美国国防部</a>计算<a title=放射性污染 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%94%BE%E5%B0%84%E6%80%A7%E6%B1%A1%E6%9F%93'))" ??>放射性污染</a>创立了这个公司。MAGI 不仅计算了<a title=伽马射线 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E4%BC%BD%E9%A9%AC%E5%B0%84%E7%BA%BF'))" ??>伽马射线</a>如何从表面进行反射（辐射的光线投射自从二十世纪四十年代就已经开始计算了），也计算了它们如何穿透以及折射。这些研究工作帮助政府确定一些特定的军事应用；建造能够保护军队避免辐射的军用车辆，设计可以重入的太空探索交通工具。在 <a class=new title="Philip Mittelman" href="http://zh.wikipedia.org/w/index.php?title=Philip_Mittelman&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Philip Mittelman</a> 博士的指导下，科学家们开发了一种使用同样基本软件生成图像的方法。1972 年，MAFI 转变成了一个商业动画工作室，这个工作室使用光线投射技术为商业电视、<a class=new title=教育电影 href="http://zh.wikipedia.org/w/index.php?title=%E6%95%99%E8%82%B2%E7%94%B5%E5%BD%B1&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">教育电影</a>以及最后为故事片制作三维计算机动画，他们全部使用光线投射制作了 <em><a class=new title=Tron href="http://zh.wikipedia.org/w/index.php?title=Tron&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Tron</a></em> 电影中的绝大部分动画。MAGI 于 1985 年破产。</p>
<p><a name=.E5.85.89.E7.BA.BF.E8.B7.9F.E8.B8.AA.E7.AE.97.E6.B3.95></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%85%89%E7%BA%BF%E8%B7%9F%E8%B8%AA&amp;action=edit&amp;section=5" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>光线跟踪算法</span></h3>
<p>下一个重要的研究突破是 <a class=new title="Turner Whitted" href="http://zh.wikipedia.org/w/index.php?title=Turner_Whitted&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Turner Whitted</a> 于 1979 年做出的。以前的算法从眼睛到场景投射光线，但是并不跟踪这些光线。当光线碰到一个物体表面的时候，可能产生三种新的类型的光线：反射、折射与阴影。光滑的物体表面将光线按照镜像反射的方向反射出去，然后这个光线与场景中的物体相交，最近的相交物体就是反射中看到的物体。在透明物质中传输的光线以类似的方式传播，但是在进入或者离开一种物质的时候会发生折射。为了避免跟踪场景中的所有光线，人们使用阴影光线来测试光线是否可以照射到物体表面。光线照射到物体表面上的某些点上，如果这些点面向光线，那么就跟踪这段交点与光源之间的光线。如果在表面与光源之间是不透明的物体，那么这个表面就位于阴影之中，光线无法照射。这种新层次的光线计算使得光线跟踪图像更加真实。</p>
<p><a name=.E5.85.89.E7.BA.BF.E8.B7.9F.E8.B8.AA.E7.9A.84.E4.BC.98.E7.82.B9></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%85%89%E7%BA%BF%E8%B7%9F%E8%B8%AA&amp;action=edit&amp;section=6" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>光线跟踪的优点</span></h3>
<p>光线跟踪的流行来源于它比其它渲染方法如扫描线渲染或者光线投射更加能够现实地模拟光线，象反射和<a class=new title=阴影 href="http://zh.wikipedia.org/w/index.php?title=%E9%98%B4%E5%BD%B1&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">阴影</a>这样一些对于其它的算法来说都很难实现的效果，却是光线跟踪算法的一种自然结果。光线跟踪易于实现并且视觉效果很好，所以它通常是图形编程中首次尝试的领域。</p>
<p><a name=.E5.85.89.E7.BA.BF.E8.B7.9F.E8.B8.AA.E7.9A.84.E7.BC.BA.E7.82.B9></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%85%89%E7%BA%BF%E8%B7%9F%E8%B8%AA&amp;action=edit&amp;section=7" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>光线跟踪的缺点</span></h3>
<p>光线跟踪的一个最大的缺点就是性能，扫描线算法以及其它算法利用了数据的一致性从而在像素之间共享计算，但是光线跟踪通常是将每条光线当作独立的光线，每次都要重新计算。但是，这种独立的做法也有一些其它的优点，例如可以使用更多的光线以<a class=new title=抗混叠 href="http://zh.wikipedia.org/w/index.php?title=%E6%8A%97%E6%B7%B7%E5%8F%A0&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">抗混叠</a>现象，并且在需要的时候可以提高图像质量。尽管它正确地处理了相互反射的现象以及折射等光学效果，但是传统的光线跟踪并不一定是真实效果图像，只有在非常紧似或者完全实现<a title=渲染方程 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%B8%B2%E6%9F%93%E6%96%B9%E7%A8%8B'))" ??>渲染方程</a>的时候才能实现真正的真实效果图像。由于渲染方程描述了每个光束的物理效果，所以实现渲染方程可以得到真正的真实效果，但是，考虑到所需要的计算资源，这通常是无法实现的。于是，所有可以实现的渲染模型都必须是渲染方程的近似，而光线跟踪就不一定是最为可行的方法。包括<a class=new title=光子映射 href="http://zh.wikipedia.org/w/index.php?title=%E5%85%89%E5%AD%90%E6%98%A0%E5%B0%84&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">光子映射</a>在内的一些方法，都是依据光线跟踪实现一部分算法，但是可以得到更好的效果。</p>
<p><a name=.E5.85.89.E7.BA.BF.E7.A9.BF.E8.BF.87.E5.9C.BA.E6.99.AF.E7.9A.84.E5.8F.8D.E6.96.B9.E5.90.91></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%85%89%E7%BA%BF%E8%B7%9F%E8%B8%AA&amp;action=edit&amp;section=8" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>光线穿过场景的反方向</span></h3>
<p>从眼睛发出光线到达光源从而渲染图像的过程有时也称为<em>后向光线跟踪</em>，这是因为它是实际光线传播方向的反方向。但是，对于这个术语来说还有一些混淆的地方。早期的光线跟踪经常是从眼睛开始，James Arvo 等早期研究人员用<em>后向光线跟踪</em>表示从光源发出光线然后收集得到的结果。因为如此，将它们分成<em>基于眼睛</em>或者<em>基于光源</em>的光线跟踪将会更加清楚。在过去的几十年中，研究人员已经开发了许多组合了这两种方向的计算方法与机制以生成投降或者偏离交叉表面的或多或少的光线。例如，<a title=辐射着色 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%BE%90%E5%B0%84%E7%9D%80%E8%89%B2'))" ??>辐射着色</a>算法通常根据光源对于表面的影响进行计算并且存储这些结果，然后一个标准的递归光线跟踪器可以使用这些数据生成场景的真实、物理正确的图像。在<a class=new title=全局照明 href="http://zh.wikipedia.org/w/index.php?title=%E5%85%A8%E5%B1%80%E7%85%A7%E6%98%8E&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">全局照明</a>算法如<a class=new title=光子映射 href="http://zh.wikipedia.org/w/index.php?title=%E5%85%89%E5%AD%90%E6%98%A0%E5%B0%84&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">光子映射</a>以及 <a class=new title="Metropolis light transport" href="http://zh.wikipedia.org/w/index.php?title=Metropolis_light_transport&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Metropolis light transport</a> 中，光线跟踪只是一个用来计算光线在表面之间传输的简单工具。</p>
<p><a name=.E7.BB.8F.E5.85.B8.E9.80.92.E5.BD.92.E5.85.89.E7.BA.BF.E8.B7.9F.E8.B8.AA.E7.AE.97.E6.B3.95></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%85%89%E7%BA%BF%E8%B7%9F%E8%B8%AA&amp;action=edit&amp;section=9" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>经典递归光线跟踪算法</span></h3>
<pre>For each pixel in image {
Create ray from eyepoint passing through this pixel
Initialize NearestT to INFINITY and NearestObject to NULL
For every object in scene {
If ray intersects this object {
If t of intersection is less than NearestT {
Set NearestT to t of the intersection
Set NearestObject to this object
}
}
}
If NearestObject is NULL {
Fill this pixel with background color
} Else {
Shoot a ray to each light source to check if in shadow
If surface is reflective, generate reflection ray: recurse
If surface is transparent, generate refraction ray: recurse
Use NearestObject and NearestT to compute shading function
Fill this pixel with color result of shading function
}
}
</pre>
<p><a name=.E5.AE.9E.E6.97.B6.E5.85.89.E7.BA.BF.E8.B7.9F.E8.B8.AA></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%85%89%E7%BA%BF%E8%B7%9F%E8%B8%AA&amp;action=edit&amp;section=10" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>实时光线跟踪</span></h2>
<p>人们已经进行了许多努力，改进如<a title=电子游戏 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%94%B5%E5%AD%90%E6%B8%B8%E6%88%8F'))" ??>计算机与视频游戏</a>这些交互式三维图形应用程序中的实时光线跟踪速度。</p>
<p><a class=new title=OpenRT href="http://zh.wikipedia.org/w/index.php?title=OpenRT&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">OpenRT</a> 项目包含一个高度优化的光线跟踪软件内核，并且提供了一套类似于 <a title=OpenGL href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/OpenGL'))" ??>OpenGL</a> 的 API 用于替代目前交互式三维图形处理中基于<a class=new title=位图化 href="http://zh.wikipedia.org/w/index.php?title=%E4%BD%8D%E5%9B%BE%E5%8C%96&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">位图化</a>（rasterization）的实现方法。</p>
<p>一些<a class=new title=光线跟踪硬件 href="http://zh.wikipedia.org/w/index.php?title=%E5%85%89%E7%BA%BF%E8%B7%9F%E8%B8%AA%E7%A1%AC%E4%BB%B6&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">光线跟踪硬件</a>，如 <a class=new title="Saarland 大学" href="http://zh.wikipedia.org/w/index.php?title=Saarland_%E5%A4%A7%E5%AD%A6&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Saarland 大学</a>开发的实验性<a class=new title=光线处理单元 href="http://zh.wikipedia.org/w/index.php?title=%E5%85%89%E7%BA%BF%E5%A4%84%E7%90%86%E5%8D%95%E5%85%83&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">光线处理单元</a>，都是设计用来加速光线跟踪处理中那些需要大量计算的操作。</p>
<p>自从二十世纪九十年代末开始，一些 <a class=new title=Demoscene href="http://zh.wikipedia.org/w/index.php?title=Demoscene&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">demo programmers</a> 爱好者就已经开发了一些光线跟踪的实时三维引擎软件。但是，<a class=new title="Demo (computer programming)" href="http://zh.wikipedia.org/w/index.php?title=Demo_%28computer_programming%29&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">demos</a> 中的光线跟踪为了实现足够高的帧速经常使用一些不正确的近似甚至是欺骗的手段。<a class="external autonumber" title=http://www.acm.org/tog/resources/RTNews/demos/overview.htm href="http://www.acm.org/tog/resources/RTNews/demos/overview.htm" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">[1]</a></p>
<p><a name=.E5.85.89.E5.AD.A6.E8.AE.BE.E8.AE.A1.E4.B8.AD.E7.9A.84.E5.85.89.E7.BA.BF.E8.B7.9F.E8.B8.AA></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%85%89%E7%BA%BF%E8%B7%9F%E8%B8%AA&amp;action=edit&amp;section=11" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>光学设计中的光线跟踪</span></h2>
<p>计算机图形学中的光线跟踪的名称与原理源自于二十世纪最初十年就已经开始出现的<a class=new title=光学镜头设计 href="http://zh.wikipedia.org/w/index.php?title=%E5%85%89%E5%AD%A6%E9%95%9C%E5%A4%B4%E8%AE%BE%E8%AE%A1&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">光学镜头设计</a>中的古老技术。<em>几何光线跟踪</em>用于描述光线通过镜头系统或者<a title=光学 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%85%89%E5%AD%A6'))" ??>光学</a>仪器时的传输特性，并建立系统的成像属性模型。这用于建造前优化光学仪器的设计，例如减少<a class=new title=色像差 href="http://zh.wikipedia.org/w/index.php?title=%E8%89%B2%E5%83%8F%E5%B7%AE&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">色像差</a>或者其它的光学<a title=像差 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%83%8F%E5%B7%AE'))" ??>像差</a>。光线跟踪也用于计算光学系统中的<a title=光程 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%85%89%E7%A8%8B'))" ??>光程差</a>，光程差用于计算光学波前，而光学波前用于计算系统的<a title=衍射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%A1%8D%E5%B0%84'))" ??>衍射</a>作用，例如<a class=new title=点扩展函数 href="http://zh.wikipedia.org/w/index.php?title=%E7%82%B9%E6%89%A9%E5%B1%95%E5%87%BD%E6%95%B0&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">点扩展函数</a>、<a class=new title=调制传递函数 href="http://zh.wikipedia.org/w/index.php?title=%E8%B0%83%E5%88%B6%E4%BC%A0%E9%80%92%E5%87%BD%E6%95%B0&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">调制传递函数</a>以及 <a class=new title="Strehl ratio" href="http://zh.wikipedia.org/w/index.php?title=Strehl_ratio&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Strehl ratio</a>。光线跟踪不仅用于摄影领域的镜头设计，也可以用于微波设计甚至是无线电系统这样的较长<a title=波长 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%B3%A2%E9%95%BF'))" ??>波长</a>应用，也可以用于<a title=紫外线 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%B4%AB%E5%A4%96%E7%BA%BF'))" ??>紫外线</a>或者<a title=X射线 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/X%E5%B0%84%E7%BA%BF'))" ??>X射线</a>光学这样的较短波长领域。</p>
<p>计算机图形学与光学设计领域所用的光线跟踪的基本原理都是类似的，但是光学设计所用的技术通常更加严格，并且能够更加正确地反映光线行为。尤其是<a title=光的色散 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%85%89%E7%9A%84%E8%89%B2%E6%95%A3'))" ??>光的色散</a>、<a title=衍射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%A1%8D%E5%B0%84'))" ??>衍射</a>效应以及<a class=new title=光学镀膜 href="http://zh.wikipedia.org/w/index.php?title=%E5%85%89%E5%AD%A6%E9%95%80%E8%86%9C&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">光学镀膜</a>的特性在<a class=new title=光学镜头设计 href="http://zh.wikipedia.org/w/index.php?title=%E5%85%89%E5%AD%A6%E9%95%9C%E5%A4%B4%E8%AE%BE%E8%AE%A1&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">光学镜头设计</a>中都是非常重要的，但是在计算机图形学领域就没有那么重要了。</p>
<p>在<a title=计算机 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%AE%A1%E7%AE%97%E6%9C%BA'))" ??>计算机</a>出现以前，光线跟踪需要使用<a title=三角学 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E4%B8%89%E8%A7%92%E5%AD%A6'))" ??>三角</a>以及<a title=对数 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%AF%B9%E6%95%B0'))" ??>对数</a>表手工计算，许多传统<a title=摄影 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%91%84%E5%BD%B1'))" ??>摄影</a>镜头的光学公式都是许多人共同完成优化的，每个人只能处理其中一小部分的计算工作。现在这些计算可以在如来自于 Lambda Research 的 <a class=new title=OSLO href="http://zh.wikipedia.org/w/index.php?title=OSLO&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">OSLO</a> 或者 <a class=new title=TracePro href="http://zh.wikipedia.org/w/index.php?title=TracePro&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">TracePro</a>、<a class=new title="CODE V" href="http://zh.wikipedia.org/w/index.php?title=CODE_V&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Code-V</a> 或者 <a class=new title=Zemax href="http://zh.wikipedia.org/w/index.php?title=Zemax&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Zemax</a> 这些光学设计软件上完成。一个简单的光线跟踪版本是<a class=new title=光线传递矩阵分析 href="http://zh.wikipedia.org/w/index.php?title=%E5%85%89%E7%BA%BF%E4%BC%A0%E9%80%92%E7%9F%A9%E9%98%B5%E5%88%86%E6%9E%90&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">光线传递矩阵分析</a>，它通常用于<a title=激光 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%BF%80%E5%85%89'))" ??>激光</a><a class=new title=光学谐振腔 href="http://zh.wikipedia.org/w/index.php?title=%E5%85%89%E5%AD%A6%E8%B0%90%E6%8C%AF%E8%85%94&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">光学谐振腔</a>的设计。</p>
<p><a name=.E4.BE.8B.E5.AD.90></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%85%89%E7%BA%BF%E8%B7%9F%E8%B8%AA&amp;action=edit&amp;section=12" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>例子</span></h2>
<p>为了说明光线跟踪所用的基本原理，我们来看计算一个光线与球体交点的例子。用 <strong>I</strong> 表示球面上的点，<strong>C</strong> 表示球心，<strong>r</strong> 表示半径，那么球面的公式为 <img class=tex alt=|\mathbf{I\mathbf{C}|^2=r^2 src="http://www.gollumbrowser.com/tc/math/8/0/9/809617f3df3ded1e22304a4347ea85cc.png">}-. 如果定义一条线的起点即光线起点是 <strong>S</strong>，方向是 <strong>d</strong>，那么线上的每个点都可以表示为</p>
<dl>
<dd><img class=tex alt="\mathbf{S}+t\mathbf{d}\ ," src="http://www.gollumbrowser.com/tc/math/d/8/3/d83f48aacff869b7b6024dc5890cb3eb.png"></dd></dl>
<p>其中 <em>t</em> 是定义线上与起点距离的常数，为了简化起见，通常 <strong>d</strong> 定义为<a title=单位向量 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%8D%95%E4%BD%8D%E5%90%91%E9%87%8F'))" ??>单位向量</a>。那么，在这种情况下已知 <strong>S</strong>、<strong>d</strong>、<strong>C</strong> 以及 <strong>r</strong>，于是代入 <strong>I</strong> 得到：</p>
<dl>
<dd><img class=tex alt="|\mathbf{S}+t\mathbf{d\mathbf{C}|^{2}=r^{2}\ ." src="http://www.gollumbrowser.com/tc/math/8/1/4/8140727a73c4b1e91b3ec987e4d780e0.png">}-</dd></dl>
<p>简化 <img class=tex alt=\mathbf{V}\equiv\mathbf{S\mathbf{C} src="http://www.gollumbrowser.com/tc/math/d/f/d/dfd1908c7d8603bab746c9e5a487fb06.png">}- ，那么</p>
<dl>
<dd><img class=tex alt=|\mathbf{V}+t\mathbf{d}|^{2}=r^{2} src="http://www.gollumbrowser.com/tc/math/a/2/7/a27ce21daa6b36c14bc25f8646d44e79.png"></dd></dl>
<dl>
<dd><img class=tex alt="\mathbf{V}^2+t^2\mathbf{d}^2+2\mathbf{V}\cdot t\mathbf{d}=r^2" src="http://www.gollumbrowser.com/tc/math/6/4/0/640f233cb5dd2426b0a98c9df4acd3df.png"></dd></dl>
<dl>
<dd><img class=tex alt="d^2t^2+2\mathbf{V}\cdot t\mathbf{d}+\mathbf{V}^2-r^2=0\ ." src="http://www.gollumbrowser.com/tc/math/a/4/4/a44286afce8014729e85436a846749fd.png"></dd></dl>
<p>那么二次方程的解是</p>
<dl>
<dd><img class=tex alt="t=\frac{-2\mathbf{V}\cdot\mathbf{d}\pm\sqrt{(2\mathbf{V}\cdot\mathbf{d})^2-4d^2(V^2-r^2)}}{2d^2}\ ." src="http://www.gollumbrowser.com/tc/math/0/3/9/039de90713792a92c20398f4a059962a.png"></dd></dl>
<p>这只是直线<a class=new title=光线与球体交点 href="http://zh.wikipedia.org/w/index.php?title=%E5%85%89%E7%BA%BF%E4%B8%8E%E7%90%83%E4%BD%93%E4%BA%A4%E7%82%B9&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">光线与球体交点</a>的所用的数学公式，当然对于通用的光线跟踪来说是远远不够的，但是它至少表示了这个算法如何使用的一个实例。</p>
<p><a name=.E5.8F.82.E8.A7.81></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%85%89%E7%BA%BF%E8%B7%9F%E8%B8%AA&amp;action=edit&amp;section=13" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>参见</span></h2>
<ul>
    <li><a class=new title="Actual state" href="http://zh.wikipedia.org/w/index.php?title=Actual_state&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Actual state</a></li>
    <li><a class=new title=光束跟踪 href="http://zh.wikipedia.org/w/index.php?title=%E5%85%89%E6%9D%9F%E8%B7%9F%E8%B8%AA&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">光束跟踪</a></li>
    <li><a class=new title=BRL-CAD href="http://zh.wikipedia.org/w/index.php?title=BRL-CAD&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">BRL-CAD</a></li>
    <li><a class=new title=锥体跟踪 href="http://zh.wikipedia.org/w/index.php?title=%E9%94%A5%E4%BD%93%E8%B7%9F%E8%B8%AA&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">锥体跟踪</a></li>
    <li><a class=new title=分布式光线跟踪 href="http://zh.wikipedia.org/w/index.php?title=%E5%88%86%E5%B8%83%E5%BC%8F%E5%85%89%E7%BA%BF%E8%B7%9F%E8%B8%AA&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">分布式光线跟踪</a></li>
    <li><a class=new title=整体光照 href="http://zh.wikipedia.org/w/index.php?title=%E6%95%B4%E4%BD%93%E5%85%89%E7%85%A7&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">整体光照</a></li>
    <li><a class=new title="Line-sphere intersection" href="http://zh.wikipedia.org/w/index.php?title=Line-sphere_intersection&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Line-sphere intersection</a></li>
    <li><a class=new title="Pencil tracing" href="http://zh.wikipedia.org/w/index.php?title=Pencil_tracing&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Pencil tracing</a></li>
    <li><a class=new title="Philipp Slusallek" href="http://zh.wikipedia.org/w/index.php?title=Philipp_Slusallek&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Philipp Slusallek</a></li>
    <li><a class=new title=光子映射 href="http://zh.wikipedia.org/w/index.php?title=%E5%85%89%E5%AD%90%E6%98%A0%E5%B0%84&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">光子映射</a></li>
    <li><a title=POV-Ray href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/POV-Ray'))" ??>POV-Ray</a></li>
    <li><a class=new title=Powerwall href="http://zh.wikipedia.org/w/index.php?title=Powerwall&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Powerwall</a></li>
    <li><a title=辐射着色 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%BE%90%E5%B0%84%E7%9D%80%E8%89%B2'))" ??>辐射着色</a></li>
    <li><a class=new title="Radiance (software)" href="http://zh.wikipedia.org/w/index.php?title=Radiance_%28software%29&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Radiance (software)</a></li>
    <li><a class=new title=光线跟踪硬件 href="http://zh.wikipedia.org/w/index.php?title=%E5%85%89%E7%BA%BF%E8%B7%9F%E8%B8%AA%E7%A1%AC%E4%BB%B6&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">光线跟踪硬件</a></li>
    <li><a title=反射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%8F%8D%E5%B0%84'))" ??>镜面反射与镜子</a></li>
    <li><a class=new title=球体跟踪 href="http://zh.wikipedia.org/w/index.php?title=%E7%90%83%E4%BD%93%E8%B7%9F%E8%B8%AA&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">球体跟踪</a></li>
    <li><a class=new title="Target state" href="http://zh.wikipedia.org/w/index.php?title=Target_state&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Target state</a></li>
    <li><a title=YafRay href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/YafRay'))" ??>YafRay</a></li>
</ul>
<p><a name=.E5.8F.82.E8.80.83.E6.96.87.E7.8C.AE></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%85%89%E7%BA%BF%E8%B7%9F%E8%B8%AA&amp;action=edit&amp;section=14" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>参考文献</span></h2>
<ul>
    <li>Glassner, Andrew (Ed.) (1989). <em>光线跟踪入门</em>. Academic Press. <a class=internal href="javascript:void(wb.w._link('http://zh.wikipedia.org/w/index.php?title=Special:Booksources&amp;isbn=0122861604'))" ??>ISBN 0-12-286160-4</a>.</li>
    <li>Shirley, Peter and Morley Keith, R. (2001) <em>Realistic Ray Tracing,2nd edition</em>. A.K. Peters. <a class=internal href="javascript:void(wb.w._link('http://zh.wikipedia.org/w/index.php?title=Special:Booksources&amp;isbn=1568811985'))" ??>ISBN 1-56881-198-5</a>.</li>
    <li>Henrik Wann Jensen. (2001) <em>Realistic image synthesis using photon mapping</em>. A.K. Peters. <a class=internal href="javascript:void(wb.w._link('http://zh.wikipedia.org/w/index.php?title=Special:Booksources&amp;isbn=1568811470'))" ??>ISBN 1-56881-147-0</a>.</li>
    <li>Pharr, Matt and Humphreys, Greg (2004). <em>Physically Based Rendering&nbsp;: From Theory to Implementation</em>. Morgan Kaufmann. <a class=internal href="javascript:void(wb.w._link('http://zh.wikipedia.org/w/index.php?title=Special:Booksources&amp;isbn=012553180X'))" ??>ISBN 0-12-553180-X</a>.</li>
</ul>
<p><a name=.E5.A4.96.E9.83.A8.E9.93.BE.E6.8E.A5></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%85%89%E7%BA%BF%E8%B7%9F%E8%B8%AA&amp;action=edit&amp;section=15" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>外部链接</span></h2>
<ul>
    <li><a class="external text" title=http://www.raytracingnews.org/ href="http://www.raytracingnews.org/" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">光线跟踪新闻</a> - 短小的研究文章以及新的资源链接</li>
    <li><a class="external text" title=http://graphics.cs.uni-sb.de/RTGames/ href="http://graphics.cs.uni-sb.de/RTGames/" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">使用实时光线跟踪的游戏</a></li>
    <li><a class="external text" title=http://www.devmaster.net/articles/raytracing_series/part1.php href="http://www.devmaster.net/articles/raytracing_series/part1.php" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">用 C++ 实现光线跟踪的系列教程</a></li>
    <li><a class="external text" title=http://irtc.org/ href="http://irtc.org/" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">The Internet Ray Tracing Competition</a> - 静止与动画分类</li>
</ul>
<p><a name=.E5.85.89.E7.BA.BF.E8.B7.9F.E8.B8.AA.E8.BD.AF.E4.BB.B6></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%85%89%E7%BA%BF%E8%B7%9F%E8%B8%AA&amp;action=edit&amp;section=16" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>光线跟踪软件</span></h3>
<ul>
    <li><a class="external text" title=http://www.blender.org/ href="http://www.blender.org/" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Blender</a></li>
    <li><a class="external text" title=http://www.povray.org/ href="http://www.povray.org/" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">POV-Ray</a></li>
    <li><a class="external text" title=http://pixie.sourceforge.net/ href="http://pixie.sourceforge.net/" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Pixie</a></li>
    <li><a class="external text" title=http://www.pbrt.org href="http://www.pbrt.org/" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">PBRT</a> - 基于物理的光线跟踪</li>
    <li><a class="external text" title=http://jedi.ks.uiuc.edu/~johns/raytracer href="http://jedi.ks.uiuc.edu/~johns/raytracer" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Tachyon</a></li>
    <li><a class="external text" title=http://graphics.stanford.edu/~cek/rayshade href="http://graphics.stanford.edu/~cek/rayshade" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Rayshade</a></li>
    <li><a class="external text" title=http://www.openrt.de/ href="http://www.openrt.de/" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">OpenRT</a> - 实时光线跟踪库</li>
    <li><a class="external text" title=http://www.renderplus/com href="http://www.renderplus/com" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">RPS Ray Tace</a> - 用于 <a class=new title=SketchUp href="http://zh.wikipedia.org/w/index.php?title=SketchUp&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">SketchUp</a> 的光线跟踪 <a class=new title=AccuRender href="http://zh.wikipedia.org/w/index.php?title=AccuRender&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">AccuRender</a></li>
    <li><a class="external text" title=http://www.bmsc.washington.edu/raster3d/raster3d.html href="http://www.bmsc.washington.edu/raster3d/raster3d.html" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Raster3D</a></li>
    <li><a class="external text" title=http://www.realstorm.com href="http://www.realstorm.com/" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">RealStorm Engine</a> - 实时光线跟踪引擎</li>
    <li><a class="external text" title=http://brlcad.org/ href="http://brlcad.org/" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">BRL-CAD</a></li>
    <li><a class="external text" title=http://www.acm.org/tog/Software.html#ray href="http://www.acm.org/tog/Software.html#ray" rel=nofollow>更多的光线跟踪源代码链接</a></li>
    <li><a class="external text" title=http://www.zemax.com/ href="http://www.zemax.com/" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Zemax</a></li>
    <li><a class="external text" title=http://radsite.lbl.gov/radiance/ href="http://radsite.lbl.gov/radiance/" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Radiance</a></li>
    <li><a class="external text" title=http://www.yafray.org href="http://www.yafray.org/" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Yafray</a></li>
    <li><a class="external text" title=http://www.lambdares.com/products/oslo/ href="http://www.lambdares.com/products/oslo/" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">OSLO</a> - 镜头设计与优化软件，OSLO-EDU 可以自由下载</li>
    <li><a class="external text" title=http://www.lambdares.com/products/tracepro/ href="http://www.lambdares.com/products/tracepro/" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">TracePro</a> - 带有 CAD 界面的散射光与照明软件</li>
</ul>
</div>
<img src ="http://www.cppblog.com/yaoming/aggbug/40110.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/yaoming/" target="_blank">姚明</a> 2008-01-01 06:16 <a href="http://www.cppblog.com/yaoming/archive/2008/01/01/40110.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>辐射着色</title><link>http://www.cppblog.com/yaoming/archive/2008/01/01/40109.html</link><dc:creator>姚明</dc:creator><author>姚明</author><pubDate>Mon, 31 Dec 2007 22:14:00 GMT</pubDate><guid>http://www.cppblog.com/yaoming/archive/2008/01/01/40109.html</guid><wfw:comment>http://www.cppblog.com/yaoming/comments/40109.html</wfw:comment><comments>http://www.cppblog.com/yaoming/archive/2008/01/01/40109.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/yaoming/comments/commentRss/40109.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/yaoming/services/trackbacks/40109.html</trackback:ping><description><![CDATA[<h1 class=firstHeading>辐射着色</h1>
<div id=bodyContent>
<h3 id=siteSub>&nbsp;</h3>
<div id=contentSub></div>
<p><strong>辐射着色（Radiosity）</strong>是一种<a class=new title=全局光照 href="http://zh.wikipedia.org/w/index.php?title=%E5%85%A8%E5%B1%80%E5%85%89%E7%85%A7&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">全局光照</a><a title=算法 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%AE%97%E6%B3%95'))" ??>算法</a>，用于<a title=三维计算机图形学 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E4%B8%89%E7%BB%B4%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9B%BE%E5%BD%A2%E5%AD%A6'))" ??>三维计算机图形学</a><a class=new title="绘制 (计算机图形学)" href="http://zh.wikipedia.org/w/index.php?title=%E7%BB%98%E5%88%B6_%28%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9B%BE%E5%BD%A2%E5%AD%A6%29&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">绘制</a>。和倾向于只在一个表面上模拟一次光的反射的<a class=new title=直接光照 href="http://zh.wikipedia.org/w/index.php?title=%E7%9B%B4%E6%8E%A5%E5%85%89%E7%85%A7&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">直接光照</a>算法(例如<a title=光线跟踪 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%85%89%E7%BA%BF%E8%B7%9F%E8%B8%AA'))" ??>光线跟踪</a>)不同，象辐射着色这样的<a class=new title=全局光照 href="http://zh.wikipedia.org/w/index.php?title=%E5%85%A8%E5%B1%80%E5%85%89%E7%85%A7&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">全局光照</a>算法模拟光在一个场景里的多次反射，通常会导致更柔和更自然的影子和反射。</p>
<p>辐射着色做为绘制方法是在1984年由<a title=康奈尔大学 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%BA%B7%E5%A5%88%E5%B0%94%E5%A4%A7%E5%AD%A6'))" ??>康奈尔大学</a>的研究人员(C. Goral, K. E. Torrance, D. P. Greenberg 和 B. Battaile)在他们的论文"Modeling the interaction of light between diffuse surfaces"(漫射表面之间的光线的交互的建模)中引入的。 该理论在工程中早有应用，用以解决<a class=new title=辐射热传导 href="http://zh.wikipedia.org/w/index.php?title=%E8%BE%90%E5%B0%84%E7%83%AD%E4%BC%A0%E5%AF%BC&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">辐射热传导</a>中的问题，始于约1950年。</p>
<p>突出的商用辐射着色引擎包括Lightscape (现已集成到Autodesk <a title="3D Studio Max" href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/3D_Studio_Max'))" ??>3D Studio Max</a>的内部绘制引擎中)，和更新的Next Limit的Maxwell~Renderer(麦克斯韦绘制器)。</p>
<p><a name=.E8.A7.86.E8.A7.89.E7.89.B9.E7.82.B9></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E8%BE%90%E5%B0%84%E7%9D%80%E8%89%B2&amp;action=edit&amp;section=1" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>视觉特点</span></h2>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 162px"><a class=image title=辐射着色的例子 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Radiosity.png'))" ??><img class=thumbimage height=120 alt=辐射着色的例子 src="http://upload.wikimedia.org/wikipedia/commons/d/de/Radiosity.png" width=160 border=0></a>
<div class=thumbcaption>辐射着色的例子</div>
</div>
</div>
<p>辐射度在绘制过程中的引入经常对最后的场景带来更多一份的真实感，这是因为它模拟真实世界现象的方式。考虑一个在白色地板上的红球。</p>
<p>光打在球上，投射出一个阴影，还有将一小部分红光反射到周围的物体上 - 在这个例子中，也就是地板。该现象给白色地板靠近球的地方加上了一点红色的<a title=色调 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%89%B2%E8%B0%83'))" ??>色调</a>。该效应是很微妙的，但因为人类的<a title=眼睛 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%9C%BC%E7%9D%9B'))" ??>眼睛</a>对于其真实世界的对应现象很习惯，它可以增加真实感。</p>
<p><br></p>
<p><a name=.E7.89.A9.E7.90.86.E7.89.B9.E7.82.B9></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E8%BE%90%E5%B0%84%E7%9D%80%E8%89%B2&amp;action=edit&amp;section=2" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>物理特点</span></h2>
<p>基本的辐射着色方法其基础在于<a title=熱 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%86%B1'))" ??>热辐射</a>的理论，因为辐射度依赖于两个表面之间光能的传输。为了简化计算，辐射度算法假设该数值在整个面片上恒定（完全或理想<a class=new title=漫射 href="http://zh.wikipedia.org/w/index.php?title=%E6%BC%AB%E5%B0%84&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">漫射</a>曲面）；这意味着要计算精确的图像，场景表述的几何部分必须分解成更小的区域，或者说面片，然后把它们组合起来得到最后的图像。</p>
<p>在这个分解之后，光能传输的量可以通过使用已知的反射表面的反射率和两个面片的<em>波形系数</em>来计算。波形系数是一个<a class=new title=无量纲量 href="http://zh.wikipedia.org/w/index.php?title=%E6%97%A0%E9%87%8F%E7%BA%B2%E9%87%8F&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">无量纲量</a>，它根据两个面片的几何朝向来计算，可以视为第一个面片所有可能发射区域的被第二个面片所覆盖的部分所占的比例。</p>
<p>更精确的讲，辐射度是每单位时间离开曲面片的能量，是发射和反射能量的组合：</p>
<dl>
<dd><img class=tex alt="B_i d A_i = E_i d A_i + R_i \int_j B_j F_{ji} d A_j\,\!" src="http://www.gollumbrowser.com/tc/math/d/e/1/de112c906a6744b7c9e4f611b8beeaed.png"></dd></dl>
<p>其中:</p>
<ul>
    <li>B<sub>i</sub> 是面片<em>i</em>的辐射度。</li>
    <li>E<sub>i</sub> 是发射的能量。</li>
    <li>R<sub>i</sub> 是面片的反射系数，和入射能量（从其他面片来的能量）相乘得到反射能量。</li>
    <li>所有绘制环境中的<em>j</em> (<img class=tex alt="j \ne i" src="http://www.gollumbrowser.com/tc/math/c/c/f/ccf5f455f5de788b5d5eeaf339059de1.png">)对于B<sub>j</sub>F<sub>ji</sub>dA<sub>j</sub>积分，得到离开每个面片<em>j</em>并到达面片<em>i</em>的能量。</li>
    <li>F<sub>ji</sub> 是面片<em>i</em>和面片<em>j</em>的几何关系决定的常数波形系数。</li>
</ul>
<p>对偶性：</p>
<dl>
<dd><img class=tex alt="F_{ij} A_i = F_{ji} A_j\,\!" src="http://www.gollumbrowser.com/tc/math/1/5/5/1552a2eb4aa4b355efe5489f02d1d830.png"></dd></dl>
<p>给出：</p>
<dl>
<dd><img class=tex alt="B_i = E_i + R_i \int_i B_j F_{ij}\,\!" src="http://www.gollumbrowser.com/tc/math/a/8/3/a83c1ff809c8bed2bff3015a58060121.png"></dd></dl>
<p>作为简化，<a title=积分 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%A7%AF%E5%88%86'))" ??>积分</a>用每个面片上恒定的辐射度取代，上式简化为：</p>
<dl>
<dd><img class=tex alt="B_i = E_i + R_i \sum_{j=1}^n B_j F_{ji}" src="http://www.gollumbrowser.com/tc/math/0/e/1/0e1be3bec869de472ddc38fd583d34da.png"></dd></dl>
<p>然后该方程可以应用到每个面片。这个方程是单色的，所以彩色辐射度需要对于每个所需的色彩进行计算。</p>
<p>常数F<sub>ji</sub>可以用几个计算方法。早期的方法采用<em><a class=new title=半立方体 href="http://zh.wikipedia.org/w/index.php?title=%E5%8D%8A%E7%AB%8B%E6%96%B9%E4%BD%93&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">半立方体</a></em> （一个假想的立方体中心位于第一个曲面，第二个曲面投影于其上，由Cohen 和Greenberg于1985年提出）以逼近波形系数，也解决了相交面片的问题。这在<a title=计算 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%AE%A1%E7%AE%97'))" ??>计算</a>上耗费很大，因为理想的<a class=new title=波形系数 href="http://zh.wikipedia.org/w/index.php?title=%E6%B3%A2%E5%BD%A2%E7%B3%BB%E6%95%B0&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">波形系数</a>必须对一个可能的面片对导出，这导致了对于增加的几何复杂度在计算上的<a class=new title=二次函数 href="http://zh.wikipedia.org/w/index.php?title=%E4%BA%8C%E6%AC%A1%E5%87%BD%E6%95%B0&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">二次</a>增长。</p>
<p><a name=.E5.A4.96.E9.83.A8.E9.93.BE.E6.8E.A5></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E8%BE%90%E5%B0%84%E7%9D%80%E8%89%B2&amp;action=edit&amp;section=3" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>外部链接</span></h2>
<ul>
    <li><a class="external text" title=http://www.siggraph.org/education/materials/HyperGraph/radiosity/overview_1.htm href="http://www.siggraph.org/education/materials/HyperGraph/radiosity/overview_1.htm" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Radiosity Overview，來自SIGGRAPH的HyperGraph</a> （提供Full Matrix Radiosity與Progressive Radiosity演算法）</li>
    <li><a class="external text" title=http://freespace.virgin.net/hugo.elias/radiosity/radiosity.htm href="http://freespace.virgin.net/hugo.elias/radiosity/radiosity.htm" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Radiosity，作者Hugo Elias</a> （也给出了光照算法的一般介绍，附带编程实例）</li>
    <li><a class="external text" title=http://web.cs.wpi.edu/~matt/courses/cs563/talks/radiosity.html href="http://web.cs.wpi.edu/~matt/courses/cs563/talks/radiosity.html" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Radiosity，作者Allen Martin</a> （更数学化的解释）</li>
    <li><a class="external text" title=http://www.cse.iitd.ernet.in/~parag/projects/CG2/asign2/report/RADical.shtml href="http://www.cse.iitd.ernet.in/~parag/projects/CG2/asign2/report/RADical.shtml" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">RADical，作者Parag Chaudhuri</a> （使用OpenGL加速的Shooting &amp; Sorting Progressive Radiosity演算法實作範例，該程式由Colbeck製作的GLUTRAD延伸而來）</li>
</ul>
</div>
<img src ="http://www.cppblog.com/yaoming/aggbug/40109.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/yaoming/" target="_blank">姚明</a> 2008-01-01 06:14 <a href="http://www.cppblog.com/yaoming/archive/2008/01/01/40109.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>折射</title><link>http://www.cppblog.com/yaoming/archive/2008/01/01/40107.html</link><dc:creator>姚明</dc:creator><author>姚明</author><pubDate>Mon, 31 Dec 2007 22:07:00 GMT</pubDate><guid>http://www.cppblog.com/yaoming/archive/2008/01/01/40107.html</guid><wfw:comment>http://www.cppblog.com/yaoming/comments/40107.html</wfw:comment><comments>http://www.cppblog.com/yaoming/archive/2008/01/01/40107.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/yaoming/comments/commentRss/40107.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/yaoming/services/trackbacks/40107.html</trackback:ping><description><![CDATA[<h1 class=firstHeading>折射</h1>
<div id=bodyContent>
<h3 id=siteSub>&nbsp;</h3>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 252px"><a class=image title=圖中所見的灰色棒插在水中，用眼睛觀看時好像屈曲了，這是光進入水時產生折射所致。 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Pencil_in_a_bowl_of_water.png'))" ??><img class=thumbimage height=159 alt=圖中所見的灰色棒插在水中，用眼睛觀看時好像屈曲了，這是光進入水時產生折射所致。 src="http://upload.wikimedia.org/wikipedia/commons/thumb/6/62/Pencil_in_a_bowl_of_water.png/250px-Pencil_in_a_bowl_of_water.png" width=250 border=0></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=放大 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Pencil_in_a_bowl_of_water.png'))" ??><img height=11 alt="" src="http://zh.wikipedia.org/skins-1.5/common/images/magnify-clip.png" width=15></a></div>
圖中所見的灰色棒插在水中，用眼睛觀看時好像屈曲了，這是光進入水時產生折射所致。</div>
</div>
</div>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 252px"><a class=image title=液体中的光线折射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Glass_is_Liquide.jpg'))" ??><img class=thumbimage height=188 alt=液体中的光线折射 src="http://upload.wikimedia.org/wikipedia/commons/thumb/d/d4/Glass_is_Liquide.jpg/250px-Glass_is_Liquide.jpg" width=250 border=0></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=放大 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Glass_is_Liquide.jpg'))" ??><img height=11 alt="" src="http://zh.wikipedia.org/skins-1.5/common/images/magnify-clip.png" width=15></a></div>
液体中的光线折射</div>
</div>
</div>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 252px"><a class=image title=光透過玻璃的折射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Uniformity.jpg'))" ??><img class=thumbimage height=166 alt=光透過玻璃的折射 src="http://upload.wikimedia.org/wikipedia/commons/thumb/2/2b/Uniformity.jpg/250px-Uniformity.jpg" width=250 border=0></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=放大 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Uniformity.jpg'))" ??><img height=11 alt="" src="http://zh.wikipedia.org/skins-1.5/common/images/magnify-clip.png" width=15></a></div>
光透過玻璃的折射</div>
</div>
</div>
<p><strong>折射</strong>（<a title=英語 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%8B%B1%E8%AA%9E'))" ??>英語</a>：<strong>refraction</strong>），又名<strong>屈折</strong>，是一個<a title=光學 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%85%89%E5%AD%B8'))" ??>光學</a>名詞，指<a title=光 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%85%89'))" ??>光</a>從一種<a title=介质 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E4%BB%8B%E8%B4%A8'))" ??>介質</a>進入另一種<a title=介质 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E4%BB%8B%E8%B4%A8'))" ??>介質</a>，或者在同一種介質中<a title=折射率 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%8A%98%E5%B0%84%E7%8E%87'))" ??>折射率</a>不同的部分運行時，由於<a title=波速 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%B3%A2%E9%80%9F'))" ??>波速</a>的差異，使光的運行方向改變的現象。例如當一條木棒插在水裡面時，單用肉眼看會以為木棒進入水中時折曲了，這是光進入水裡面時，產生折射，才帶來這種效果。</p>
<p>光在發生折射時<a title=入射角 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%85%A5%E5%B0%84%E8%A7%92'))" ??>入射角</a>與<a title=折射角 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%8A%98%E5%B0%84%E8%A7%92'))" ??>折射角</a>符合<a title=光的折射定律 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%85%89%E7%9A%84%E6%8A%98%E5%B0%84%E5%AE%9A%E5%BE%8B'))" ??>斯涅尔定律</a>（Snell's Law）。此定律指出<a title=光 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%85%89'))" ??>光</a>從<a title=真空 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%9C%9F%E7%A9%BA'))" ??>真空</a>進入某種<a title=介质 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E4%BB%8B%E8%B4%A8'))" ??>介質</a>發生<strong class=selflink>折射</strong>時，入射角i的正弦跟折射角r的正弦之比數，等於這種介質的折射率n。這項定律以如下公式顯示：</p>
<p><img class=tex alt=" \frac{\sin i}{\sin r}=n " src="http://www.gollumbrowser.com/tc/math/7/7/8/778d5e8ef860adb6e0a67afe6afabb2c.png"></p>
<p>這條公式被稱為斯涅爾公式。</p>
<p><a name=.E5.8F.83.E7.9C.8B></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%8A%98%E5%B0%84&amp;action=edit&amp;section=1" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>參看</span></h2>
<ul>
    <li><a title=光的折射定律 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%85%89%E7%9A%84%E6%8A%98%E5%B0%84%E5%AE%9A%E5%BE%8B'))" ??>光的折射定律</a></li>
    <li><a title=反射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%8F%8D%E5%B0%84'))" ??>反射</a></li>
</ul>
</div>
<img src ="http://www.cppblog.com/yaoming/aggbug/40107.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/yaoming/" target="_blank">姚明</a> 2008-01-01 06:07 <a href="http://www.cppblog.com/yaoming/archive/2008/01/01/40107.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>透明</title><link>http://www.cppblog.com/yaoming/archive/2008/01/01/40106.html</link><dc:creator>姚明</dc:creator><author>姚明</author><pubDate>Mon, 31 Dec 2007 22:06:00 GMT</pubDate><guid>http://www.cppblog.com/yaoming/archive/2008/01/01/40106.html</guid><wfw:comment>http://www.cppblog.com/yaoming/comments/40106.html</wfw:comment><comments>http://www.cppblog.com/yaoming/archive/2008/01/01/40106.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/yaoming/comments/commentRss/40106.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/yaoming/services/trackbacks/40106.html</trackback:ping><description><![CDATA[<h1 class=firstHeading>透明</h1>
<div id=bodyContent>
<h3 id=siteSub>&nbsp;</h3>
<div id=contentSub></div>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 302px"><a class=image title=透明玻璃球 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Glass-Ball.jpg'))" ??><img class=thumbimage height=363 alt=透明玻璃球 src="http://upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Glass-Ball.jpg/300px-Glass-Ball.jpg" width=300 border=0></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=放大 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Glass-Ball.jpg'))" ??><img height=11 alt="" src="http://zh.wikipedia.org/skins-1.5/common/images/magnify-clip.png" width=15></a></div>
透明玻璃球</div>
</div>
</div>
<p>在<a title=光学 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%85%89%E5%AD%A6'))" ??>光学</a>里，<strong>透明</strong>是允许<a title=光 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%85%89'))" ??>光</a>穿透的属性。透明材料可以被透视；即，它们允许明晰的图像穿过。相反的属性被称为<a class=new title=不透明性 href="http://zh.wikipedia.org/w/index.php?title=%E4%B8%8D%E9%80%8F%E6%98%8E%E6%80%A7&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">不透明性</a>。<strong>半透明</strong>材料只允许光散射穿透，即为，材料会扭曲图像。也被称为透明度，一个在矿物学中常用的术语。</p>
<p><a name=.E9.80.8F.E6.98.8E></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E9%80%8F%E6%98%8E&amp;action=edit&amp;section=1" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>透明</span></h2>
<p>虽然透明通常使用中指的是可见光，它可以正确的用于指代任何种类的辐射。例如，肉体对<a title=X光 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/X%E5%85%89'))" ??>X光</a>是透明的，但骨头却不是，使得<a title=医学成像 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%8C%BB%E5%AD%A6%E6%88%90%E5%83%8F'))" ??>X光成像</a>对医疗非常有用。</p>
<p>透明材料的例子有<a title=空气 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%A9%BA%E6%B0%94'))" ??>空气</a>和其他一些<a title=气体 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%B0%94%E4%BD%93'))" ??>气体</a>，<a title=液体 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%B6%B2%E4%BD%93'))" ??>液体</a>比如水，大多数<a title=玻璃 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%8E%BB%E7%92%83'))" ??>玻璃</a>，以及<a title=塑料 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%A1%91%E6%96%99'))" ??>塑料</a>诸如<a class=new title=Perspex href="http://zh.wikipedia.org/w/index.php?title=Perspex&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Perspex</a>和<a title=Pyrex href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Pyrex'))" ??>Pyrex</a>。对于透明度通常随光的<a title=波长 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%B3%A2%E9%95%BF'))" ??>波长</a>不同而改变的情形，透过该材料的图像会被染色。这是因为玻璃中一些金属氧化物分子，或者更大的着色粒子（比如稀薄的<a title=煙 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%85%99'))" ??>烟雾</a>）的存在。如果很多此类例子在材料中存在，则材料变得不透明，例如浓烟。</p>
<p>从<a title=量子电动力学 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E9%87%8F%E5%AD%90%E7%94%B5%E5%8A%A8%E5%8A%9B%E5%AD%A6'))" ??>电动力学</a>的结论而言，严格意义上仅有真空是真正透明的，任何物质都有一定的对<a title=电磁学 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%94%B5%E7%A3%81%E5%AD%A6'))" ??>电磁</a>波的吸收能力。</p>
<div class="thumb tleft">
<div class=thumbinner style="WIDTH: 202px"><a class=image title=一只带有透明翅膀的蝴蝶。能够透过翅膀清楚的看到躯干 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Butterfly_transparent.jpg'))" ??><img class=thumbimage height=150 alt=一只带有透明翅膀的蝴蝶。能够透过翅膀清楚的看到躯干 src="http://upload.wikimedia.org/wikipedia/commons/thumb/0/03/Butterfly_transparent.jpg/200px-Butterfly_transparent.jpg" width=200 border=0></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=放大 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Butterfly_transparent.jpg'))" ??><img height=11 alt="" src="http://zh.wikipedia.org/skins-1.5/common/images/magnify-clip.png" width=15></a></div>
一只带有透明翅膀的蝴蝶。能够透过翅膀清楚的看到躯干</div>
</div>
</div>
<p>有些透明<a title=玻璃 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%8E%BB%E7%92%83'))" ??>玻璃</a>墙可以通过是用电荷而被做成<a class=new title=不透明度 href="http://zh.wikipedia.org/w/index.php?title=%E4%B8%8D%E9%80%8F%E6%98%8E%E5%BA%A6&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">不透明的</a>，这种技术称为<a title=电致变色 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%94%B5%E8%87%B4%E5%8F%98%E8%89%B2'))" ??>电致变色显示（技术）</a>。</p>
<p>某些<a title=晶体 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%99%B6%E4%BD%93'))" ??>晶体</a>是透明的因为有很多直线穿过晶体结构所致。光可以沿着这些直线不受阻碍的穿过晶体。</p>
<p>有一种复杂的理论 "预言" (计算出) 不同材料的吸收与其光谱的相关性。参考：<a title=吸收 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%90%B8%E6%94%B6'))" ??>吸收</a> - 材料对<a title=光子 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%85%89%E5%AD%90'))" ??>光子</a>的吸收和<a class=new title=吸收光谱学 href="http://zh.wikipedia.org/w/index.php?title=%E5%90%B8%E6%94%B6%E5%85%89%E8%B0%B1%E5%AD%A6&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">吸收光谱学</a>。</p>
<p><a name=.E5.8D.8A.E9.80.8F.E6.98.8E></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E9%80%8F%E6%98%8E&amp;action=edit&amp;section=2" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>半透明</span></h2>
<p>透过半透明材料看到的图像是模糊或者扭曲的。半透明材料的例子包括霜化玻璃，<a title=纸 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%BA%B8'))" ??>纸</a> (<a title=透写纸 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E9%80%8F%E5%86%99%E7%BA%B8'))" ??>透写纸</a>)，以及一些种类的<a title=琥珀 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%90%A5%E7%8F%80'))" ??>琥珀</a>。有些时候辨别半透明物体有所不同。例如，很容易看出<a title=北极熊 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%8C%97%E6%9E%81%E7%86%8A'))" ??>北极熊</a>的皮毛是白色的，需要靠近看才能看出它其实是半透明的。不透明度的定义是基于材料对入射光的吸收或者反射。</p>
<p><a name=.E5.8F.82.E8.A7.81></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E9%80%8F%E6%98%8E&amp;action=edit&amp;section=3" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>参见</span></h2>
<ul>
    <li><a class=new title=Transmittance href="http://zh.wikipedia.org/w/index.php?title=Transmittance&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Transmittance</a></li>
    <li><a class=new title="Electromagnetically induced transparency" href="http://zh.wikipedia.org/w/index.php?title=Electromagnetically_induced_transparency&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Electromagnetically induced transparency</a></li>
    <li><a class=new title="Transparent alumina" href="http://zh.wikipedia.org/w/index.php?title=Transparent_alumina&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Transparent alumina</a></li>
    <li><a class=new title="Zone plate" href="http://zh.wikipedia.org/w/index.php?title=Zone_plate&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Zone plate</a></li>
    <li><a class=new title="List of optical topics" href="http://zh.wikipedia.org/w/index.php?title=List_of_optical_topics&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">List of optical topics</a></li>
    <li><a class=new title=不透明性 href="http://zh.wikipedia.org/w/index.php?title=%E4%B8%8D%E9%80%8F%E6%98%8E%E6%80%A7&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">不透明性</a></li>
</ul>
</div>
<img src ="http://www.cppblog.com/yaoming/aggbug/40106.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/yaoming/" target="_blank">姚明</a> 2008-01-01 06:06 <a href="http://www.cppblog.com/yaoming/archive/2008/01/01/40106.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>反射</title><link>http://www.cppblog.com/yaoming/archive/2008/01/01/40105.html</link><dc:creator>姚明</dc:creator><author>姚明</author><pubDate>Mon, 31 Dec 2007 22:05:00 GMT</pubDate><guid>http://www.cppblog.com/yaoming/archive/2008/01/01/40105.html</guid><wfw:comment>http://www.cppblog.com/yaoming/comments/40105.html</wfw:comment><comments>http://www.cppblog.com/yaoming/archive/2008/01/01/40105.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/yaoming/comments/commentRss/40105.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/yaoming/services/trackbacks/40105.html</trackback:ping><description><![CDATA[<h1 class=firstHeading>反射</h1>
<div id=bodyContent>
<div class="notice metadata" id=disambig style="FONT-SIZE: small">
<div class=floatleft><span></span>&nbsp;</div>
<div style="MARGIN: 0px 0px 0px 30px; TEXT-ALIGN: left">關於「反射」的其他意思，詳見「<strong><a title="反射 (消歧义)" href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%8F%8D%E5%B0%84_%28%E6%B6%88%E6%AD%A7%E4%B9%89%29'))" ??>反射 (消歧义)</a></strong>」。</div>
</div>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 152px"><a class=image title=反射現象 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Matterhorn_Riffelsee_2005-06-11.jpg'))" ??><img class=thumbimage height=227 alt=反射現象 src="http://upload.wikimedia.org/wikipedia/commons/thumb/4/4f/Matterhorn_Riffelsee_2005-06-11.jpg/150px-Matterhorn_Riffelsee_2005-06-11.jpg" width=150 border=0></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=放大 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Matterhorn_Riffelsee_2005-06-11.jpg'))" ??><img height=11 alt="" src="http://zh.wikipedia.org/skins-1.5/common/images/magnify-clip.png" width=15></a></div>
反射現象</div>
</div>
</div>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 172px"><a class=image title="&#952;i = &#952;r.入射角等於反射角" href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Reflection_angles.svg'))" ??><img class=thumbimage height=204 alt="&#952;i = &#952;r.入射角等於反射角" src="http://upload.wikimedia.org/wikipedia/commons/thumb/1/10/Reflection_angles.svg/170px-Reflection_angles.svg.png" width=170 border=0></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=放大 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Reflection_angles.svg'))" ??><img height=11 alt="" src="http://zh.wikipedia.org/skins-1.5/common/images/magnify-clip.png" width=15></a></div>
&#952;<sub>i</sub> = &#952;<sub>r</sub>.<br>入射角等於反射角</div>
</div>
</div>
<p><a title=波 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%B3%A2'))" ??>波</a>從一個<a title=介质 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E4%BB%8B%E8%B4%A8'))" ??>介質</a>進入另一個介質時，其傳播方向突然改變而回到其來源的介質，這種現象稱為<strong>反射</strong>。波被反射時會遵從<a title=反射定律 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%8F%8D%E5%B0%84%E5%AE%9A%E5%BE%8B'))" ??>反射定律</a>，即反射角等於其入射角。光線進入時反射的角度必與光線進入的角度相等。</p>
<p>反射按介質的特點可分為<a class=new title=鏡射 href="http://zh.wikipedia.org/w/index.php?title=%E9%8F%A1%E5%B0%84&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">鏡射</a>(specular)和<a class=new title=漫射 href="http://zh.wikipedia.org/w/index.php?title=%E6%BC%AB%E5%B0%84&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">漫射</a>(diffuse)。前者是在平滑的表面反射，反射時反射角會以同一方向進行；後者則是在不平滑的表面反射，各條光線的反射角方向會混亂。鏡射時平滑的表面會出現清晰的影像，而漫射時則會出影較模糊的影像。但不論鏡射或漫射，影像都與真實物體倒轉。</p>
<p><a title=電磁波 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E9%9B%BB%E7%A3%81%E6%B3%A2'))" ??>電磁波</a>（<a title=光 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%85%89'))" ??>光</a>）、<a title=声波 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%A3%B0%E6%B3%A2'))" ??>聲波</a>或<a class=new title=水波 href="http://zh.wikipedia.org/w/index.php?title=%E6%B0%B4%E6%B3%A2&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">水波</a>的反射是經常被觀察到和被利用的。</p>
<p><a name=.E4.BA.8B.E4.BE.8B></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%8F%8D%E5%B0%84&amp;action=edit&amp;section=1" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>事例</span></h2>
<ul>
    <li><a title=鏡子 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E9%8F%A1%E5%AD%90'))" ??>鏡子</a>照出來之影像乃反射的典型例子。</li>
    <li>平靜的水面也能產生出反射的現象。</li>
</ul>
<p><a name=.E5.8F.83.E7.9C.8B></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%8F%8D%E5%B0%84&amp;action=edit&amp;section=2" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>參看</span></h2>
<ul>
    <li><a title=反射定律 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%8F%8D%E5%B0%84%E5%AE%9A%E5%BE%8B'))" ??>反射定律</a></li>
    <li><a title=折射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%8A%98%E5%B0%84'))" ??>折射</a></li>
    <li><a title=光的折射定律 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%85%89%E7%9A%84%E6%8A%98%E5%B0%84%E5%AE%9A%E5%BE%8B'))" ??>光的折射定律</a></li>
</ul>
</div>
<img src ="http://www.cppblog.com/yaoming/aggbug/40105.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/yaoming/" target="_blank">姚明</a> 2008-01-01 06:05 <a href="http://www.cppblog.com/yaoming/archive/2008/01/01/40105.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>距离模糊</title><link>http://www.cppblog.com/yaoming/archive/2008/01/01/40104.html</link><dc:creator>姚明</dc:creator><author>姚明</author><pubDate>Mon, 31 Dec 2007 22:01:00 GMT</pubDate><guid>http://www.cppblog.com/yaoming/archive/2008/01/01/40104.html</guid><wfw:comment>http://www.cppblog.com/yaoming/comments/40104.html</wfw:comment><comments>http://www.cppblog.com/yaoming/archive/2008/01/01/40104.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/yaoming/comments/commentRss/40104.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/yaoming/services/trackbacks/40104.html</trackback:ping><description><![CDATA[<h1 class=firstHeading>距离模糊</h1>
<div id=bodyContent>
<h3 id=siteSub>&nbsp;</h3>
<p><strong>距离模糊</strong>是<a title=三维计算机图形学 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E4%B8%89%E7%BB%B4%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9B%BE%E5%BD%A2%E5%AD%A6'))" ??>三维计算机图形学</a>中用来增强距离<a class=new title=深度感 href="http://zh.wikipedia.org/w/index.php?title=%E6%B7%B1%E5%BA%A6%E6%84%9F&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">深度感</a>的一项技术。</p>
<p>由于图形环境中的许多形状相对来说比较简单，并且难于<a title=渲染 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%B8%B2%E6%9F%93'))" ??>渲染</a>复杂的阴影，所以许多图形处理引擎都使用了&#8220;模糊&#8221;梯度，距离照相机越远的物体渐进地被雾化而变得模糊。它的原理是由于光的<a title=衍射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%A1%8D%E5%B0%84'))" ??>衍射</a>效应，距离越远的物体看起来越模糊，尤其是在户外环境中更是这样。</p>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 182px"><a class=image title=距离模糊实例 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:CGfog.jpg'))" ??><img class=thumbimage height=82 alt=距离模糊实例 src="http://upload.wikimedia.org/wikipedia/commons/thumb/c/c5/CGfog.jpg/180px-CGfog.jpg" width=180 border=0></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=放大 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:CGfog.jpg'))" ??><img height=11 alt="" src="http://zh.wikipedia.org/skins-1.5/common/images/magnify-clip.png" width=15></a></div>
距离模糊实例</div>
</div>
</div>
<p><em>雾化</em>在距离模糊在<a title=1990年代 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/1990%E5%B9%B4%E4%BB%A3'))" ??>1990年代</a>中期到末期游戏中的另外一项应用，当时处理能力不够强大，无法渲染远距离的场景，所以就使用了<a class=new title=Clipping href="http://zh.wikipedia.org/w/index.php?title=Clipping&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">clipping</a>方法，但是这种方法的效果非常不好。通过使用中等程度的模糊，被裁剪的多边形能够更加接近真实地逐渐消失，尽管在有些场合看起来仍然不够真实。许多早期的 <a title="Nintendo 64" href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Nintendo_64'))" ??>Nintendo 64</a> 游戏都使用了这种效果，比较著名的有 <a class=new title="Turok: Dinosaur Hunter" href="http://zh.wikipedia.org/w/index.php?title=Turok:_Dinosaur_Hunter&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Turok: Dinosaur Hunter</a> 以及 <a class=new title="Superman 64" href="http://zh.wikipedia.org/w/index.php?title=Superman_64&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Superman 64</a>。</p>
<p><a name=.E5.8F.82.E8.A7.81></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E8%B7%9D%E7%A6%BB%E6%A8%A1%E7%B3%8A&amp;action=edit&amp;section=1" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>参见</span></h2>
<ul>
    <li><a title=计算机图形学 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9B%BE%E5%BD%A2%E5%AD%A6'))" ??>计算机图形学</a></li>
    <li><a title=虚拟现实 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%99%9A%E6%8B%9F%E7%8E%B0%E5%AE%9E'))" ??>虚拟现实</a></li>
</ul>
</div>
<img src ="http://www.cppblog.com/yaoming/aggbug/40104.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/yaoming/" target="_blank">姚明</a> 2008-01-01 06:01 <a href="http://www.cppblog.com/yaoming/archive/2008/01/01/40104.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>凸凹纹理映射</title><link>http://www.cppblog.com/yaoming/archive/2008/01/01/40103.html</link><dc:creator>姚明</dc:creator><author>姚明</author><pubDate>Mon, 31 Dec 2007 21:56:00 GMT</pubDate><guid>http://www.cppblog.com/yaoming/archive/2008/01/01/40103.html</guid><wfw:comment>http://www.cppblog.com/yaoming/comments/40103.html</wfw:comment><comments>http://www.cppblog.com/yaoming/archive/2008/01/01/40103.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cppblog.com/yaoming/comments/commentRss/40103.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/yaoming/services/trackbacks/40103.html</trackback:ping><description><![CDATA[<h1 class=firstHeading>凸凹纹理映射</h1>
<div id=bodyContent>
<h3 id=siteSub>&nbsp;</h3>
<div id=contentSub></div>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 162px"><a class=image title=不带凸凹纹理映射的球体 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Bump-map-demo-smooth.png'))" ??><img class=thumbimage height=160 alt=不带凸凹纹理映射的球体 src="http://upload.wikimedia.org/wikipedia/zh/b/b3/Bump-map-demo-smooth.png" width=160 border=0></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=放大 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Bump-map-demo-smooth.png'))" ??><img height=11 alt="" src="http://zh.wikipedia.org/skins-1.5/common/images/magnify-clip.png" width=15></a></div>
不带凸凹纹理映射的球体</div>
</div>
</div>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 162px"><a class=image title=下图所用的凸凹纹理 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Orange-bumpmap.png'))" ??><img class=thumbimage height=160 alt=下图所用的凸凹纹理 src="http://upload.wikimedia.org/wikipedia/zh/thumb/0/0c/Orange-bumpmap.png/160px-Orange-bumpmap.png" width=160 border=0></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=放大 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Orange-bumpmap.png'))" ??><img height=11 alt="" src="http://zh.wikipedia.org/skins-1.5/common/images/magnify-clip.png" width=15></a></div>
下图所用的凸凹纹理</div>
</div>
</div>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 162px"><a class=image title=这个使用凸凹纹理映射的球体几何上与上面的球体一模一样，这改变了球体的浓淡效果，使它看起来象一个橙子 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Bump-map-demo-bumpy.png'))" ??><img class=thumbimage height=160 alt=这个使用凸凹纹理映射的球体几何上与上面的球体一模一样，这改变了球体的浓淡效果，使它看起来象一个橙子 src="http://upload.wikimedia.org/wikipedia/zh/3/30/Bump-map-demo-bumpy.png" width=160 border=0></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=放大 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Bump-map-demo-bumpy.png'))" ??><img height=11 alt="" src="http://zh.wikipedia.org/skins-1.5/common/images/magnify-clip.png" width=15></a></div>
这个使用凸凹纹理映射的球体几何上与上面的球体一模一样，这改变了球体的浓淡效果，使它看起来象一个<a title=橙 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%A9%99'))" ??>橙子</a></div>
</div>
</div>
<p><strong>凸凹纹理映射</strong>（bump mapping），又稱為<strong>皺面貼圖</strong>，是一项<a title=计算机图形学 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9B%BE%E5%BD%A2%E5%AD%A6'))" ??>计算机图形学</a>技术，在这项技术中每个待<a title=渲染 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%B8%B2%E6%9F%93'))" ??>渲染</a>的像素在计算照明之前都要加上一个从<a class=new title=高度图 href="http://zh.wikipedia.org/w/index.php?title=%E9%AB%98%E5%BA%A6%E5%9B%BE&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">高度图</a>中找到的扰动。这样得到的结果表面表现更加丰富、细致，更加接近物体在自然界本身的模样。<a title=法向映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%B3%95%E5%90%91%E6%98%A0%E5%B0%84'))" ??>法向映射</a>是一项常用的凸凹纹理映射技术，另外还有许多其它的实现技术，如<a title=视差映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%A7%86%E5%B7%AE%E6%98%A0%E5%B0%84'))" ??>视差映射</a>等等。</p>
<p><a title=位移映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E4%BD%8D%E7%A7%BB%E6%98%A0%E5%B0%84'))" ??>位移映射</a>与凸凹纹理映射之间区别在例图中已经很明显地显现出来了：在凸凹纹理映射中，只有法线进行了扰动，而几何体本身没有扰动，这样的结果就是人为改变只出现在物体的轮廓上，而球体本身仍然是原来的圆形。</p>
<p><a name=.E5.81.87.E5.87.B8.E5.87.B9.E7.BA.B9.E7.90.86.E6.98.A0.E5.B0.84></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%87%B8%E5%87%B9%E7%BA%B9%E7%90%86%E6%98%A0%E5%B0%84&amp;action=edit&amp;section=1" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>假凸凹纹理映射</span></h2>
<p><a title=三维计算机图形 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E4%B8%89%E7%BB%B4%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9B%BE%E5%BD%A2'))" ??>三维计算机图形</a>程序员有时使用计算量较小的假凸凹纹理映射模拟凸凹纹理映射效果。其中一个方法是使用<a title=纹素 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%BA%B9%E7%B4%A0'))" ??>纹素</a>索引变化取代曲面法线变化，这种方法经常用于二维凸凹纹理映射。在 <a title="GeForce 2" href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/GeForce_2'))" ??>GeForce 2</a> 类型的图形加速硬件中就使用了这项技术。</p>
<p>全屏的二维假凸凹纹理映射，可以很容易地用简单快速的渲染循环实现，在二十世纪九十年代的 <a class=new title="Demo (computer programming)" href="http://zh.wikipedia.org/w/index.php?title=Demo_%28computer_programming%29&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Demo (computer programming)</a> 是一个非常普通的 <a class=new title="Demo effect" href="http://zh.wikipedia.org/w/index.php?title=Demo_effect&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">视觉效果</a>。</p>
<p><a name=.E5.8F.82.E8.80.83.E6.96.87.E7.8C.AE></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%87%B8%E5%87%B9%E7%BA%B9%E7%90%86%E6%98%A0%E5%B0%84&amp;action=edit&amp;section=2" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>参考文献</span></h2>
<ul>
    <li>Blinn, James F. "皱纹表面模拟", Computer Graphics, Vol. 12 (3), pp. 286-292 SIGGRAPH-ACM (August 1978) </li>
</ul>
<p><a name=.E9.93.BE.E6.8E.A5></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%87%B8%E5%87%B9%E7%BA%B9%E7%90%86%E6%98%A0%E5%B0%84&amp;action=edit&amp;section=3" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>链接</span></h2>
<ul>
    <li><a class="external free" title=http://www.jawed.com/bump/ href="http://www.jawed.com/bump/" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">http://www.jawed.com/bump/</a> Java 语言实现的实时凸凹纹理映射示例（包括源代码）
    <li><a class="external free" title=http://www.blacksmith-studios.dk/projects/downloads/bumpmapping_using_cg.php href="http://www.blacksmith-studios.dk/projects/downloads/bumpmapping_using_cg.php" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">http://www.blacksmith-studios.dk/projects/downloads/bumpmapping_using_cg.php</a> Bump Mapping tutorial using CG and C++ </li>
</ul>
<p><a name=.E5.8F.82.E8.A7.81></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E5%87%B8%E5%87%B9%E7%BA%B9%E7%90%86%E6%98%A0%E5%B0%84&amp;action=edit&amp;section=4" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>参见</span></h2>
<ul>
    <li><a title=纹理映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%BA%B9%E7%90%86%E6%98%A0%E5%B0%84'))" ??>纹理映射</a>
    <li><a title=法向映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%B3%95%E5%90%91%E6%98%A0%E5%B0%84'))" ??>法向映射</a>
    <li><a title=视差映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%A7%86%E5%B7%AE%E6%98%A0%E5%B0%84'))" ??>视差映射</a>
    <li><a title=位移映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E4%BD%8D%E7%A7%BB%E6%98%A0%E5%B0%84'))" ??>位移映射</a>
    <li><a class=new title=浮雕纹理映射 href="http://zh.wikipedia.org/w/index.php?title=%E6%B5%AE%E9%9B%95%E7%BA%B9%E7%90%86%E6%98%A0%E5%B0%84&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">浮雕纹理映射</a> </li>
</ul>
</div>
<img src ="http://www.cppblog.com/yaoming/aggbug/40103.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/yaoming/" target="_blank">姚明</a> 2008-01-01 05:56 <a href="http://www.cppblog.com/yaoming/archive/2008/01/01/40103.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>纹理映射</title><link>http://www.cppblog.com/yaoming/archive/2008/01/01/40102.html</link><dc:creator>姚明</dc:creator><author>姚明</author><pubDate>Mon, 31 Dec 2007 21:54:00 GMT</pubDate><guid>http://www.cppblog.com/yaoming/archive/2008/01/01/40102.html</guid><wfw:comment>http://www.cppblog.com/yaoming/comments/40102.html</wfw:comment><comments>http://www.cppblog.com/yaoming/archive/2008/01/01/40102.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/yaoming/comments/commentRss/40102.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/yaoming/services/trackbacks/40102.html</trackback:ping><description><![CDATA[<h1 class=firstHeading>纹理映射</h1>
<div id=bodyContent>
<h3 id=siteSub>&nbsp;</h3>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 161px"><a class=image title=球面纹理映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:SphericalTextureMapping.png'))" ??><img class=thumbimage height=360 alt=球面纹理映射 src="http://upload.wikimedia.org/wikipedia/zh/6/69/SphericalTextureMapping.png" width=159 border=0></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=放大 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:SphericalTextureMapping.png'))" ??><img height=11 alt="" src="http://zh.wikipedia.org/skins-1.5/common/images/magnify-clip.png" width=15></a></div>
球面纹理映射</div>
</div>
</div>
<p>在<a title=计算机图形学 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9B%BE%E5%BD%A2%E5%AD%A6'))" ??>计算机图形学</a>中，<strong>纹理映射(texture mapping)</strong>把存储在内存里的<a title=位图 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E4%BD%8D%E5%9B%BE'))" ??>位图</a>包裹到3D渲染物体的表面。<a class=new title=纹理 href="http://zh.wikipedia.org/w/index.php?title=%E7%BA%B9%E7%90%86&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">纹理</a>给物体提供了丰富的细节，用简单的方式模拟出了复杂的外观。一个图像（纹理）被贴(映射)到场景中的一个简单形体上，就像印花贴到一个平面上一样。这大大减少了在场景中制作形体和纹理的计算量。例如，可以建立一个球并把脸的纹理贴上去，这样就不用处理鼻子和眼睛的形状了。</p>
<p>随着<a title=图形卡 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%9B%BE%E5%BD%A2%E5%8D%A1'))" ??>图形卡</a>功能越来越强，理论上纹理映射变得越来越不必要，而三维绘制(渲染)成了常用的工具。但事实上，最近的趋势是使用更大和更多的纹理图像，再加上把多幅纹理组合到同个物体的不同角度的复杂技术。(这在实时图形学中更为重要，因为同时显示的纹理个数是可用图形内存容量的函数。)</p>
<p>最后显示在屏幕上的<a title=像素 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%83%8F%E7%B4%A0'))" ??>像素</a>是从纹理的<a class=new title=Texel href="http://zh.wikipedia.org/w/index.php?title=Texel&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">texel</a>中计算的，这由<a class=new title=纹理滤波 href="http://zh.wikipedia.org/w/index.php?title=%E7%BA%B9%E7%90%86%E6%BB%A4%E6%B3%A2&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">纹理滤波</a>决定。最快的方法是每个<a title=像素 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%83%8F%E7%B4%A0'))" ??>像素</a>使用一个texel，线性插值也很常用，还有更复杂的办法，参看<a class=new title=MIPMAP href="http://zh.wikipedia.org/w/index.php?title=MIPMAP&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">MIPMAP</a>。另外，纹理也可用来决定模型表面的颜色，甚至双向反射分布函数(BRDF)，从而和光照模型等方法结合起来。</p>
<p><a name=.E4.BE.8B.E5.AD.90.E4.BB.A3.E7.A0.81></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E7%BA%B9%E7%90%86%E6%98%A0%E5%B0%84&amp;action=edit&amp;section=1" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>例子代码</span></h2>
<p>下面是简单的纹理映射的<a title=Java href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Java'))" ??>Java</a>语言实现。</p>
<pre>public double[] sphereMap(double x, double y, double z, int radius)
{
/* x,y,z 是球面的法向量乘以它的半径*/
/* 也就是 vec3 (intersect_pointv3-sphere_centre_pointv3)                */
double u, v;
v = Math.acos(z/radius) / PI;
if (y &gt; 0.0) {
u = Math.acos(x/(radius * Math.sin(PI * v))) / PI*2;
}
else {
u = (PI + Math.acos(x/(radius * Math.sin(PI * v)))) / PI*2;
}
return new double[] { u, v };
}
</pre>
<p><a name=.E5.8F.82.E7.9C.8B></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E7%BA%B9%E7%90%86%E6%98%A0%E5%B0%84&amp;action=edit&amp;section=2" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>参看</span></h2>
<ul>
    <li><a class=new title="Edwin Catmull" href="http://zh.wikipedia.org/w/index.php?title=Edwin_Catmull&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Edwin Catmull</a></li>
    <li><a class=new title=纹理滤波 href="http://zh.wikipedia.org/w/index.php?title=%E7%BA%B9%E7%90%86%E6%BB%A4%E6%B3%A2&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">纹理滤波</a></li>
</ul>
<p><a name=.E5.A4.96.E9.83.A8.E9.93.BE.E6.8E.A5></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E7%BA%B9%E7%90%86%E6%98%A0%E5%B0%84&amp;action=edit&amp;section=3" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>外部链接</span></h2>
<ul>
    <li><a class="external text" title=http://www.cs.unc.edu/~rademach/xroads-RT/RTarticle.html href="http://www.cs.unc.edu/~rademach/xroads-RT/RTarticle.html" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Graphics for the Masses by Paul Rademacher</a></li>
    <li><a class="external text" title=http://www.mayang.com/textures/ href="http://www.mayang.com/textures/" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">High resolution textures resource</a></li>
    <li><a class="external text" title=http://www.imageafter.com/ href="http://www.imageafter.com/" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">High resolution images and textures resource</a></li>
    <li><a class="external text" title=http://www.texturehound.com/ href="http://www.texturehound.com/" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Texture Hound |Utlimate 3d Texture Links Directory</a></li>
</ul>
</div>
<img src ="http://www.cppblog.com/yaoming/aggbug/40102.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/yaoming/" target="_blank">姚明</a> 2008-01-01 05:54 <a href="http://www.cppblog.com/yaoming/archive/2008/01/01/40102.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>浓淡处理</title><link>http://www.cppblog.com/yaoming/archive/2008/01/01/40101.html</link><dc:creator>姚明</dc:creator><author>姚明</author><pubDate>Mon, 31 Dec 2007 21:51:00 GMT</pubDate><guid>http://www.cppblog.com/yaoming/archive/2008/01/01/40101.html</guid><wfw:comment>http://www.cppblog.com/yaoming/comments/40101.html</wfw:comment><comments>http://www.cppblog.com/yaoming/archive/2008/01/01/40101.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/yaoming/comments/commentRss/40101.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/yaoming/services/trackbacks/40101.html</trackback:ping><description><![CDATA[<h1 class=firstHeading>浓淡处理</h1>
<div id=bodyContent>
<h3 id=siteSub>&nbsp;</h3>
<p><strong>浓淡处理</strong>是在三维模型中通过改变亮度表现深度的方法。</p>
<p><a name=.E7.BB.98.E5.9B.BE></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B5%93%E6%B7%A1%E5%A4%84%E7%90%86&amp;action=edit&amp;section=1" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>绘图</span></h2>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 177px"><a class=image title=浓淡处理实例 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Shading1.jpg'))" ??><img class=thumbimage height=104 alt=浓淡处理实例 src="http://upload.wikimedia.org/wikipedia/commons/thumb/7/7b/Shading1.jpg/175px-Shading1.jpg" width=175 border=0></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=放大 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Shading1.jpg'))" ??><img height=11 alt="" src="http://zh.wikipedia.org/skins-1.5/common/images/magnify-clip.png" width=15></a></div>
浓淡处理实例</div>
</div>
</div>
<p><strong>浓淡处理</strong>是用较大压力在纸上绘制较深颜色、用较小压力绘制较浅颜色从而表示不同明暗程度的过程。有许多不同的浓淡处理技术，其中<a class=new title=影线 href="http://zh.wikipedia.org/w/index.php?title=%E5%BD%B1%E7%BA%BF&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">交叉影线</a>是用不同距离互相垂直的网格线绘制不同区域的浓淡。影线距离越近，所绘制区域越暗；相反，距离越远，所绘制区域越亮。这个术语近来用来泛指使用<a class=new title=浓淡工具 href="http://zh.wikipedia.org/w/index.php?title=%E6%B5%93%E6%B7%A1%E5%B7%A5%E5%85%B7&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">浓淡工具</a>的场合。</p>
<p>物体都有照亮区域以及阴影区域这样不同的光照模式，这种现象可以用于在纸上以及计算机屏幕上显示不同的深度。</p>
<p><a name=.E8.AE.A1.E7.AE.97.E6.9C.BA.E5.9B.BE.E5.BD.A2.E5.AD.A6></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B5%93%E6%B7%A1%E5%A4%84%E7%90%86&amp;action=edit&amp;section=2" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>计算机图形学</span></h2>
<p>在计算机图形学中，<strong>浓淡处理</strong>表示根据物体相对于光线的角度及其距离光源距离改变物体颜色生成<a class=new title=Photorealistic href="http://zh.wikipedia.org/w/index.php?title=Photorealistic&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">photorealistic</a>效果的过程。浓淡处理是在<a title=渲染 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%B8%B2%E6%9F%93'))" ??>渲染</a>过程中完成的。</p>
<p><a name=.E7.9B.B8.E5.AF.B9.E4.BA.8E.E5.85.89.E6.BA.90.E7.9A.84.E8.A7.92.E5.BA.A6></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B5%93%E6%B7%A1%E5%A4%84%E7%90%86&amp;action=edit&amp;section=3" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>相对于光源的角度</span></h3>
<p>根据物体表面相对于太阳光或者其它光源的角度不同，浓淡处理过程改变三维模型中的表面颜色。</p>
<p>下面的第一张图中的盒子的每个表面都用同一种颜色进行渲染，画出边线是为了易于观看。 第二张图是同一张模型，但是没有绘制边线。我们很难分辨出这张图的每一个表面。 第三种进行了浓淡处理，这样图像看起来更加真实，也易于分辨每个表面。</p>
<div class="thumb tleft">
<div class=thumbinner style="WIDTH: 229px"><a class=image title=盒子的渲染图像，没有进行浓淡处理，但是绘制了边线以分割表面 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Shading1.png'))" ??><img class=thumbimage height=208 alt=盒子的渲染图像，没有进行浓淡处理，但是绘制了边线以分割表面 src="http://upload.wikimedia.org/wikipedia/commons/d/df/Shading1.png" width=227 border=0></a>
<div class=thumbcaption>盒子的渲染图像，没有进行浓淡处理，但是绘制了边线以分割表面</div>
</div>
</div>
<div class="thumb tleft">
<div class=thumbinner style="WIDTH: 229px"><a class=image title=同第一幅图像一样，但是没有绘制边线 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Shading2.PNG'))" ??><img class=thumbimage height=208 alt=同第一幅图像一样，但是没有绘制边线 src="http://upload.wikimedia.org/wikipedia/commons/8/87/Shading2.PNG" width=227 border=0></a>
<div class=thumbcaption>同第一幅图像一样，但是没有绘制边线</div>
</div>
</div>
<div class="thumb tleft">
<div class=thumbinner style="WIDTH: 229px"><a class=image title=同一模型根据三个表面相对于光源的角度进行了浓淡处理得到的图像 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Shading3.PNG'))" ??><img class=thumbimage height=208 alt=同一模型根据三个表面相对于光源的角度进行了浓淡处理得到的图像 src="http://upload.wikimedia.org/wikipedia/commons/2/2c/Shading3.PNG" width=227 border=0></a>
<div class=thumbcaption>同一模型根据三个表面相对于光源的角度进行了浓淡处理得到的图像</div>
</div>
</div>
<p><br clear=all></p>
<p><a id=Distance_Falloff name=Distance_Falloff></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B5%93%E6%B7%A1%E5%A4%84%E7%90%86&amp;action=edit&amp;section=4" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>Distance Falloff</span></h3>
<p>理论上讲，如太阳这样的远距离光源对于两个平行表面的的照明是等同的，尽管其中一个表面可能较远，但是在空间中可以看到更多的部分，因此照明仍然看起来是一样的。</p>
<p>注意在第一幅图中，两个盒子正面的颜色是完全相同的。但是在两个表面相交的地方看起来颜色有些差别，这是因为在两个表面相交部分下面还有一段竖直边缘带来的视觉幻觉。</p>
<p>在第二幅图中，前面盒子的正面比后面盒子的正面要亮，并且地板也从前到后逐渐变暗。</p>
<p>这种 Distance Falloff 效果生成的图像看起来更加真实，并且不需要添加额外的照明来实现同样的效果。<br clear=all></p>
<div class="thumb tleft">
<div class=thumbinner style="WIDTH: 262px"><a class=image title="使用 OpenGL 渲染工具生成的两个盒子。 注意尽管其中一个盒子距离较远，但是它们的正面颜色仍是相同的" href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:2squares-1.jpg'))" ??><img class=thumbimage height=224 alt="使用 OpenGL 渲染工具生成的两个盒子。 注意尽管其中一个盒子距离较远，但是它们的正面颜色仍是相同的" src="http://upload.wikimedia.org/wikipedia/commons/0/06/2squares-1.jpg" width=260 border=0></a>
<div class=thumbcaption>使用 OpenGL <a class=new title=渲染工具 href="http://zh.wikipedia.org/w/index.php?title=%E6%B8%B2%E6%9F%93%E5%B7%A5%E5%85%B7&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">渲染工具</a>生成的两个盒子。 注意尽管其中一个盒子距离较远，但是它们的正面颜色仍是相同的</div>
</div>
</div>
<div class="thumb tleft">
<div class=thumbinner style="WIDTH: 284px"><a class=image title='用 ARRIS CAD 渲染的同一模型，它实现了 "Distance Falloff" 从而距离较近的表面看起来更加明亮' href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:2squares-2.jpg'))" ??><img class=thumbimage height=243 alt='用 ARRIS CAD 渲染的同一模型，它实现了 "Distance Falloff" 从而距离较近的表面看起来更加明亮' src="http://upload.wikimedia.org/wikipedia/commons/0/02/2squares-2.jpg" width=282 border=0></a>
<div class=thumbcaption>用 ARRIS CAD 渲染的同一模型，它实现了 "Distance Falloff" 从而距离较近的表面看起来更加明亮</div>
</div>
</div>
<p><br clear=all></p>
<p><a name=.E5.85.89.E6.BA.90></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B5%93%E6%B7%A1%E5%A4%84%E7%90%86&amp;action=edit&amp;section=5" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>光源</span></h3>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 202px"><a class=image title=泛光照明的浓淡效果 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Floodlight.png'))" ??><img class=thumbimage height=300 alt=泛光照明的浓淡效果 src="http://upload.wikimedia.org/wikipedia/commons/1/1b/Floodlight.png" width=200 border=0></a>
<div class=thumbcaption>泛光照明的浓淡效果</div>
</div>
</div>
<p>OpenGL 有可以处理太阳光的阴影的接口，但是使用<a title=光线跟踪 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%85%89%E7%BA%BF%E8%B7%9F%E8%B8%AA'))" ??>光线跟踪</a><a class=new title=渲染工具 href="http://zh.wikipedia.org/w/index.php?title=%E6%B8%B2%E6%9F%93%E5%B7%A5%E5%85%B7&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">渲染工具</a>时我们可以添加灯泡、泛光灯以及聚光灯。</p>
<p>根据物体表面相对于光源的角度、光源的距离以及泛光灯光束角的不同物体表面亮度也有所不同。<br clear=all></p>
<div class="thumb tright">
<div class=thumbinner style="WIDTH: 302px"><a class=image title="Flat 浓淡插值实例" href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Phong-shading-sample.jpg'))" ??><img class=thumbimage height=130 alt="Flat 浓淡插值实例" src="http://upload.wikimedia.org/wikipedia/commons/thumb/8/84/Phong-shading-sample.jpg/300px-Phong-shading-sample.jpg" width=300 border=0></a>
<div class=thumbcaption>
<div class=magnify style="FLOAT: right"><a class=internal title=放大 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Image:Phong-shading-sample.jpg'))" ??><img height=11 alt="" src="http://zh.wikipedia.org/skins-1.5/common/images/magnify-clip.png" width=15></a></div>
Flat 浓淡插值实例</div>
</div>
</div>
<p><a name=.E5.B9.B3.E7.9B.B4.E4.B8.8E.E5.85.89.E6.BB.91.E6.B5.93.E6.B7.A1.E5.A4.84.E7.90.86></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B5%93%E6%B7%A1%E5%A4%84%E7%90%86&amp;action=edit&amp;section=6" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>平直与光滑浓淡处理</span></h3>
<p><strong>平直浓淡处理</strong>是<a title=三维计算机图形学 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E4%B8%89%E7%BB%B4%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9B%BE%E5%BD%A2%E5%AD%A6'))" ??>三维计算机图形学</a>中使用的一种赵明技术，它根据物体表面<a title=多边形 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%A4%9A%E8%BE%B9%E5%BD%A2'))" ??>多边形</a>的<a class=new title=曲面法线 href="http://zh.wikipedia.org/w/index.php?title=%E6%9B%B2%E9%9D%A2%E6%B3%95%E7%BA%BF&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">表面法线</a>与光源之间的角度、各自的颜色以及光源的强度对于每个多边形进行浓淡处理。这种方法经常用于高速<a title=渲染 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%B8%B2%E6%9F%93'))" ??>渲染</a>过程，在这种场合下其它更加高级的技术由于计算量太大而难于使用。</p>
<p>平直浓淡处理的一个缺点是少量多边形表示的模型看起来有许多小平面。在有些情况下这种方法看起来已经足够，如箱子模型。艺术家有时使用平面浓淡处理来查看他们正在创建的实体模型。更加高级、真实的光照与浓淡处理技术有 <a class=new title="Gouraud shading" href="http://zh.wikipedia.org/w/index.php?title=Gouraud_shading&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Gouraud shading</a> 与 <a class=new title="Phong shading" href="http://zh.wikipedia.org/w/index.php?title=Phong_shading&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Phong shading</a> 等。</p>
<p><a name=.E5.8F.82.E8.A7.81></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B5%93%E6%B7%A1%E5%A4%84%E7%90%86&amp;action=edit&amp;section=7" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>参见</span></h2>
<p><a title=三维计算机图形 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E4%B8%89%E7%BB%B4%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9B%BE%E5%BD%A2#.E5.8F.8D.E5.B0.84.E4.B8.8E.E6.B5.93.E6.B7.A1.E5.A4.84.E7.90.86.E6.A8.A1.E5.9E.8B'))" ??>三维计算机图形/反射与浓淡处理模型</a></p>
</div>
<img src ="http://www.cppblog.com/yaoming/aggbug/40101.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/yaoming/" target="_blank">姚明</a> 2008-01-01 05:51 <a href="http://www.cppblog.com/yaoming/archive/2008/01/01/40101.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>渲染</title><link>http://www.cppblog.com/yaoming/archive/2008/01/01/40100.html</link><dc:creator>姚明</dc:creator><author>姚明</author><pubDate>Mon, 31 Dec 2007 21:43:00 GMT</pubDate><guid>http://www.cppblog.com/yaoming/archive/2008/01/01/40100.html</guid><wfw:comment>http://www.cppblog.com/yaoming/comments/40100.html</wfw:comment><comments>http://www.cppblog.com/yaoming/archive/2008/01/01/40100.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/yaoming/comments/commentRss/40100.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/yaoming/services/trackbacks/40100.html</trackback:ping><description><![CDATA[<h1 class=firstHeading>渲染</h1>
<div id=bodyContent>
<h3 id=siteSub>&nbsp;</h3>
<p><strong>渲染</strong>（<strong>Render</strong>）是用软件从模型生成图像的过程。模型是用严格定义的语言或者数据结构对于三维物体的描述，它包括几何、视点、<a class=new title=纹理 href="http://zh.wikipedia.org/w/index.php?title=%E7%BA%B9%E7%90%86&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">纹理</a>以及<a title=照明 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%85%A7%E6%98%8E'))" ??>照明</a>信息。图像是<a title=数字图像 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%95%B0%E5%AD%97%E5%9B%BE%E5%83%8F'))" ??>数字图像</a>或者<a title=位图 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E4%BD%8D%E5%9B%BE'))" ??>位图</a><a title=图像 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%9B%BE%E5%83%8F'))" ??>图像</a>。渲染这个术语类似于&#8220;艺术家对于场景的渲染&#8221;。另外渲染也用于描述计算视频编辑文件中的效果以生成最终视频输出的过程。</p>
<p>渲染是<a title=三维计算机图形学 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E4%B8%89%E7%BB%B4%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9B%BE%E5%BD%A2%E5%AD%A6'))" ??>三维计算机图形学</a>中的最重要的研究课题之一，并且在实践领域它与其它技术密切相关。在图形流水线中渲染是最后一项重要步骤，通过它得到模型与动画最终显示效果。自从二十世纪七十年代以来随着计算机图形的不断复杂化，渲染也越来越成为一项重要的技术。</p>
<p>渲染的应用领域有：<a title=电子游戏 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%94%B5%E5%AD%90%E6%B8%B8%E6%88%8F'))" ??>计算机与视频游戏</a>、<a class=new title=模拟 href="http://zh.wikipedia.org/w/index.php?title=%E6%A8%A1%E6%8B%9F&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">模拟</a>、<a title=电影 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%94%B5%E5%BD%B1'))" ??>电影</a>或者电视<a class=new title=视觉效果 href="http://zh.wikipedia.org/w/index.php?title=%E8%A7%86%E8%A7%89%E6%95%88%E6%9E%9C&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">特效</a>以及可视化设计，每一种应用都是特性与技术的综合考虑。作为产品来看，现在已经有各种不同的渲染工具产品，有些集成到更大的建模或者动画包中，有些是独立产品，有些是<a title=开放源代码 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%BC%80%E6%94%BE%E6%BA%90%E4%BB%A3%E7%A0%81'))" ??>开放源代码</a>的产品。从内部来看，渲染工具是都是根据各种学科理论经过仔细设计的程序，其中有：<a title=光学 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%85%89%E5%AD%A6'))" ??>光学</a>、<a title=视觉系统 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%A7%86%E8%A7%89%E7%B3%BB%E7%BB%9F'))" ??>视觉感知</a>、<a title=数学 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%95%B0%E5%AD%A6'))" ??>数学</a>以及<a title=软件工程 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%BD%AF%E4%BB%B6%E5%B7%A5%E7%A8%8B'))" ??>软件开发</a>。</p>
<p>三维计算机图形的预渲染或者实时渲染的速度都非常慢。预渲染的计算强度很大，通常是用于电影制作；实时渲染经常用于三维视频游戏，通常依靠带有三维硬件加速器的图形卡完成这个过程。</p>
<p><a name=.E4.BD.BF.E7.94.A8></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B8%B2%E6%9F%93&amp;action=edit&amp;section=1" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>使用</span></h2>
<p>在图像初步建立（通常使用<a title=线框模型 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%BA%BF%E6%A1%86%E6%A8%A1%E5%9E%8B'))" ??>网格</a>骨架构建）之后，就要进行渲染了。渲染将会在上面添加<a class=new title=位图纹理 href="http://zh.wikipedia.org/w/index.php?title=%E4%BD%8D%E5%9B%BE%E7%BA%B9%E7%90%86&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">位图纹理</a>或者<a class=new title=程序纹理 href="http://zh.wikipedia.org/w/index.php?title=%E7%A8%8B%E5%BA%8F%E7%BA%B9%E7%90%86&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">程序纹理</a>、照明、<a title=凸凹纹理映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%87%B8%E5%87%B9%E7%BA%B9%E7%90%86%E6%98%A0%E5%B0%84'))" ??>凸凹纹理映射</a>以及相对于其它物体的位置。得到的结果就是消费者或者观察者所能看到的完整图像。</p>
<p>对于电影动画来说，需要渲染几幅或几帧图像，并且将这些图像在动画制作程序中将它们连结在一起。大多数的三维图像编辑程序都能够完成这项工作。</p>
<p><a name=.E7.89.B9.E6.80.A7></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B8%B2%E6%9F%93&amp;action=edit&amp;section=2" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>特性</span></h2>
<p>渲染的图像有许多显著的特性，渲染研究的领域也主要集中在寻找高效模拟这些特性的方法。有些特性只与特定的算法有关，有些却与多个算法相关。</p>
<ul>
    <li><strong><a title=浓淡处理 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%B5%93%E6%B7%A1%E5%A4%84%E7%90%86'))" ??>浓淡处理</a></strong> — 表面颜色与亮度随光照的变化
    <li><strong><a title=纹理映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%BA%B9%E7%90%86%E6%98%A0%E5%B0%84'))" ??>纹理映射</a></strong> — 在表面生成细节的方法
    <li><strong><a title=凸凹纹理映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%87%B8%E5%87%B9%E7%BA%B9%E7%90%86%E6%98%A0%E5%B0%84'))" ??>凸凹纹理映射</a></strong> — 在表面模拟小凸凹的方法
    <li><strong><a title=距离模糊 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%B7%9D%E7%A6%BB%E6%A8%A1%E7%B3%8A'))" ??>距离模糊</a></strong> — 光照穿过不清澈的大气时的模糊
    <li><strong><a class=new title=阴影 href="http://zh.wikipedia.org/w/index.php?title=%E9%98%B4%E5%BD%B1&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">阴影</a></strong> — 阻挡光照的效果
    <li><strong><a class=new title=柔和阴影 href="http://zh.wikipedia.org/w/index.php?title=%E6%9F%94%E5%92%8C%E9%98%B4%E5%BD%B1&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">柔和阴影</a></strong> — 非常微弱的光源生成的暗处
    <li><strong><a title=反射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%8F%8D%E5%B0%84'))" ??>反射</a></strong> — 镜子或者非常光滑的反射
    <li><strong><a title=透明 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E9%80%8F%E6%98%8E'))" ??>透明</a></strong> — 固体明显允许光线穿过
    <li><strong><a title=半透明 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%8D%8A%E9%80%8F%E6%98%8E'))" ??>半透明</a></strong> — 光线通过固体高度散射
    <li><strong><a title=折射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%8A%98%E5%B0%84'))" ??>折射</a></strong> — 与透明相关的光线弯曲
    <li><strong><a class=new title=整体照明 href="http://zh.wikipedia.org/w/index.php?title=%E6%95%B4%E4%BD%93%E7%85%A7%E6%98%8E&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">间接照明</a></strong> — 表面由其它表面反射的光照亮，而非光源直接照亮
    <li><strong><a class=new title=焦散 href="http://zh.wikipedia.org/w/index.php?title=%E7%84%A6%E6%95%A3&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">焦散</a>（caustics）</strong>— 间接照明的一种形式，光滑物体反射的光线或者通过透明物体生成的聚焦光线在其它物体上形成照亮区域
    <li><strong><a title=景深 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%99%AF%E6%B7%B1'))" ??>景深</a></strong> — 当物体在焦距物体前后太远时出现模糊
    <li><strong><a class=new title=运动模糊 href="http://zh.wikipedia.org/w/index.php?title=%E8%BF%90%E5%8A%A8%E6%A8%A1%E7%B3%8A&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">运动模糊</a></strong> — 由于物体高速运动或者照相机运动而导致的物体模糊
    <li><strong><a class=new title=真实感渲染 href="http://zh.wikipedia.org/w/index.php?title=%E7%9C%9F%E5%AE%9E%E6%84%9F%E6%B8%B2%E6%9F%93&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">真实感渲染</a></strong> — 看起来较像现实世界的三维渲染
    <li><strong><a class=new title=非真实感渲染 href="http://zh.wikipedia.org/w/index.php?title=%E9%9D%9E%E7%9C%9F%E5%AE%9E%E6%84%9F%E6%B8%B2%E6%9F%93&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">非真实感渲染</a></strong> — 用艺术风格渲染场景，使它看起来象油画或者素描 </li>
</ul>
<p><a name=.E6.8A.80.E6.9C.AF></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B8%B2%E6%9F%93&amp;action=edit&amp;section=3" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>技术</span></h2>
<p>研究人员已经研究出了许多渲染算法，渲染软件可以使用多种不同的技术以生成最终图像。</p>
<p>对场景中的每束光线进行跟踪不太现实，并且需要耗费大得惊人的时间。如果没有采样进行很好的约束，即使是一部分光线的跟踪以生成图像也需要非常大量的时间。</p>
<p>所以，大致可以分为四类的更加高效的光线传输模型技术就应运而生。第一类是<strong><a title=栅格化 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%A0%85%E6%A0%BC%E5%8C%96'))" ??>栅格化</a></strong>，包括<strong><a title=扫描线渲染 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%89%AB%E6%8F%8F%E7%BA%BF%E6%B8%B2%E6%9F%93'))" ??>扫描线渲染</a></strong>，这种方法考虑场景中的物体并将它们投影一幅图像，对于生成不同观察点的<a class=new title=透视图 href="http://zh.wikipedia.org/w/index.php?title=%E9%80%8F%E8%A7%86%E5%9B%BE&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">透视图</a>没有任何帮助；第二类是<strong><a class=new title=光线投射 href="http://zh.wikipedia.org/w/index.php?title=%E5%85%89%E7%BA%BF%E6%8A%95%E5%B0%84&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">光线投射</a></strong>，将场景从不同视角观察，只根据几何与反射强度的基本光学原理计算观察到的图像，也可能使用<a title=蒙特&#183;卡罗方法 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%92%99%E7%89%B9%C2%B7%E5%8D%A1%E7%BD%97%E6%96%B9%E6%B3%95'))" ??>蒙特&#183;卡罗方法</a>减少人为噪声；第三类是<strong><a title=辐射着色 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%BE%90%E5%B0%84%E7%9D%80%E8%89%B2'))" ??>辐射着色</a></strong>，使用<a title=有限元分析 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%9C%89%E9%99%90%E5%85%83%E5%88%86%E6%9E%90'))" ??>有限元分析</a>方法模拟光线在表面的散射；第四类是<strong><a title=光线跟踪 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%85%89%E7%BA%BF%E8%B7%9F%E8%B8%AA'))" ??>光线跟踪</a></strong>，类似于光线投射，但是使用了更加先进的光学模拟方法，并且通常使用<a title=蒙特&#183;卡罗方法 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%92%99%E7%89%B9%C2%B7%E5%8D%A1%E7%BD%97%E6%96%B9%E6%B3%95'))" ??>蒙特&#183;卡罗方法</a>以实现更加真实的结果，但是这样做的代价通常是速度的大幅度降低。</p>
<p>大多数高级软件使用多种技术的组合以在合理的开销范围内实现足够好的结果。</p>
<p><a name=.E6.89.AB.E6.8F.8F.E7.BA.BF.E6.B8.B2.E6.9F.93.E4.B8.8E.E6.A0.85.E6.A0.BC.E5.8C.96></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B8%B2%E6%9F%93&amp;action=edit&amp;section=4" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>扫描线渲染与栅格化</span></h3>
<p>图像的高层次表示有必要包含与像素不同的元素，这些元素称为基元。例如，在示意图中线段与曲线是基元；在图形用户界面中，窗口与按钮是基元；在三维渲染中，三角形与空间多边形是基元。</p>
<p>在像素到像素渲染速度很慢无法实现的任务中，基元到基元的实现方法可能就能排上用场。在这种方法中，循环遍历每个基元确定它将影响图像中的哪个像素，然后相应地修改那个像素。这种方法称为<strong>栅格化</strong>，这是当今所有<a title=GPU href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/GPU'))" ??>图形卡</a>都用的渲染方法。</p>
<p>栅格化经常要比像素到像素的渲染速度快。首先，图像中的大块区域可能根本没有基元，栅格化就可以忽略这些区域，而像素到像素的渲染方法却必须遍历这些区域；其次，栅格化可以提高<a class=new title=缓存一致性 href="http://zh.wikipedia.org/w/index.php?title=%E7%BC%93%E5%AD%98%E4%B8%80%E8%87%B4%E6%80%A7&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">缓存一致性</a>并且可以利用图像中同一个基元占据的像素通常是连续的这样一个事实从而减少冗余操作。正是由于这些原因，栅格化通常是需要<a class=new title=交互式 href="http://zh.wikipedia.org/w/index.php?title=%E4%BA%A4%E4%BA%92%E5%BC%8F&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">交互式</a>渲染的场合选择的一种方法，但是像素到像素的实现方法经常可以生成更高质量的图像，同时由于没有栅格化那么多的前提条件所以更加通用。</p>
<p>栅格化有两种主要的形式，不仅整个表面或者基元进行渲染，而且表面顶点全部进行渲染，以及用相邻顶点简单颜色混合来渲染位于顶点之间的表面上的像素，由于这种方法不使用复杂的纹理实现图像连续，所以这种方法已经取代了较旧的栅格化方法，并且由于简单的纹理可以节省内存空间，所以通过使用图形卡的已经繁重的浓淡效果处理功能仍然可以得到更好的性能。旧的方法如果不使用复杂的纹理就会在图像逐个表面覆盖纹理的时候形成块状效应，并且由于像素之间没有颜色渐变所以表面看起来也不光滑。有些情况下设计人员在某些表面上使用栅格化的方法，而根据其它表面相对于其它相交表面的角度使用其它的方法，这样一方面可以提高处理速度，另外也仍然可以保证整体效果。</p>
<p><a name=.E5.85.89.E7.BA.BF.E6.8A.95.E5.B0.84></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B8%B2%E6%9F%93&amp;action=edit&amp;section=5" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>光线投射</span></h3>
<p>光线投射主要用于如三维电脑游戏以及动画等实时模拟场合，在这些场合下细节并不太重要或者是通过人为制造细节可以得到更好的计算效率。通常在需要多帧图像生成动画时就会出现这种情况。如果不使用其它的技巧，这种方法得到的物体表面通常看起来比较扁平，就好像场景中的物体都是经过光滑处理的糙面。</p>
<p>建好的几何模型从外部观察点逐点、逐线进行分析，就如同是从观察点投射出光线一样。当光线与物体交叉的时候，交叉点的颜色可以用几种不同的方法来计算。其中最简单的方法是用交叉点处物体的颜色表示该点的实际颜色；也可以用<a title=纹理映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%BA%B9%E7%90%86%E6%98%A0%E5%B0%84'))" ??>纹理映射</a>的方法来确定；一种更加复杂的方法是仅仅根据照明因数变更颜色值，而无需考虑与模拟光源的关系。为了减少人为误差，可以对多条相邻方向的光线进行平均。</p>
<p>另外也可以对光的特性进行大致的模拟：简单计算从物体到观察点的光线。另外的一些计算涉及到从光源到物体的入射角，以及根据光源的强度计算像素的亮度值。此外还有一些模拟使用辐射着色算法绘制的照明结果，或者使用这两种信息的组合。</p>
<p><a name=.E8.BE.90.E5.B0.84.E7.9D.80.E8.89.B2></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B8%B2%E6%9F%93&amp;action=edit&amp;section=6" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>辐射着色</span></h3>
<p><a title=辐射着色 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%BE%90%E5%B0%84%E7%9D%80%E8%89%B2'))" ??>辐射着色</a>是模拟反射光线如何反射到其它表面以及如何照亮周围环境的方法。这种方法可以生成较为真实的浓淡效果，并且更加易于捕捉室内场景的<a class=new title=环境光 href="http://zh.wikipedia.org/w/index.php?title=%E7%8E%AF%E5%A2%83%E5%85%89&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">环境光</a>。一个经典的例子就是墙角处阴影的样子。</p>
<p>这种模拟的光学基础是特定物体表面某一点的漫反射的光线散布在在很大的方向范围内并且会照亮周围的环境。</p>
<p>各种模拟技术的复杂性可能会有所不同。许多渲染方法所用的辐射着色模型都非常原始，它们只是简单地根据环境因数变化照亮整个场景。但是当高级的辐射着色与高质量的光线跟踪算法组合在一起使用的时候，它们能够生成相当真实的图像，尤其是对于室内场景更是这样。</p>
<p>在高级的辐射着色模拟中，递归的有限元分析算法不断地将光线在模型表面之间来回反射，直到达到一定的递归条件为止。这样一个表面的色彩就会影响其它相邻表面的色彩，反之亦然。整个模型（有时也包括空白空间）的照明结果保存起来，在光线投射或者光线跟踪模型中作为输入使用。</p>
<p>由于这项技术的递归特性，所以对于复杂物体的模拟速度非常缓慢。一些先进的辐射着色计算方法可能只计算房间中从墙面、地板与房顶反射的环境光，而并不计算复杂物体反光对于辐射着色的影响，或者在辐射着色计算中使用使用同样尺寸及纹理的简单物体取代复杂物体。</p>
<p>如果场景中需要重排的辐射着色物体很少，那么可以在多帧画面中重复使用同样的辐射着色数据，这样就使得辐射着色一方面可以改进光线投射中的扁平效果，另外一方面每帧的渲染时间也不会受到很大的影响。</p>
<p>正因为如此，辐射着色已经成为领先的实时渲染方法，并且已经用于最近大量著名的长篇三维动画电影从头到尾的制作过程。</p>
<p><a name=.E5.85.89.E7.BA.BF.E8.B7.9F.E8.B8.AA></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B8%B2%E6%9F%93&amp;action=edit&amp;section=7" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>光线跟踪</span></h3>
<p>光线跟踪是与扫描线渲染和光线投射开发的同样技术的延伸，同那些方法一样，它可以很好地处理复杂物体，并且也可以用数学方法描述物体。与扫描线渲染和光线投射不同的是，光线跟踪几乎是一项<a title=蒙特&#183;卡罗方法 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%92%99%E7%89%B9%C2%B7%E5%8D%A1%E7%BD%97%E6%96%B9%E6%B3%95'))" ??>蒙特&#183;卡罗方法</a>，蒙特&#183;卡罗方法是一项基于从模型中随机得到的一组采样进行平均的技术。</p>
<p>在这种方法中，采样是假想的从场景物体发出与观察点相交的光线。在重点考虑阴影、折射与反射等需要复杂精确渲染的场合这种方法就可以派上用场。</p>
<p>在最终要求产品质量渲染效果的光线跟踪中，通常每个像素都要多条光线，并且不仅仅跟踪到第一次相交，而是需要按照&#8220;入射角等于反射角&#8221;这样的光学定律以及更加高级的处理折射与粗糙表面反射的定律处理多次连续反射。</p>
<p>一旦光线遇到光源或者更可能出现的是光线反射次数已经达到设定的限制，那么最终点的表面照明就通过上面的方法确定下来，并且经过多次反射发生的变化也可以用来估计在观察点看到的亮度。每个采样点、每个像素都要重复这个过程。</p>
<p>在有些场合中每个交点可能生成多条光线。</p>
<p>作为一种非常有效的方法，光线跟踪的实时处理速度太慢，直到最近也没有在任何质量要求的短片电影中获得应用，尽管它已经开始在一些特殊效果要求的场合开始使用，如在需要高质量甚至是<a class=new title=Photorealistic href="http://zh.wikipedia.org/w/index.php?title=Photorealistic&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Photorealistic</a>的脚本片断的广告中开始使用。</p>
<p>但是，降低不需要高质量细节部分的或者与光线跟踪特性无关部分的计算量的努力已经使得光线跟踪的应用更加广泛。目前已经出现了一些至少已经处于原型阶段硬件加速的光线跟踪设备，在一些游戏演示中也有实时软件或者硬件光线跟踪的应用。</p>
<p><a name=.E4.BC.98.E5.8C.96></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B8%B2%E6%9F%93&amp;action=edit&amp;section=8" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>优化</span></h2>
<p><a name=.E8.89.BA.E6.9C.AF.E5.AE.B6.E6.9E.84.E5.BB.BA.E5.9C.BA.E6.99.AF.E7.9A.84.E6.97.B6.E5.80.99.E6.89.80.E7.94.A8.E7.9A.84.E4.BC.98.E5.8C.96.E6.96.B9.E6.B3.95></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B8%B2%E6%9F%93&amp;action=edit&amp;section=9" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>艺术家构建场景的时候所用的优化方法</span></h3>
<p>由于所需计算量非常大，一项逐步进行的工作的细节渲染通常对应于当时工作的进度。因此，在建模的开始阶段可以使用线框模型或者光线投射进行处理，即使是最终的目标结果是要使用辐射着色的光线跟踪也可以这么做。另外也经常只对一部分进行高质量的渲染，而对于当前工作无关紧要的部分剔除出去。</p>
<p><a name=.E5.AE.9E.E6.97.B6.E6.B8.B2.E6.9F.93.E4.B8.AD.E5.B8.B8.E7.94.A8.E7.9A.84.E4.BC.98.E5.8C.96.E6.96.B9.E6.B3.95></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B8%B2%E6%9F%93&amp;action=edit&amp;section=10" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>实时渲染中常用的优化方法</span></h3>
<p>对于实时渲染来说，适当的做法是简化一个或者多个共同的近似，将关键场景调到正确的参数，并且要将参数调整到能够获得最好的效果。</p>
<p>另外还有些一些不太出名的渲染方法，如<a title=球谐函数 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%90%83%E8%B0%90%E5%87%BD%E6%95%B0'))" ??>球谐函数</a>。这些技术由于速度较慢、缺少实用性或者仅仅因为它们还不太完善所以不太出名，或许其中的某些技术能够提供一些新的解决方案。</p>
<p><a name=.E9.87.87.E6.A0.B7.E4.B8.8E.E6.BB.A4.E6.B3.A2></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B8%B2%E6%9F%93&amp;action=edit&amp;section=11" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>采样与滤波</span></h2>
<p>不管系统采样哪种渲染方法，都必须解决<strong>采样问题</strong>。本质上来讲，渲染过程试图用有限数目的像素将图像空间的<a title=连续函数 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%BF%9E%E7%BB%AD%E5%87%BD%E6%95%B0'))" ??>连续函数</a>表现成颜色。根据<a title=采样定理 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E9%87%87%E6%A0%B7%E5%AE%9A%E7%90%86'))" ??>采样定理</a>的结论，扫描频率必须是点速（dot rate）的两倍，点速与图像<a title=分辨率 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%88%86%E8%BE%A8%E7%8E%87'))" ??>分辨率</a>成正比。用简单的话来说就是图像不能显示小于一个像素的细节。</p>
<p>如果使用一个未经验证的渲染算法，那么图像函数中的高频成分将会导致最终图像中出现难看的<a title=混疊 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%B7%B7%E7%96%8A'))" ??>混疊</a>现象。混叠现象通常表现为<a class=new title=锯齿图 href="http://zh.wikipedia.org/w/index.php?title=%E9%94%AF%E9%BD%BF%E5%9B%BE&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">锯齿图</a>或者是可见像素栅格处的锯齿边。为了去除混叠现象，所有的渲染算法如果想要生成好看的图像的话都必须对图像函数进行滤波以去除高频成分，这个过程叫作<a class=new title=抗混叠 href="http://zh.wikipedia.org/w/index.php?title=%E6%8A%97%E6%B7%B7%E5%8F%A0&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">抗混叠</a>。</p>
<p><a name=.E7.94.B5.E5.BD.B1.E6.B8.B2.E6.9F.93></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B8%B2%E6%9F%93&amp;action=edit&amp;section=12" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>电影渲染</span></h2>
<p>电影渲染通常在一个紧密相连的计算机组成的网络<a class=new title=渲染集群 href="http://zh.wikipedia.org/w/index.php?title=%E6%B8%B2%E6%9F%93%E9%9B%86%E7%BE%A4&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">渲染集群</a>（render farm）。</p>
<p>当今用于电影制作三维图像描述发展水平代表是 <a title=Pixar href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Pixar'))" ??>Pixar</a> 设计的 <a title=RenderMan href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/RenderMan'))" ??>RenderMan</a>&nbsp;<a class=new title=场景描述语言 href="http://zh.wikipedia.org/w/index.php?title=%E5%9C%BA%E6%99%AF%E6%8F%8F%E8%BF%B0%E8%AF%AD%E8%A8%80&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">场景描述语言</a>。它与 <a title=VRML href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/VRML'))" ??>VRML</a> 这样较简单的三维文件格式或者是经过修改专门用于三维硬件加速的<a title=OpenGL href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/OpenGL'))" ??>OpenGL</a>以及<a title=DirectX href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/DirectX'))" ??>DirectX</a>等<a title=应用程序编程接口 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%BA%94%E7%94%A8%E7%A8%8B%E5%BA%8F%E7%BC%96%E7%A8%8B%E6%8E%A5%E5%8F%A3'))" ??>应用程序编程接口</a>有所不同。</p>
<p>电影渲染软件包括：</p>
<ul>
    <li><a class=new title=Renderman href="http://zh.wikipedia.org/w/index.php?title=Renderman&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Renderman</a>
    <li><a class=new title="Mental Ray" href="http://zh.wikipedia.org/w/index.php?title=Mental_Ray&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Mental Ray</a>
    <li><a class=new title="Brazil R/S" href="http://zh.wikipedia.org/w/index.php?title=Brazil_R/S&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Brazil R/S</a>
    <li><a title=Blender href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/Blender'))" ??>Blender</a> （也可以用于建模）
    <li><a class=new title=LightWave href="http://zh.wikipedia.org/w/index.php?title=LightWave&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">LightWave</a> （包括建模模块） </li>
</ul>
<p><a name=.E7.90.86.E8.AE.BA.E5.9F.BA.E7.A1.80></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B8%B2%E6%9F%93&amp;action=edit&amp;section=13" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>理论基础</span></h2>
<p>真实感渲染的实现都是某种程度的物理仿真 — 一些计算都是真实物理过程的模拟或抽象。</p>
<p>&#8220;<em>基于物理</em>&#8221;这个术语表示是使用在渲染领域之外也被广泛接受的物理模型或者近似，在渲染领域逐渐建立起了相关的特殊技术。</p>
<p>这些物理基本概念都相当直白，但是却难于计算；一个非常优秀的算法或者实现方法对于更加通用的渲染目的来说却可能难以理解。为了满足健壮、精确及实用的要求，实现方法都必须是多项不同技术的复杂组合。</p>
<p>渲染研究工作主要集中在科学模型的改进及其高效应用。</p>
<p><a name=.E6.B8.B2.E6.9F.93.E6.96.B9.E7.A8.8B></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B8%B2%E6%9F%93&amp;action=edit&amp;section=14" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>渲染方程</span></h3>
<dl>
<dd>
<div class=noprint style="FONT-SIZE: small">主条目：<a title=渲染方程 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%B8%B2%E6%9F%93%E6%96%B9%E7%A8%8B'))" ??>渲染方程</a></div>
</dd></dl>
<p>渲染方程是渲染中的一个核心理论概念，它是渲染不可感知方面的最抽象的正式表示，所有更加完善的算法都可以看作这个方程特殊形式的解。</p>
<dl>
<dd><img class=tex alt="L_o(x, \vec w) = L_e(x, \vec w) + \int_\Omega f_r(x, \vec w', \vec w) L_i(x, \vec w') (\vec w' \cdot \vec n) d\vec w'" src="http://www.gollumbrowser.com/tc/math/7/9/a/79afc7016dee9593d7adf88915acce97.png"></dd></dl>
<p>含义是：在一个特定的位置与方向，出射光 L<sub>o</sub>) 是发射光 L<sub>e</sub> 与反射光之和。反射光是所有方向入射光之和 L<sub>i</sub> 乘以表面反射率及入射角。通过交叉点，这个方程将入射光与出射光联系在一起，它代表了场景中完整的光线传输即光线的所有运动。</p>
<p><a name=.E5.8F.8C.E5.90.91.E5.8F.8D.E5.B0.84.E5.88.86.E5.B8.83.E5.87.BD.E6.95.B0></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B8%B2%E6%9F%93&amp;action=edit&amp;section=15" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>双向反射分布函数</span></h3>
<p><strong><a class=new title=双向反射分布函数 href="http://zh.wikipedia.org/w/index.php?title=%E5%8F%8C%E5%90%91%E5%8F%8D%E5%B0%84%E5%88%86%E5%B8%83%E5%87%BD%E6%95%B0&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">双向反射分布函数</a></strong>（BRDF）描述了一个光线与物体表面相互作用的简单模型：</p>
<dl>
<dd><img class=tex alt="f_r(x, \vec w', \vec w) = \frac{dL_r(x, \vec w)}{L_i(x, \vec w')(\vec w' \cdot \vec n) d\vec w'}" src="http://www.gollumbrowser.com/tc/math/7/8/5/7857783a84a1c7193fdc36a1a6d29e50.png"></dd></dl>
<p>光线相互作用通常用更加简单的模型进行近似：漫反射与镜面反射。这两种都可以是双向反射函数。</p>
<p><a name=.E5.87.A0.E4.BD.95.E5.85.89.E5.AD.A6></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B8%B2%E6%9F%93&amp;action=edit&amp;section=16" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>几何光学</span></h3>
<p>实际上渲染是完全关于光物理粒子性方面研究的技术即几何光学。将光在本质上看作跳动的光子这种简化是合适的：在大多数场合下，光的波动性是可以忽略的，并且也非常难于模拟。著名的光波动现象有衍射，如<a title=CD href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/CD'))" ??>CD</a>以及<a title=DVD href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/DVD'))" ??>DVD</a>上的颜色，以及如<a title=LCD href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/LCD'))" ??>LCD</a>上看到的极化现象。如果这两种类型的效果，通常对反射模型进行针对表现效果的调整。</p>
<p><a name=.E8.A7.86.E8.A7.89></a></p>
<h3><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B8%B2%E6%9F%93&amp;action=edit&amp;section=17" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>视觉</span></h3>
<p>尽管很少受到关注，但是对于人类视觉的理解对于渲染来说非常重要，这是因为图像显示与人类视觉都有一定的约束范围。渲染工具几乎可以模拟无限范围的亮度与颜色，但是电影、显示器等当今的显示设备都不能处理这么大的范围，通常都需要压缩甚至舍弃一部分信息。人类视觉也有类似的限制，因此不需要为了真实感而使用很大范围的图像。视觉研究可以帮助解决将图像用显示器显示的问题，以及建议渲染中使用哪些捷径，一些细微的信息是无法感知的。这个相关的主题是<a title=色调映射 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%89%B2%E8%B0%83%E6%98%A0%E5%B0%84'))" ??>色调映射</a>。</p>
<p>在渲染中使用的数学基础有：<a title=线性代数 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%BA%BF%E6%80%A7%E4%BB%A3%E6%95%B0'))" ??>线性代数</a>、<a title=微积分 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%BE%AE%E7%A7%AF%E5%88%86'))" ??>微积分</a>、<a title=数值分析 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%95%B0%E5%80%BC%E5%88%86%E6%9E%90'))" ??>数值分析</a>、<a title=数字信号处理 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%95%B0%E5%AD%97%E4%BF%A1%E5%8F%B7%E5%A4%84%E7%90%86'))" ??>数字信号处理</a>以及<a title=蒙特&#183;卡罗方法 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%92%99%E7%89%B9%C2%B7%E5%8D%A1%E7%BD%97%E6%96%B9%E6%B3%95'))" ??>蒙特&#183;卡罗方法</a>。</p>
<p><a name=.E9.87.8D.E8.A6.81.E6.80.9D.E6.83.B3.E5.87.BA.E7.8E.B0.E7.9A.84.E5.B9.B4.E4.BB.A3.E8.A1.A8></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B8%B2%E6%9F%93&amp;action=edit&amp;section=18" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>重要思想出现的年代表</span></h2>
<ul>
    <li>1970 <strong>扫描线算法</strong> (Bouknight, W. J. (1970). A procedure for generation of three-dimensional half-tone computer graphics presentations. <em>Communications of the ACM</em>)
    <li>1971 <strong>Gouraud shading</strong> (Gouraud, H. (1971). Computer display of curved surfaces. <em>IEEE Transactions on Computers</em><strong>20</strong> (6), 623&#8211;629.)
    <li>1974 <strong>纹理映射</strong> (Catmull, E. (1974). A subdivision algorithm for computer display of curved surfaces. <em>PhD thesis</em>, University of Utah.)
    <li>1974 <strong>深度缓冲</strong> (Catmull, E. (1974). A subdivision algorithm for computer display of curved surfaces. <em>PhD thesis</em>)
    <li>1975 <strong>Phong shading</strong> (Phong, B-T. (1975). Illumination for computer generated pictures. <em>Communications of the ACM</em><strong>18</strong> (6), 311&#8211;316.)
    <li>1976 <strong>环境映射</strong> (Blinn, J.F., <a class=new title="M. E. Newell" href="http://zh.wikipedia.org/w/index.php?title=M._E._Newell&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Newell, M.E.</a> (1976). Texture and reflection in computer generated images. <em>Communications of the ACM</em><strong>19</strong>, 542&#8211;546.)
    <li>1977 <strong>阴影体</strong> (Crow, F.C. (1977). Shadow algorithms for computer graphics. <em>Computer Graphics (Proceedings of SIGGRAPH 1977)</em><strong>11</strong> (2), 242&#8211;248.)
    <li>1978 <strong>阴影缓冲</strong> (Williams, L. (1978). Casting curved shadows on curved surfaces. <em>Computer Graphics (Proceedings of SIGGRAPH 1978)</em><strong>12</strong> (3), 270&#8211;274.)
    <li>1978 <strong>凸凹纹理映射</strong> (Blinn, J.F. (1978). Simulation of wrinkled surfaces. <em>Computer Graphics (Proceedings of SIGGRAPH 1978)</em><strong>12</strong> (3), 286&#8211;292.)
    <li>1980 <strong>BSP trees</strong> (Fuchs, H. Kedem, Z.M. Naylor, B.F. (1980). On visible surface generation by a priori tree structures. <em>Computer Graphics (Proceedings of SIGGRAPH 1980)</em><strong>14</strong> (3), 124&#8211;133.)
    <li>1980 <strong>光线跟踪</strong> (Whitted, T. (1980). An improved illumination model for shaded display. <em>Communications of the ACM</em><strong>23</strong> (6), 343&#8211;349.)
    <li>1981 <strong>Cook shader</strong> (Cook, R.L. Torrance, K.E. (1981). A reflectance model for computer graphics. <em>Computer Graphics (Proceedings of SIGGRAPH 1981)</em><strong>15</strong> (3), 307&#8211;316.)
    <li>1983 <strong>Mipmaps</strong> (Williams, L. (1983). Pyramidal parametrics. <em>Computer Graphics (Proceedings of SIGGRAPH 1983)</em><strong>17</strong> (3), 1&#8211;11.)
    <li>1984 <strong>八叉树光线跟踪</strong> (Glassner, A.S. (1984). Space subdivision for fast ray tracing. <em>IEEE Computer Graphics &amp; Applications</em><strong>4</strong> (10), 15&#8211;22.)
    <li>1984 <strong>Alpha compositing</strong> (Porter, T. Duff, T. (1984). Compositing digital images. <em>Computer Graphics (Proceedings of SIGGRAPH 1984)</em><strong>18</strong> (3), 253&#8211;259.)
    <li>1984 <strong>分布式光线跟踪</strong> (Cook, R.L. Porter, T. Carpenter, L. (1984). Distributed ray tracing. <em>Computer Graphics (Proceedings of SIGGRAPH 1984)</em><strong>18</strong> (3), 137&#8211;145.)
    <li>1984 <strong>辐射着色</strong> (Goral, C. Torrance, K.E. Greenberg, D.P. Battaile, B. (1984). Modelling the interaction of light between diffuse surfaces. <em>Computer Graphics (Proceedings of SIGGRAPH 1984)</em><strong>18</strong> (3), 213&#8211;222.)
    <li>1985 <strong>半立方辐射着色</strong> (Cohen, M.F. Greenberg, D.P. (1985). The hemi-cube: a radiosity solution for complex environments. <em>Computer Graphics (Proceedings of SIGGRAPH 1985)</em><strong>19</strong> (3), 31&#8211;40.)
    <li>1986 <strong>光源跟踪</strong> (Arvo, J. (1986). Backward ray tracing. <em>SIGGRAPH 1986 Developments in Ray Tracing course notes</em>)
    <li>1986 <strong>渲染方程</strong> (Kajiya, J.T. (1986). The rendering equation. <em>Computer Graphics (Proceedings of SIGGRAPH 1986)</em><strong>20</strong> (4), 143&#8211;150.)
    <li>1987 <strong><a class=new title="Reyes rendering" href="http://zh.wikipedia.org/w/index.php?title=Reyes_rendering&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Reyes</a> algorithm</strong> (Cook, R.L. Carpenter, L. Catmull, E. (1987). The reyes image rendering architecture. <em>Computer Graphics (Proceedings of SIGGRAPH 1987)</em><strong>21</strong> (4), 95&#8211;102.)
    <li>1991 <strong>分级辐射着色</strong> (Hanrahan, P. Salzman, D. Aupperle, L. (1991). A rapid hierarchical radiosity algorithm. <em>Computer Graphics (Proceedings of SIGGRAPH 1991)</em><strong>25</strong> (4), 197&#8211;206.)
    <li>1993 <strong>色调映射</strong> (Tumblin, J. Rushmeier, H.E. (1993). Tone reproduction for realistic computer generated images. <em>IEEE Computer Graphics &amp; Applications</em><strong>13</strong> (6), 42&#8211;48.)
    <li>1993 <strong>Subsurface scattering</strong> (Hanrahan, P. Krueger, W. (1993). Reflection from layered surfaces due to subsurface scattering. <em>Computer Graphics (Proceedings of SIGGRAPH 1993)</em><strong>27</strong> (), 165&#8211;174.)
    <li>1995 <strong>光子映射</strong> (Jensen, H.J. Christensen, N.J. (1995). Photon maps in bidirectional monte carlo ray tracing of complex objects. <em>Computers &amp; Graphics</em><strong>19</strong> (2), 215&#8211;224.) </li>
</ul>
<p><a name=.E5.8F.82.E8.A7.81></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B8%B2%E6%9F%93&amp;action=edit&amp;section=19" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>参见</span></h2>
<ul>
    <li><a class=new title="Painter\'s algorithm" href="http://zh.wikipedia.org/w/index.php?title=Painter%27s_algorithm&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">painter\'s algorithm</a>
    <li><a title=扫描线渲染 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%89%AB%E6%8F%8F%E7%BA%BF%E6%B8%B2%E6%9F%93'))" ??>扫描线渲染</a>算法如 <a class=new title=Reyes href="http://zh.wikipedia.org/w/index.php?title=Reyes&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Reyes</a>
    <li><a title=深度缓冲 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%B7%B1%E5%BA%A6%E7%BC%93%E5%86%B2'))" ??>深度缓冲</a>
    <li><a class=new title=全局照明 href="http://zh.wikipedia.org/w/index.php?title=%E5%85%A8%E5%B1%80%E7%85%A7%E6%98%8E&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">全局照明</a>
    <li><a title=辐射着色 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%BE%90%E5%B0%84%E7%9D%80%E8%89%B2'))" ??>辐射着色</a>
    <li><a title=光线跟踪 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%85%89%E7%BA%BF%E8%B7%9F%E8%B8%AA'))" ??>光线跟踪</a>
    <li><a title=立体渲染 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%AB%8B%E4%BD%93%E6%B8%B2%E6%9F%93'))" ??>立体渲染</a>
    <li><a class=new title=预渲染 href="http://zh.wikipedia.org/w/index.php?title=%E9%A2%84%E6%B8%B2%E6%9F%93&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">预渲染</a>
    <li><a class=new title="Graphics pipeline" href="http://zh.wikipedia.org/w/index.php?title=Graphics_pipeline&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Graphics pipeline</a>
    <li><a class=new title=虚拟模型 href="http://zh.wikipedia.org/w/index.php?title=%E8%99%9A%E6%8B%9F%E6%A8%A1%E5%9E%8B&amp;action=edit" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">虚拟模型</a> </li>
</ul>
<p><a name=.E5.9B.BE.E4.B9.A6.E8.B5.84.E6.96.99></a></p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B8%B2%E6%9F%93&amp;action=edit&amp;section=20" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">编辑</a>]</span><span class=mw-headline>图书资料</span></h2>
<ul>
    <li>Foley; Van Dam; Feiner; Hughes (1990). <em>Computer Graphics: Principles And Practice</em>. Addison Wesley. <a class=internal href="javascript:void(wb.w._link('http://zh.wikipedia.org/w/index.php?title=Special:Booksources&amp;isbn=0201121107'))" ??>ISBN 0-201-12110-7</a>.
    <li>Glassner (1995). <em>Principles Of Digital Image Synthesis</em>. Morgan Kaufmann. <a class=internal href="javascript:void(wb.w._link('http://zh.wikipedia.org/w/index.php?title=Special:Booksources&amp;isbn=1558602763'))" ??>ISBN 1-55860-276-3</a>.
    <li>Pharr; Humphreys (2004). <em>Physically Based Rendering</em>. Morgan Kaufmann. <a class=internal href="javascript:void(wb.w._link('http://zh.wikipedia.org/w/index.php?title=Special:Booksources&amp;isbn=012553180X'))" ??>ISBN 0-12-553180-X</a>.
    <li>Dutre; Bala; Bekaert (2002). <em>Advanced Global Illumination</em>. AK Peters. <a class=internal href="javascript:void(wb.w._link('http://zh.wikipedia.org/w/index.php?title=Special:Booksources&amp;isbn=1568811772'))" ??>ISBN 1-56881-177-2</a>.
    <li>Jensen (2001). <em>Realistic Image Synthesis Using Photon Mapping</em>. AK Peters. <a class=internal href="javascript:void(wb.w._link('http://zh.wikipedia.org/w/index.php?title=Special:Booksources&amp;isbn=1568811470'))" ??>ISBN 1-56881-147-0</a>.
    <li>Shirley; Morley (2003). <em>Realistic Ray Tracing</em> (2nd ed.). AK Peters. <a class=internal href="javascript:void(wb.w._link('http://zh.wikipedia.org/w/index.php?title=Special:Booksources&amp;isbn=1568811985'))" ??>ISBN 1-56881-198-5</a>.
    <li>Glassner (1989). <em>An Introduction To Ray Tracing</em>. Academic Press. <a class=internal href="javascript:void(wb.w._link('http://zh.wikipedia.org/w/index.php?title=Special:Booksources&amp;isbn=0122861604'))" ??>ISBN 0-12-286160-4</a>.
    <li>Cohen; Wallace (1993). <em>Radiosity and Realistic Image Synthesis</em>. AP Professional. <a class=internal href="javascript:void(wb.w._link('http://zh.wikipedia.org/w/index.php?title=Special:Booksources&amp;isbn=0121782700'))" ??>ISBN 0-12-178270-0</a>.
    <li>Akenine-Moller; Haines (2002). <em>Real-time Rendering</em> (2nd ed.). AK Peters. <a class=internal href="javascript:void(wb.w._link('http://zh.wikipedia.org/w/index.php?title=Special:Booksources&amp;isbn=1568811829'))" ??>ISBN 1-56881-182-9</a>.
    <li>Gooch; Gooch (2001). <em>Non-Photorealistic Rendering</em>. AKPeters. <a class=internal href="javascript:void(wb.w._link('http://zh.wikipedia.org/w/index.php?title=Special:Booksources&amp;isbn=1568811330'))" ??>ISBN 1-56881-133-0</a>.
    <li>Strothotte; Schlechtweg (2002). <em>Non-Photorealistic Computer Graphics</em>. Morgan Kaufmann. <a class=internal href="javascript:void(wb.w._link('http://zh.wikipedia.org/w/index.php?title=Special:Booksources&amp;isbn=1558607870'))" ??>ISBN 1-55860-787-0</a>.
    <li>Blinn (1996). <em>Jim Blinns Corner - A Trip Down The Graphics Pipeline</em>. Morgan Kaufmann. <a class=internal href="javascript:void(wb.w._link('http://zh.wikipedia.org/w/index.php?title=Special:Booksources&amp;isbn=1558603875'))" ??>ISBN 1-55860-387-5</a>.
    <li><a class="external text" title=http://radsite.lbl.gov/radiance/papers/sg94.1/ href="http://radsite.lbl.gov/radiance/papers/sg94.1/" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif">Description of the \'Radiance\' system</a> </li>
</ul>
</div>
<img src ="http://www.cppblog.com/yaoming/aggbug/40100.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/yaoming/" target="_blank">姚明</a> 2008-01-01 05:43 <a href="http://www.cppblog.com/yaoming/archive/2008/01/01/40100.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>渲染方程</title><link>http://www.cppblog.com/yaoming/archive/2008/01/01/40099.html</link><dc:creator>姚明</dc:creator><author>姚明</author><pubDate>Mon, 31 Dec 2007 21:40:00 GMT</pubDate><guid>http://www.cppblog.com/yaoming/archive/2008/01/01/40099.html</guid><wfw:comment>http://www.cppblog.com/yaoming/comments/40099.html</wfw:comment><comments>http://www.cppblog.com/yaoming/archive/2008/01/01/40099.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/yaoming/comments/commentRss/40099.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/yaoming/services/trackbacks/40099.html</trackback:ping><description><![CDATA[<h1 class=firstHeading>渲染方程</h1>
<div id=bodyContent>
<h3 id=siteSub>&nbsp;</h3>
<p>在<a title=计算机图形学 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%AE%A1%E7%AE%97%E6%9C%BA%E5%9B%BE%E5%BD%A2%E5%AD%A6'))" ??><u><font color=#0000ff>计算机图形学</font></u></a>领域，<strong>渲染方程</strong>（<a class=extiw title=en:Rendering_equation href="javascript:void(wb.w._link('http://en.wikipedia.org/wiki/Rendering_equation'))" ??><u><font color=#0000ff>en:Rendering equation</font></u></a>）描述的是<a title=光 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E5%85%89'))" ??><u><font color=#0000ff>光</font></u></a><a title=能量 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E8%83%BD%E9%87%8F'))" ??><u><font color=#0000ff>能</font></u></a>在场景中的流动。根据光学的<a title=物理学 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E7%89%A9%E7%90%86%E5%AD%A6'))" ??><u><font color=#0000ff>物理学</font></u></a>原理，它在理论上给出了一个完美的结果，而各种各样的<a title=渲染 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%B8%B2%E6%9F%93'))" ??><u><font color=#0000ff>渲染</font></u></a>技术，只是这个理想结果的一个近似。</p>
<p>渲染方程的物理基础是能量守恒定律。在一个特定的位置和方向，出射光 L<sub>o</sub> 是发射光 L<sub>e</sub> 与反射光之和，反射光本身是各个方向的入射光 L<sub>i</sub> 之和乘以表面反射率及入射角。</p>
<p>这个方程可以用下面的数学等式表示：</p>
<dl>
<dd><img class=tex alt="L_o(x, \vec w) = L_e(x, \vec w) + \int_\Omega f_r(x, \vec w', \vec w) L_i(x, \vec w') (\vec w' \cdot \vec n) d\vec w'" src="http://www.gollumbrowser.com/tc/math/7/9/a/79afc7016dee9593d7adf88915acce97.png"></dd></dl>
<p>其中，</p>
<dl>
<dd><img class=tex alt="L_o(x, \vec w)" src="http://www.gollumbrowser.com/tc/math/7/8/0/78028c2b83f64f2ada45199ff064ec74.png"> 是在特定位置 <span class=texhtml><em>x</em></span> 及角度 <img class=tex alt="\vec w" src="http://www.gollumbrowser.com/tc/math/f/4/f/f4fdaaba2256b79221853e1251248001.png"> 的出射光。
<dd><img class=tex alt="L_e(x, \vec w)" src="http://www.gollumbrowser.com/tc/math/f/2/d/f2d7894a62b512d4167bba69f3a4da33.png"> 是在同一位置及方向发出的光。
<dd><img class=tex alt="\int_\Omega ... d\vec w'" src="http://www.gollumbrowser.com/tc/math/1/d/d/1dd6bf3e6c748aa808bea98cb72cbfbc.png"> 是入射方向半球的无穷小累加和。
<dd><img class=tex alt="f_r(x, \vec w', \vec w)" src="http://www.gollumbrowser.com/tc/math/3/0/a/30a69482bebdc4632fd158f107abc13d.png"> 是在该点从入射方向到出射方向光的反射比例。
<dd><img class=tex alt="L_i(x, \vec w')" src="http://www.gollumbrowser.com/tc/math/2/3/1/231bdec7b35be9bca3c8dbde6a6ee265.png"> 是该点的入射光位置及方向 <img class=tex alt="\vec w'" src="http://www.gollumbrowser.com/tc/math/2/2/8/2281d921f7c5871dcb25863cfea52a78.png">。
<dd><img class=tex alt="(\vec w' \cdot \vec n)" src="http://www.gollumbrowser.com/tc/math/d/9/b/d9b5f15286d2322a05365e52cb843714.png"> 是入射角带来的入射光衰减。</dd></dl>
<p>它的两个很显然的特性是：线性和空间同质性。由于只有乘法和加法运算，所以是线性的；由于在所有的位置和方向都一样，所以具有空间同质性。这也就意味着方程的解可以有很大范围的因数与排列。</p>
<p>渲染方程是渲染领域中的一个核心理论概念，它是渲染中不可感知方面的最抽象的正式表示。这个方程经过交叉点将出射光线与入射光线联系在一起，它代表了场景中全部的'光线传输'。所有更加完善的算法都可以看作是这个方程的特殊形式的解。</p>
<p><a name=.E5.A4.96.E9.83.A8.E9.93.BE.E6.8E.A5><u><font color=#0000ff></font></u></a>&nbsp;</p>
<h2><span class=editsection>[<a title=编辑本节 href="http://zh.wikipedia.org/w/index.php?title=%E6%B8%B2%E6%9F%93%E6%96%B9%E7%A8%8B&amp;action=edit&amp;section=2" target=_blank ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#0000ff>编辑</font></u></a>]</span><span class=mw-headline>外部链接</span></h2>
<ul>
    <li><a class="external text" title=http://graphics.stanford.edu/courses/cs348b-00/lectures/lecture12/ href="http://graphics.stanford.edu/courses/cs348b-00/lectures/lecture12/" target=_blank rel=nofollow ?><img src="http://gollum.easycp.de/gollum/theme/gollum/pix/ow.gif"><u><font color=#800080>课堂笔记</font></u></a>，来自于<a title=斯坦福大学 href="javascript:void(wb.w._link('http://zh.wikipedia.org/wiki/%E6%96%AF%E5%9D%A6%E7%A6%8F%E5%A4%A7%E5%AD%A6'))" ??><u><font color=#0000ff>斯坦福大学</font></u></a>课程 CS 348B， <em>计算机图形学：图像合成技术</em> </li>
</ul>
</div>
<img src ="http://www.cppblog.com/yaoming/aggbug/40099.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/yaoming/" target="_blank">姚明</a> 2008-01-01 05:40 <a href="http://www.cppblog.com/yaoming/archive/2008/01/01/40099.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>C语言上机实验</title><link>http://www.cppblog.com/yaoming/archive/2007/12/03/37680.html</link><dc:creator>姚明</dc:creator><author>姚明</author><pubDate>Mon, 03 Dec 2007 05:48:00 GMT</pubDate><guid>http://www.cppblog.com/yaoming/archive/2007/12/03/37680.html</guid><wfw:comment>http://www.cppblog.com/yaoming/comments/37680.html</wfw:comment><comments>http://www.cppblog.com/yaoming/archive/2007/12/03/37680.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.cppblog.com/yaoming/comments/commentRss/37680.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/yaoming/services/trackbacks/37680.html</trackback:ping><description><![CDATA[<p>/*--------------------------------------------------------------------------------------<br>专业：计算机原理与应用<br>姓名：姚明<br>学号：04051<br>日期：2007.12.3<br>说明：C语言上机实验1～6程序设计<br>---------------------------------------------------------------------------------------*/</p>
<p>&nbsp;</p>
<p>//------------------------------------------------------------<br>//&nbsp;&nbsp;<br>//&nbsp;&nbsp;&nbsp;实验2 基本数据类型和运算程序设计<br>//<br>//------------------------------------------------------------</p>
<p>#include &lt;stdio.h&gt;<br>#define PI 3.14159;</p>
<p>void main(void)<br>{<br>&nbsp;int k,p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* for task 1*/<br>&nbsp;int c;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* for task 2*/<br>&nbsp;int x,y,z,w;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* for task 3*/<br>&nbsp;float r, s;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* for task 4*/<br>&nbsp;unsigned short i,m,n,_result;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* for task 5*/<br>&nbsp;char a;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/* for task 6*/<br>&nbsp;<br>&nbsp;/*task 1*/<br>&nbsp;/*输入整数ｋ、ｐ,将整数ｋ的高字节作为结果的低字节,<br>&nbsp;整数ｐ的高字节作为结果的高字节,拼成一个新的整数,<br>&nbsp;然后输出;*/</p>
<p>&nbsp;printf("input int k,p:");<br>&nbsp;scanf("%x%x",&amp;k,&amp;p);<br>&nbsp;int newint = (p&amp;0xff00)|(k&amp;0xff00)&gt;&gt;8;<br>&nbsp;printf("new int = %x\n\n",newint);<br>&nbsp;getchar();<br>&nbsp;<br>&nbsp;/*task 2*/<br>&nbsp;/*输入字符ｃ。如果ｃ是大写字母,<br>&nbsp;则将ｃ转换成对应的小写,否则ｃ的值不变,<br>&nbsp;最后输出ｃ;*/</p>
<p>&nbsp;printf("input a character:");<br>&nbsp;c = getchar();<br>&nbsp;c &gt;= 'A' &amp;&amp; c &lt;= 'Z'? putchar(c + 'a'- 'A'): putchar(c);<br>&nbsp;putchar('\n');<br>&nbsp;putchar('\n');<br>&nbsp;<br>&nbsp;/*task 3*/<br>&nbsp;/*输入整数ｘ、ｙ、ｚ,输出其中最小值;*/<br>&nbsp;printf("input x, y, z:");<br>&nbsp;scanf("%d%d%d", &amp;x, &amp;y, &amp;z);<br>&nbsp;w = x &lt; y?x:y;<br>&nbsp;w = w &lt; z?w:z;<br>&nbsp;printf("min = %d\n\n",w);<br>&nbsp;<br>&nbsp;/*task 4*/<br>&nbsp;/*输入圆的半径值ｒ,计算并输出圆的面积<br>&nbsp;ｓ＝&#8719;ｒ２(&#8719;＝3.14159);*/</p>
<p>&nbsp;printf("input the radius r:");<br>&nbsp;scanf("%f", &amp;r);<br>&nbsp;s = r * r * PI;<br>&nbsp;printf("The acreage is %.2f\n\n",s);<br>&nbsp;<br>&nbsp;/*task 5*/<br>&nbsp;/* 输入无符号短整数<br>&nbsp;ｉ,ｍ,ｎ（0 &lt;= ｍ&lt;= 15, 1 &lt;= ｎ&lt;= 16-ｍ）,<br>&nbsp;取出ｉ从第ｍ位开始向左的ｎ位<br>&nbsp;（ｍ从右至左编号为0～15）,<br>&nbsp;并使其向左端（第15位）靠齐;*/</p>
<p>&nbsp;printf("input i, m, n(0 &lt;= m &lt;= 15, 1 &lt;= n &lt;= 16 - m):");<br>&nbsp;scanf("%hu%hu%hu", &amp;i, &amp;m, &amp;n);<br>&nbsp;_result = i &lt;&lt; 16 - m - n &amp; ~0xffff &gt;&gt; m + n;<br>&nbsp;printf("The result is %hu\n\n", _result);<br>&nbsp;getchar();<br>&nbsp;<br>&nbsp;/*task 6*/<br>&nbsp;/*输入一个字符,如果是数字（０～９）<br>&nbsp;则输出该数字代表的整数（８位）的反码,<br>&nbsp;否则原样输出。（反码用十六进制数表示,<br>&nbsp;例如,整数0的反码为0xff,整数1的反码为0xfe,<br>&nbsp;整数9的反码0xf6。）*/</p>
<p>&nbsp;printf("input a charater:");<br>&nbsp;a = getchar();<br>&nbsp;a &gt;= '0' &amp;&amp; a &lt;= '9'?printf("%hx",~a - '0'):putchar(a);<br>&nbsp;printf("\n\n");<br>&nbsp;getchar();<br>}</p>
<p><br>//------------------------------------------------------------<br>//&nbsp;&nbsp;<br>//&nbsp;&nbsp;&nbsp;实验3 C程序流程控制实验<br>//<br>//------------------------------------------------------------<br>#include &lt;stdio.h&gt;<br>void main()<br>{<br>&nbsp;&nbsp;&nbsp; int c;&nbsp;&nbsp;&nbsp; /* 每行的元素值(循环中生成), 初值为1 */<br>&nbsp;&nbsp;&nbsp; int n;&nbsp;&nbsp;&nbsp; /* 显示的行数 */<br>&nbsp;&nbsp;&nbsp; int i, j; /* 循环控制 */<br>&nbsp;<br>&nbsp;&nbsp;&nbsp; /* 输入行数,显示13行以内为佳 */<br>&nbsp;&nbsp;&nbsp; do<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("Input n=");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; scanf("%d",&amp;n);&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; } while(n &lt;= 0 || n &gt; 13); <br>&nbsp;&nbsp;&nbsp; for(i = 0; i &lt; n; i++)<br>&nbsp;&nbsp;&nbsp; { </p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for(j = 0; j &lt; n - i; j++) /* 输入每行前的空格 */<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("%3c", ' ');</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; c=1;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* 每行开始输出前都将c重置为1 */</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for(j = 0; j &lt;= i; j++)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; { <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("%-3d", c);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("%-3c", ' ');<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; c = c * (i - j) / (j + 1); /* 核心: 递推公式 */<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; printf("\n");<br>&nbsp;&nbsp;&nbsp; }<br>}</p>
<p>运行结果(VC):<br>=======================================================================<br>Input n=10↙<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp; 1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp; 2&nbsp;&nbsp;&nbsp;&nbsp; 1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp; 3&nbsp;&nbsp;&nbsp;&nbsp; 3&nbsp;&nbsp;&nbsp;&nbsp; 1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp; 4&nbsp;&nbsp;&nbsp;&nbsp; 6&nbsp;&nbsp;&nbsp;&nbsp; 4&nbsp;&nbsp;&nbsp;&nbsp; 1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp; 5&nbsp;&nbsp;&nbsp;&nbsp; 10&nbsp;&nbsp;&nbsp; 10&nbsp;&nbsp;&nbsp; 5&nbsp;&nbsp;&nbsp;&nbsp; 1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp; 6&nbsp;&nbsp;&nbsp;&nbsp; 15&nbsp;&nbsp;&nbsp; 20&nbsp;&nbsp;&nbsp; 15&nbsp;&nbsp;&nbsp; 6&nbsp;&nbsp;&nbsp;&nbsp; 1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp; 7&nbsp;&nbsp;&nbsp;&nbsp; 21&nbsp;&nbsp;&nbsp; 35&nbsp;&nbsp;&nbsp; 35&nbsp;&nbsp;&nbsp; 21&nbsp;&nbsp;&nbsp; 7&nbsp;&nbsp;&nbsp;&nbsp; 1<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp; 8&nbsp;&nbsp;&nbsp;&nbsp; 28&nbsp;&nbsp;&nbsp; 56&nbsp;&nbsp;&nbsp; 70&nbsp;&nbsp;&nbsp; 56&nbsp;&nbsp;&nbsp; 28&nbsp;&nbsp;&nbsp; 8&nbsp;&nbsp;&nbsp;&nbsp; 1<br>&nbsp;&nbsp; 1&nbsp;&nbsp;&nbsp;&nbsp; 9&nbsp;&nbsp;&nbsp;&nbsp; 36&nbsp;&nbsp;&nbsp; 84&nbsp;&nbsp;&nbsp; 126&nbsp;&nbsp; 126&nbsp;&nbsp; 84&nbsp;&nbsp;&nbsp; 36&nbsp;&nbsp;&nbsp; 9&nbsp;&nbsp;&nbsp;&nbsp; 1<br>=======================================================================</p>
<p><br>/*&nbsp;编写一个程序，将用户输入的任意正整数逆转，例如，输入1234，输出4321。*/<br>#include &lt;stdio.h&gt;<br>void main()<br>{<br>&nbsp;&nbsp;&nbsp; int num,_result=0;<br>&nbsp;printf("enter number:");<br>&nbsp;scanf("%d",&amp;num);<br>&nbsp;while(num)<br>&nbsp;{<br>&nbsp;&nbsp;_result=_result*10;<br>&nbsp;&nbsp;_result= num%10+_result;<br>&nbsp;&nbsp;num/=10;<br>&nbsp;}<br>&nbsp;printf("%d\n",_result);<br>}</p>
<p>/*&nbsp;验证歌德巴赫猜想：任何充分大（&gt;=4）的偶数都可以用两个素数之和表示，<br>将4到100中的所有偶数分别用两个素数之和的形式表示。（例如：4=2+2，100=3+97）*/</p>
<p><br>#include &lt;stdio.h&gt;<br>int IsPrime(int n);</p>
<p>void main()<br>{<br>&nbsp;for(int i=4;i&lt;=100;i+=2)<br>&nbsp;{<br>&nbsp;&nbsp;int x=0;</p>
<p>&nbsp;&nbsp;for(x=2;x&lt;i;x++)<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;if(IsPrime(x)&amp;&amp;IsPrime(i-x))<br>&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;printf("%d = %d + %d\n",i,x,i-x);<br>&nbsp;&nbsp;&nbsp;&nbsp;break;<br>&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;}<br>&nbsp;}<br>}</p>
<p>int IsPrime(int n) <br>{ <br>&nbsp;int i; <br>&nbsp;if (n == 1 || n == 2 || n == 3 || n == 5) <br>&nbsp;&nbsp;return 1; <br>&nbsp;else if (n % 2) <br>&nbsp;{ <br>&nbsp;&nbsp;for (i = 3; i &lt;= n / 2 + 1; i += 2) <br>&nbsp;&nbsp;{ <br>&nbsp;&nbsp;&nbsp;if (n % i == 0) return 0; <br>&nbsp;&nbsp;} <br>&nbsp;&nbsp;return 1; <br>&nbsp;} <br>&nbsp;else <br>&nbsp;{ <br>&nbsp;&nbsp;return 0; <br>&nbsp;} <br>} </p>
<p><br>/*计算两个数的最大公约数*/</p>
<p>#include &lt;stdio.h&gt;<br>unsigned int gcd(unsigned int,unsigned int);</p>
<p>void main()<br>{<br>&nbsp;int x,y;<br>&nbsp;printf("Enter 2 num:");<br>&nbsp;scanf("%d%d",&amp;x,&amp;y);<br>&nbsp;printf("common divisor:%d\n",gcd(x,y));<br>}</p>
<p>unsigned int gcd(unsigned int x,unsigned int y) // common divisor<br>{ <br>&nbsp;unsigned int i,j,t; <br>&nbsp;if(x==0) <br>&nbsp;&nbsp;return y; <br>&nbsp;if(y==0) <br>&nbsp;&nbsp;return x;<br>&nbsp;for(i=0;0==(x&amp;1);x&gt;&gt;=1,++i);<br>&nbsp;for(j=0;0==(y&amp;1);y&gt;&gt;=1,++j); <br>&nbsp;if(j&lt;i) <br>&nbsp;&nbsp;i=j;<br>&nbsp;for(;;)<br>&nbsp;{ <br>&nbsp;&nbsp;if(x&lt;y)<br>&nbsp;&nbsp;&nbsp;t=y,y=x,x=t;<br>&nbsp;&nbsp;if(0==(x-=y))<br>&nbsp;&nbsp;&nbsp;return y&lt;&lt;i;<br>&nbsp;&nbsp;for(;0==(x&amp;1);x&gt;&gt;=1);<br>&nbsp;}<br>}</p>
<p><br>/*&nbsp;输出所输入的正文。输出时将连续的多个空格字符和横向制表符缩减为一个空格字符，<br>空行删去不输出（空行是指仅由空格字符、横向制表符和行结束符组成的行）*/</p>
<p>#include &lt;stdio.h&gt;<br>int main()<br>{<br>&nbsp;&nbsp; int ch, flag1 =0, flag2 = 0;<br>&nbsp;&nbsp;&nbsp; while((ch=getchar())!=EOF)<br>&nbsp;&nbsp;&nbsp; switch(ch){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case '\n':<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(flag2) {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; flag1=flag2=0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; putchar(ch);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case ' ':<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; case '\t':<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; flag1=1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; break;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; default:<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(flag1){<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; putchar(' ');<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; flag1=0;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; putchar(ch);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; flag2=1;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; continue;<br>&nbsp;&nbsp;&nbsp; }<br>&nbsp;&nbsp;&nbsp; return 0;<br>}</p>
<p>//------------------------------------------------------------<br>//&nbsp;&nbsp;<br>//&nbsp;&nbsp;&nbsp;实验4 C函数程序设计<br>//<br>//------------------------------------------------------------</p>
<p>#include &lt;stdio.h&gt;</p>
<p>int factorial(int n);&nbsp;&nbsp;&nbsp;&nbsp; //计算阶乘<br>double reckon(int n);&nbsp;&nbsp;&nbsp;&nbsp; //公式函数</p>
<p>void main()<br>{<br>&nbsp;int num;<br>&nbsp;printf("Enter num:");<br>&nbsp;scanf("%d",&amp;num);<br>&nbsp;printf("out:%f\n",reckon(num));<br>}</p>
<p>int factorial(int n)<br>{<br>&nbsp;long _result; <br>&nbsp;&nbsp;&nbsp; if(n&gt;1)&nbsp; <br>&nbsp;&nbsp;_result=factorial(n-1)*n; <br>&nbsp;&nbsp;&nbsp; else&nbsp; _result=1; <br>&nbsp;&nbsp;&nbsp; return(_result);<br>}</p>
<p>double reckon(int n)<br>{<br>&nbsp;double sum=0;<br>&nbsp;for(int i=1;i&lt;n;i++)<br>&nbsp;{<br>&nbsp;&nbsp;double ret = factorial(i);<br>&nbsp;&nbsp;sum += 1/ret;<br>&nbsp;}<br>&nbsp;return sum;<br>}</p>
<p><br>//------------------------------------------------------------<br>//&nbsp;&nbsp;<br>//&nbsp;&nbsp;&nbsp;实验5 数组程序设计<br>//<br>//------------------------------------------------------------</p>
<p>/* 用rand函数模拟掷双骰子，计算投掷出的两个值的和。在程序中把这两个骰子各掷3600次，<br>用一维数组记录每一种可能值的出现次数，以表格格式打印出结果，判断算出的和是否合理。*/</p>
<p>#include &lt;stdio.h&gt;<br>#include &lt;stdlib.h&gt;<br>#include &lt;memory.h&gt;<br>#include &lt;time.h&gt;</p>
<p>void main()<br>{<br>&nbsp;&nbsp; int rands[13];int num1,num2;int i;<br>&nbsp;&nbsp; memset(rands,0,sizeof(int)*13);<br>&nbsp;&nbsp; <br>&nbsp;&nbsp; /* Seed the random-number generator with current time so that<br>&nbsp;&nbsp;&nbsp; * the numbers will be different every time we run.<br>&nbsp;&nbsp;&nbsp; */<br>&nbsp;&nbsp; srand( (unsigned)time( NULL ) );</p>
<p>&nbsp;&nbsp; for(i = 1;&nbsp;&nbsp; i &lt; 3600; i++ )<br>&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; num1 = rand()%6;<br>&nbsp;&nbsp;&nbsp; num2 = rand()%6;<br>&nbsp;&nbsp;&nbsp; num1==0?num1=6:num1;<br>&nbsp;&nbsp;&nbsp; num2==0?num2=6:num2;<br>&nbsp;&nbsp;&nbsp; rands[num1+num2]++;<br>&nbsp;&nbsp; }</p>
<p>&nbsp;&nbsp; printf("-------------------------------------------------------------------------------\n");<br>&nbsp;&nbsp; printf("number:\t");<br>&nbsp;&nbsp; for(i=2; i&lt;13; i++)<br>&nbsp;&nbsp; {<br>&nbsp;&nbsp;printf("%d\t",i);<br>&nbsp;&nbsp; }<br>&nbsp;&nbsp; printf("\ntimes:\t");<br>&nbsp;&nbsp; for(i=2; i&lt;13; i++)<br>&nbsp;&nbsp; {<br>&nbsp;&nbsp;printf("%d\t",rands[i]);<br>&nbsp;&nbsp; }<br>&nbsp;&nbsp; printf("\n-------------------------------------------------------------------------------\n");<br>}</p>
<p>/* 定义函数stncat(s,t,n),从串t中至多取 n个字符添加到 s的尾部，在主函数中输入两个字符串和一个整数n，<br>调用函数stncat按要求连接成一个字符串，输出连接后的结果字符串。*/</p>
<p>#include &lt;stdio.h&gt;</p>
<p>char * strncat(char*,const char *,int);</p>
<p>void main()<br>{<br>&nbsp;&nbsp; char string[80] = "This is the initial string!";<br>&nbsp;&nbsp; char suffix[] = " extra text to add to the string...";<br>&nbsp;&nbsp; /* Combine strings with no more than 19 characters of suffix: */<br>&nbsp;&nbsp; printf( "Before: %s\n", string );<br>&nbsp;&nbsp; strncat( string, suffix, 19 );<br>&nbsp;&nbsp; printf( "After:&nbsp; %s\n", string );</p>
<p>}</p>
<p>char * strncat(char *dest,const char *source,int count)</p>
<p>{</p>
<p>&nbsp;&nbsp; char *p = dest;</p>
<p>&nbsp;&nbsp; while (*p) p++;</p>
<p>&nbsp;&nbsp; while (count-- &amp;&amp; (*p++ = *source++));</p>
<p>&nbsp;&nbsp; *p = '\0';</p>
<p>&nbsp;&nbsp; return(dest);<br>}</p>
<p><br>/* 找出二维数组b[3][3]的&#8220;鞍点&#8221;（即行上为最大，列上为最小的元素）<br>及其位置（行、列下标），如果不存在鞍点也输出相应信息。*/</p>
<p>#include&lt;stdio.h&gt;<br>#define N 3<br>#define M 3</p>
<p>void main()<br>{<br>&nbsp;int a[N][M],i,j,k,max=0,xmax,ymax,found=0,flag=1;<br>&nbsp;<br>&nbsp;printf("Input the array(%d numbers):\n",N*M);<br>&nbsp;for( i=0;i&lt;N;i++ )<br>&nbsp;{<br>&nbsp;&nbsp;for( j=0;j&lt;M;j++ )<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;printf("array[%d][%d]=",i,j);<br>&nbsp;&nbsp;&nbsp;scanf("%d",&amp;a[i][j]);<br>&nbsp;&nbsp;}<br>&nbsp;}<br>&nbsp;<br>&nbsp;for( i=0;i&lt;N;i++ )<br>&nbsp;{<br>&nbsp;&nbsp;for( j=0;j&lt;M;j++ )<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;if( max&lt;a[i][j] )<br>&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;max=a[i][j];<br>&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;}<br>&nbsp;&nbsp;<br>&nbsp;&nbsp;for( j=0;j&lt;M;j++ )<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;if(max==a[i][j])<br>&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;xmax=j;<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;for( k=0;k&lt;N;k++ )<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if( max&gt;a[k][xmax] )<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;flag=0;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;if( flag==1 )<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ymax = i;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("%d is the andian.\n",max);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("pt: x=%d\ty=%d\n",xmax+1,ymax+1);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;found++;<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;}<br>&nbsp;}<br>&nbsp;if( found==0 )<br>&nbsp;&nbsp;printf("andian not found!\n");<br>} </p>
<p><br>/* 八皇后问题，在8*8方格国际象棋盘上放置8个皇后，任意两个皇后不能位于同一行、<br>同一列或同一斜线（正斜线或反斜线）上，输出所有可能的放法。*/<br>#include &lt;stdio.h&gt;<br>#include "math.h"</p>
<p>void paichu(char (*a)[8],int i,int j);</p>
<p>void main()<br>{<br>&nbsp;int i,j,k,n;<br>&nbsp;char a[8][8];<br>&nbsp;for(k=0;k&lt;8;++k)<br>&nbsp;{<br>&nbsp;&nbsp;n=0;&nbsp; <br>&nbsp;&nbsp;for(i=0;i&lt;8;++i)<br>&nbsp;&nbsp;&nbsp;for(j=0;j&lt;8;++j)<br>&nbsp;&nbsp;&nbsp;&nbsp;a[i][j]='*';<br>&nbsp;&nbsp;&nbsp;for(i=0;i&lt;8;++i)<br>&nbsp;&nbsp;&nbsp;&nbsp;for(j=0;j&lt;8;++j)<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(i==0 &amp;&amp; j&lt;k) continue;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else if(a[i][j]=='*' &amp;&amp; (fabs(j-k)&lt;i+5)) <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;paichu(a,i,j);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a[i][j]='*';<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;for(i=0;i&lt;8;++i)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for(j=0;j&lt;8;++j)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(a[i][j]=='*') ++n;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(n!=8) continue;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for(i=0;i&lt;8;++i)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;for(j=0;j&lt;8;++j)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("%c",a[i][j]);<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("\n");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;printf("\n");<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;getchar(); <br>&nbsp;}<br>}</p>
<p>void paichu(char (*a)[8],int i,int j)<br>{<br>&nbsp;int k,n,i1,i2,j1,j2;<br>&nbsp;if(i&gt;j) n=j;<br>&nbsp;else n=i;<br>&nbsp;for(k=0;k&lt;8;++k)<br>&nbsp;{<br>&nbsp;&nbsp;*(*(a+k)+j)='o';<br>&nbsp;&nbsp;*(*(a+i)+k)='o';<br>&nbsp;}<br>&nbsp;i1=i-n;<br>&nbsp;j1=j-n;<br>&nbsp;while(i1&lt;8 &amp;&amp; j1&lt;8)<br>&nbsp;{<br>&nbsp;&nbsp;*(*(a+i1)+j1)='o';<br>&nbsp;&nbsp;++i1;<br>&nbsp;&nbsp;++j1;<br>&nbsp;}<br>&nbsp;if(i+j&lt;8) i2=0;<br>&nbsp;&nbsp;&nbsp; else i2=i-7+j;<br>&nbsp;j2=j+i-i2;<br>&nbsp;while(i2&lt;8 &amp;&amp; j2&gt;=0)<br>&nbsp;{<br>&nbsp;&nbsp;*(*(a+i2)+j2)='o';<br>&nbsp;&nbsp;++i2;<br>&nbsp;&nbsp;--j2;<br>&nbsp;}<br>}</p>
<p>//------------------------------------------------------------<br>//&nbsp;&nbsp;<br>//&nbsp;&nbsp;&nbsp;实验6 指针程序设计<br>//<br>//------------------------------------------------------------</p>
<p>1．2 运行下面的程序之前，先给出你自己认为的结果，再看看运行结果是否和你想的一样，试着解释程序输出的结果。<br>#include &lt;stdio.h&gt;<br>#include &lt;stdlib.h&gt;<br>&nbsp;<br>void f(char s[100])<br>{<br>&nbsp; &nbsp;printf("s size in function f: %d\n", sizeof(s));<br>}</p>
<p>int main()<br>{<br>&nbsp; &nbsp;char s[] = "hello";&nbsp;&nbsp;&nbsp;<br>&nbsp; &nbsp;char *p, *mp;<br>&nbsp; &nbsp;int n;<br>&nbsp; &nbsp;char str[100];<br>&nbsp;&nbsp;<br>&nbsp; &nbsp;printf("s size: %d\n", sizeof(s));<br>&nbsp;<br>&nbsp; &nbsp;p = s;<br>&nbsp; &nbsp;printf("p size: %d\n", sizeof(p));<br>&nbsp;<br>&nbsp; &nbsp;printf("n size: %d\n", sizeof(n));<br>&nbsp;<br>&nbsp; &nbsp;printf("str size: %d\n", sizeof(str));<br>&nbsp;<br>&nbsp; &nbsp;mp = malloc(100);<br>&nbsp; &nbsp;printf("mp size: %d\n", sizeof(mp));<br>&nbsp;<br>&nbsp; &nbsp;f(str);<br>&nbsp;<br>&nbsp; &nbsp;return 0;<br>}</p>
<p>sizeof是是长度运算符, 获得数据类型或是变量的长度，如果是数据类型，<br>则返回数据类型大小，如果是用数组，则返回数组所占空间大小</p>
<p>s size:6&nbsp; s是自动分配的数组,根据所给字符串长度，编译器自动分配空间，(h,e, l, l, o, \0)<br>p size:4&nbsp; p是char*,通常，指针长度和计算机CPU的位数相等，此计算机为32位，即4字节<br>str size:100 返回数组长度，str是用户自定义长度的数组<br>mp size:4 同上 p size<br>s size in function f:4 f函数属于传参操作，即指针传递，没有开辟新空间，函数对s做指针处理。</p>
<p>&nbsp;</p>
<p>2．判断与改错：<br>#include &lt;stdio.h&gt;</p>
<p>void upper(char *s)<br>{<br>&nbsp; while (*s != '\0')<br>&nbsp; {<br>&nbsp;&nbsp;&nbsp; if (*s &gt;= 97 &amp;&amp; *s &lt;= 122)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *s -= 32;<br>&nbsp;&nbsp;&nbsp; s++;<br>&nbsp; }<br>}</p>
<p>void lower(char *s)<br>{<br>&nbsp; while (*s != '\0')<br>&nbsp; {<br>&nbsp;&nbsp;&nbsp; if (*s &gt;= 65 &amp;&amp; *s &lt;= 90)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *s += 32;<br>&nbsp;&nbsp;&nbsp; s++;<br>&nbsp; }<br>}</p>
<p>int main ()<br>{<br>&nbsp; char str[100];<br>&nbsp; char *p, *q;</p>
<p>&nbsp; printf("Input a string with uppercase, lowercase or digits: \n");<br>&nbsp; gets(str);<br>&nbsp; printf("Original:&nbsp; %s\n",str);</p>
<p>&nbsp; p = str;<br>&nbsp; upper(p);<br>&nbsp; printf("Uppercase: %s\n",p);</p>
<p>&nbsp; q = str;<br>&nbsp; lower(q);<br>&nbsp; printf("Lower:&nbsp;&nbsp;&nbsp;&nbsp; %s\n",q);</p>
<p>&nbsp; return 0;<br>}</p>
<p>错误原因:<br>p,q两个指针指向了同一个数据源str,对p,q的操作会直接改变str的内容,<br>printf函数必须在每次数据改变时，分别打印到屏幕，否则只能输出3行同样的str数据。</p>
<p><br>/*编写一个你自己的strlen函数，输入一个字符串，返回它的长度，<br>并在一个完整的程序中验证它。提示：字符串的结尾为 &#8216;\0&#8217;*/</p>
<p>void main ()<br>{<br>&nbsp;&nbsp; char buffer[61] = "How long am I?";<br>&nbsp;&nbsp; int&nbsp; len;<br>&nbsp;&nbsp; len = strlen( buffer );<br>&nbsp;&nbsp; printf( "'%s' is %d characters long\n", buffer, len );<br>}</p>
<p>int strlen(const char * str) {<br>&nbsp;&nbsp;&nbsp;&nbsp; int length = 0 ;<br>&nbsp;&nbsp;&nbsp;&nbsp; while (*str++ )<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ++ length;<br>&nbsp;&nbsp;&nbsp;&nbsp; return&nbsp; length;<br>&nbsp;} </p>
<p>/*指针数组最频繁的用处是存放具有不同长度的字符串。<br>试用指针数组对输入的n个长度不等的字符串进行排序，<br>升序。字符串的比较可以用标准库中的strcmp函数。*/<br>#include &lt;stdio.h&gt;</p>
<p>void BubbleSort(char* pt[1024],int count);</p>
<p>void main()<br>{<br>&nbsp;char buffer[1024];<br>&nbsp;char *pBuffer;<br>&nbsp;char *pt[1024];<br>&nbsp;int i, ch;<br>&nbsp;<br>&nbsp;printf( "Do over please input '0'\n" );<br>&nbsp;printf( "Before:\n" );<br>&nbsp;<br>&nbsp;/* Read in single line from "stdin": */<br>&nbsp;for( i = 0; (i &lt; 1024) &amp;&amp;&nbsp; ((ch = getchar()) != EOF) <br>&nbsp;&nbsp;&amp;&amp; (ch != '0'); i++ )<br>&nbsp;&nbsp;buffer[i] = (char)ch;<br>&nbsp;<br>&nbsp;/* Terminate string with null character: */<br>&nbsp;buffer[i] = '\0';<br>&nbsp;<br>&nbsp;int pl=0;<br>&nbsp;pt[pl] = buffer;</p>
<p>&nbsp;pBuffer = buffer;<br>&nbsp;while (*pBuffer++)<br>&nbsp;{<br>&nbsp;&nbsp;if(*pBuffer == '\n')<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;++pl;<br>&nbsp;&nbsp;&nbsp;*pBuffer = '\0';<br>&nbsp;&nbsp;&nbsp;pBuffer++;<br>&nbsp;&nbsp;&nbsp;pt[pl] = pBuffer;<br>&nbsp;&nbsp;}<br>&nbsp;}</p>
<p>&nbsp;BubbleSort(pt,pl);</p>
<p>&nbsp;printf( "After:\n" );<br>&nbsp;for(i=0;i&lt;pl;i++)<br>&nbsp;{<br>&nbsp;&nbsp;printf( "%s\n", pt[i]);<br>&nbsp;}<br>}</p>
<p>void BubbleSort(char* in[1024],int count)<br>{<br>&nbsp;char* temp;<br>&nbsp;for(int y=0;y&lt;count-1;y++)<br>&nbsp;{<br>&nbsp;&nbsp;for(int x=1;x&lt;count-y;x++)<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;if((in[x][0])&lt;(in[x-1][0]))<br>&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;temp=in[x-1];<br>&nbsp;&nbsp;&nbsp;&nbsp;in[x-1]=in[x];<br>&nbsp;&nbsp;&nbsp;&nbsp;in[x]=temp;<br>&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;}<br>&nbsp;}<br>} </p>
<p><br>/*编写一个带有命令行参数的程序showletter*/</p>
<p>#include &lt;stdio.h&gt;<br>#include &lt;stdlib.h&gt;</p>
<p>int main(int argc, char* argv[])<br>{</p>
<p>&nbsp;printf("showletter [start] [end]\nstart\t a~z\nend\t0~99\n");</p>
<p>&nbsp;int start=0,end=0;</p>
<p>&nbsp;if(argc == 1)<br>&nbsp;{<br>&nbsp;&nbsp;start = 'a';<br>&nbsp;&nbsp;end&nbsp;&nbsp; = 'z';<br>&nbsp;}<br>&nbsp;else if(argc == 2)<br>&nbsp;{<br>&nbsp;&nbsp;start = (int)argv[1][0];<br>&nbsp;&nbsp;end&nbsp;&nbsp; = 'z';<br>&nbsp;}<br>&nbsp;else if(argc == 3)<br>&nbsp;{<br>&nbsp;&nbsp;start = (int)argv[1][0];<br>&nbsp;&nbsp;end&nbsp;&nbsp; =&nbsp; start+atoi(argv[2]);<br>&nbsp;}<br>&nbsp;else<br>&nbsp;{<br>&nbsp;&nbsp;printf("The command parameter error!\n");<br>&nbsp;}</p>
<p>&nbsp;&nbsp;for(int i=start; i&lt;end; i++)<br>&nbsp;{<br>&nbsp;&nbsp; if(i&gt;'z')<br>&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; printf("\n");<br>&nbsp;&nbsp;&nbsp; end-=26;<br>&nbsp;&nbsp;&nbsp; i='a';<br>&nbsp;&nbsp; }<br>&nbsp;&nbsp; printf("%c",i);<br>&nbsp;}<br>&nbsp;printf("\n");<br>&nbsp;<br>&nbsp;return 0;<br>}</p>
<img src ="http://www.cppblog.com/yaoming/aggbug/37680.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/yaoming/" target="_blank">姚明</a> 2007-12-03 13:48 <a href="http://www.cppblog.com/yaoming/archive/2007/12/03/37680.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>C/S模式考试程序制作详解</title><link>http://www.cppblog.com/yaoming/archive/2007/10/26/35185.html</link><dc:creator>姚明</dc:creator><author>姚明</author><pubDate>Thu, 25 Oct 2007 16:43:00 GMT</pubDate><guid>http://www.cppblog.com/yaoming/archive/2007/10/26/35185.html</guid><wfw:comment>http://www.cppblog.com/yaoming/comments/35185.html</wfw:comment><comments>http://www.cppblog.com/yaoming/archive/2007/10/26/35185.html#Feedback</comments><slash:comments>3</slash:comments><wfw:commentRss>http://www.cppblog.com/yaoming/comments/commentRss/35185.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/yaoming/services/trackbacks/35185.html</trackback:ping><description><![CDATA[<table cellSpacing=0 cellPadding=0 border=0>
    <tbody>
        <tr>
            <td><span id=docinfo>[ <font color=#009900>原创文档</font> 本文适合高级读者 已阅读19451次 ]</span></td>
            <td align=right>&nbsp;</td>
        </tr>
    </tbody>
</table>
<table cellSpacing=0 cellPadding=0 border=0>
    <tbody>
        <tr>
            <td>
            <p align=center><strong>大型作业答辩：C/S考试系统程序制作详解<br></strong><br><br>作者：<a href="&#109;&#97;&#105;&#108;&#116;&#111;&#58;&#121;&#97;&#111;&#109;&#105;&#110;&#103;&#109;&#97;&#105;&#108;&#64;&#115;&#105;&#110;&#97;&#46;&#99;&#111;&#109;"><font color=#0000ff><u>姚明</u></font></a></p>
            <p><a href="http://www.vckbase.com/code/downcode.asp?id=2228"><u><font color=#800080>下载源代码</font></u></a><br><br><br><img src="http://www.vckbase.com/document/image/paragraph.gif"> 程序组成结构<br><br>一、服务器程序
            <ol>
                <li>采用了WinSocket32的完成端口模型(I/O completion ports)
                <li>WIN32多线程技术
                <li>ODBC APIS 进行数据库操作 </li>
            </ol>
            二、客户端程序<br><br>用Win32 API函数构造主窗体和界面元素，如图一所示：<br><br><img style="WIDTH: 380px; HEIGHT: 512px" height=512 src="http://www.vckbase.com/document/journal/vckbase27/images/csexamsys1.gif" width=380 border=0><br>图一 程序组织结构<br><br><img src="http://www.vckbase.com/document/image/paragraph.gif"> 服务器程序详解<br><br>一、完全端口模型(I/O completion ports)是迄今为止最为复杂的一种I/O模型，假如一个程序需要管理为数众多的套接字，那么采用这种模型往往可以达到最佳的系统性能，不幸的是该模型只适用与WIN2000和WINNT操作系统，因其设计的复杂性，只有在你的应用程序需要同时管理数百乃至上千个套接字的时候，而且希望随着系统内安装的CPU的数量增多，应用程序的性能也可以线性的提升，才考虑采用&#8220;完成端口模型&#8221;(WEB服务器便是这方面的典型例子)。I/O completion ports是唯一适用于高负载服务器的一个技术，它利用一些线程帮助平衡&#8220;I/O请求&#8221;所引起的负载，这样的构架特别适合应用在SMP系统中产生所谓的&#8220;Scalable&#8221;服务器，(Scalable是指能够籍着增加RAM或磁盘空间，CPU个数而提升应用程序效能的一种系统)。<br><br>二、完全端口模型的具体实现<br>　　为了使用&#8220;完成端口模型&#8221;，我产生了一堆线程在端口上等待，线程数量=CPU个数x2+2，我将每个客户端产生的文件句柄与I/O completion ports端口相关联，建立了这种关系之后，任何客户端发出操作请求，便会导致I/O completion packet被送到&#8220;完成端口&#8221;去，这个步骤是操作系统完成的，为了回应I/O completion packet，我让I/O completion释放一个等待中的线程，如果目前没有线程正在等待，它不会为这个客户端N产生新的线程, 当作用中的线程处理完相应客户端的&#8220;overlapped I/O&#8221;后，将返回I/O completion端口进行等待，客户端N这时才能够被处理，这样就保证了我的Workers线程总是保持一个稳定的数量(CPU个数x2+2)。如图二所示：<br><br><img style="WIDTH: 347px; HEIGHT: 338px" height=338 src="http://www.vckbase.com/document/journal/vckbase27/images/csexamsys2.gif" width=347 border=0><br>图二　完全端口线程模型示意图<br><br>三、数据库的操作实现<br>　　这部分功能主要是通过WinSocket32 API和ODBC API结合使用来实现的,服务端进入监听状态后,为每个客户端提供相应线程处理发过来的指令,通过分析指令,作出以下相应的操作：<br>客户端发送的指令(自定义的):
            <pre>      login: 登陆校验 参数:用户名,科目,密码
            Srecv:ScanTm: 检查服务器时间校对试卷修改试卷状态,抛出计数值
            Srecv:GetSta: 获取试卷状态
            Srecv:GetRlt: 获取上次做答
            Srecv:GetNum: 获得试卷相关信息(总题数,开考时间,结束时间)
            Srecv:GetQue: 获取试卷题目内容.
            Srecv:SaveDt: 保存试卷
            Srecv:ChanST: 修改试卷状态.      </pre>
            四、服务器程序总结<br>　　数据库被单独存放在一个服务器中可以保证数据安全性，程序会将客户端的一切操作显示在窗口中，用户可以通过观察窗口,知道所有客户端的动作。这个程序采用&#8220;完成端口&#8221;模型，可以满足大规模的考试需求。<br><br><img src="http://www.vckbase.com/document/image/paragraph.gif"> 客户端程序详解<br>一、窗口完全采用Win32API函数生成<br>主要包含一下标准控件：
            <pre>      static控件
            Edit控件
            Button控件
            Scroll控件
            窗口元素全部采用计算后的相对坐标定位,所以800X600和1024X768下均能正常显示，      </pre>
            二、试卷的初始化<br>　　考虑到每张试卷的题目数量都不同，为了节约内存空间，所以我在堆中动态生成了一个试卷结构体，通过向服务器程序发送GetNum:指令来获得试卷总题数QuestionNum,然后使用TestPaper=new TestRubric [QuestionNum]
            <pre>/*结构体定义*/
            //试卷每道题的结构
            struct Questions{
            BOOL state;
            char Text [512];
            };
            struct SelectObject{
            BOOL state;
            char Text[256];
            };
            struct TestRubric{
            struct Questions Tile;
            struct SelectObject choose [4];
            };
            </pre>
            由于TextOut函数不支持自动换行,所以换行操作必须由我自己完成.因此我用同样的方法在堆中创建了一个Screen用作屏幕显示的结构体<br>
            <pre>Screen=new  Lines[LINES]
            struct Lines{
            int earmark; //用来存储Button的ID
            BOOL color1;//置颜色标志
            BOOL color2;//置颜色标志
            char Line [512];
            };      </pre>
            LINES=扫描TestPaper中超过屏幕宽度的行数+ QuestionNum*5+QuestionNum*3<br>屏幕宽度=客户区的宽/每个文字的宽度/2*2<br>屏幕高度=客户区的高/每个文字的高度<br>为每一体产生4个互斥的按钮<br>按钮总数= QuestionNum*4<br>在堆中生成hWndList数组保存按钮handle<br>hWndList=new hWnd [QuestionNum*4]<br>按钮ID=题号*10+选项号<br>Screen.earmark=按钮ID<br><br><img src="http://www.vckbase.com/document/journal/vckbase27/images/csexamsys3.gif" border=0><br>图三 <br><br>　　将TestPaper中的内容经过换行处理之后Copy到Screen结构中，并设置好Screen.earmark，Screen.Color1, Screen.Color2。在主窗口消息循环的WM_PAINT消息中将Screen.Line显示在窗口中：
            <pre>      TextOut(hdc,x,cyhar*i,Screen.Line,strlen(Screen.Line));      </pre>
            并检查Screen.earmark中是否为零,不为零就：
            <pre>      ShowWindow(hWndList[Sreen.earmark/10-1] [Screen.earmark%10-1],1);      </pre>
            <p>Screen.Color1, Screen.Color2是否为1,如果为1，则改变颜色显示。<br><br>三、换行中存在的问题<br>行宽=客户区的象素宽/每个文字的宽度/2*2是偶数；<br>汉字占用双字节，字母和标点符号占用单字节；<br>一行文字=字母+标点+汉字 (有可能产生奇数宽)；<br>当一行文字产生一个奇数宽，最后一个字符又是汉字的时,就会把这个汉字切成两份，另一半会在下一行中显示,这就造成了乱码；<br>　　我的解决办法是在换行时增加一个变量HanChar=0，当扫描到字母或是标点时，就HanChar++。一行文字扫描完后需要另起一行时，判断HanChar的奇偶性，当为奇数时行宽往里缩进一个字节，以避免以上情况。<br><br>四、客户端程序总结<br>　　由于客户端界面采用大量计算，显示的内容不会是固定的模式，他会根据题目的长短变化作出相应调整，以达到最好的显示效果。<br>　　当用户登陆验证成功之后，服务器会抛一个时间计数，客户端通过一个定时器，每隔1秒钟将计数减1，并显示倒计时在界面上，直到计数为0，表明考试结束，程序自动保存数据退出。这样做的好处是用户更改客户端的时间，不会影响程序的正常计时。<br>　　客户端每隔10秒钟自动保存一次数据，以防突然死机之类的情况，死机后再次登陆，程序会自动加载你先前保存的作答。但点击&#8220;提交试卷&#8221;后就无法登陆了。<br><br><img src="http://www.vckbase.com/document/image/paragraph.gif"> 对例子程序的说明<br>随付的程序和源码是我大型作业的作品，运行时先运行服务器程序，再运行服务端程序.</p>
            <p><img src="http://www.cppblog.com/images/cppblog_com/yaoming/production1.jpg" border=0>&nbsp;&nbsp;<img src="http://www.cppblog.com/images/cppblog_com/yaoming/sever.jpg" border=0><br><br><br>帐号:姚明<br>密码:1981922<br><br>运行之前请先调整数据库的试卷信息表的开考时间和结束时间。还要确保学生试卷成绩表里面&#8220;姚明&#8221;那一行中试卷状态为1。<br><br><img src="http://www.vckbase.com/document/image/paragraph.gif">　作者信息<br>姚明/Ym<br>邮箱:yaomingmail@sina.com<br>QQ:31547735<br>另外我不会打篮球 :-)<br><br>[代码性质] VC完整应用程序代码<br>[代码作者] 姚明/Ym<br>[文件大小] 162K <br>[更新日期] 2004-1-17 19:43:00 <br>[下载次数] 13112 <a href="http://www.vckbase.com/code/downcode.asp?id=2228" target=_blank><img height=9 alt=下载 src="http://www.vckbase.com/code/image/down.gif" width=61 border=0></a><br><br>（END）<br></p>
            </td>
        </tr>
    </tbody>
</table>
<img src ="http://www.cppblog.com/yaoming/aggbug/35185.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/yaoming/" target="_blank">姚明</a> 2007-10-26 00:43 <a href="http://www.cppblog.com/yaoming/archive/2007/10/26/35185.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>