大三05计算机图形学tracing_第1页
大三05计算机图形学tracing_第2页
大三05计算机图形学tracing_第3页
大三05计算机图形学tracing_第4页
大三05计算机图形学tracing_第5页
已阅读5页,还剩23页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、Ray Tracing1Angel: Interactive Computer Graphics 5E Addison-Wesley 2009原著Ed AngelProfessor of Computer Science, Electrical and Computer Engineering, and Media ArtsUniversity of New Mexico编辑 武汉大学计算机学院图形学课程组2Angel: Interactive Computer Graphics 5E Addison-Wesley 2009IntroductionOpenGL is based on a pi

2、peline model in which primitives are rendered one at timeNo shadows (except by tricks or multiple renderings)No multiple reflectionsGlobal approachesRendering equationRay tracingRadiosity3Angel: Interactive Computer Graphics 5E Addison-Wesley 2009Ray TracingFollow rays of light from a point sourceCa

3、n account for reflection and transmission4Angel: Interactive Computer Graphics 5E Addison-Wesley 2009ComputationShould be able to handle all physical interactionsRay tracing paradigm is not computationalMost rays do not affect what we seeScattering produces many (infinite) additional raysAlternative

4、: ray casting5Angel: Interactive Computer Graphics 5E Addison-Wesley 2009Ray CastingOnly rays that reach the eye matterReverse direction and cast raysNeed at least one ray per pixel6Angel: Interactive Computer Graphics 5E Addison-Wesley 2009Ray Casting QuadricsRay casting has e the standard way to v

5、isualize quadrics which are implicit surfaces in CSG systemsConstructive Solid GeometryPrimitives are solidsBuild objects with set operationsUnion, intersection, set difference7Angel: Interactive Computer Graphics 5E Addison-Wesley 2009Ray Casting a SphereRay is parametricSphere is quadricResulting

6、equation is a scalar quadratic equation which gives entry and exit points of ray (or no solution if ray misses)8Angel: Interactive Computer Graphics 5E Addison-Wesley 2009Shadow RaysEven if a point is visible, it will not be lit unless we can see a light source from that pointCast shadow or feeler r

7、ays9Angel: Interactive Computer Graphics 5E Addison-Wesley 2009ReflectionMust follow shadow rays off reflecting or transmitting surfacesProcess is recursive10Angel: Interactive Computer Graphics 5E Addison-Wesley 2009Reflection and Transmission11Angel: Interactive Computer Graphics 5E Addison-Wesley

8、 2009Ray Trees12Angel: Interactive Computer Graphics 5E Addison-Wesley 2009Ray Tree13Angel: Interactive Computer Graphics 5E Addison-Wesley 2009Diffuse SurfacesTheoretically the scattering at each point of intersection generates an infinite number of new rays that should be tracedIn practice, we onl

9、y trace the transmitted and reflected rays but use the Phong model to compute shade at point of intersectionRadiosity works best for perfectly diffuse (Lambertian) surfaces14Angel: Interactive Computer Graphics 5E Addison-Wesley 2009Building a Ray TracerBest expressed recursivelyCan remove recursion

10、 laterImage based approachFor each ray .Find intersection with closest surfaceNeed whole object database availableComplexity of calculation limits object typesCompute lighting at surfaceTrace reflected and transmitted rays15Angel: Interactive Computer Graphics 5E Addison-Wesley 2009When to stopSome

11、light will be absorbed at each intersectionTrack amount leftIgnore rays that go off to infinityPut large sphere around problemCount steps16Angel: Interactive Computer Graphics 5E Addison-Wesley 2009Recursive Ray Tracercolor c = trace(point p, vector d, int step) color local, reflected, transmitted;

12、point q; normal n; if(step max) return(background_color);17Angel: Interactive Computer Graphics 5E Addison-Wesley 2009Recursive Ray Tracerq = intersect(p, d, status);if(status=light_source) return(light_source_color);if(status=no_intersection) return(background_color);n = normal(q);r = reflect(q, n)

13、;t = transmit(q,n);18Angel: Interactive Computer Graphics 5E Addison-Wesley 2009Recursive Ray Tracerlocal = phong(q, n, r);reflected = trace(q, r, step+1);transmitted = trace(q,t, step+1);return(local+reflected+transmitted);19Angel: Interactive Computer Graphics 5E Addison-Wesley 2009Computing Inter

14、sectionsImplicit ObjectsQuadricsPlanesPolyhedraParametric Surfaces20Angel: Interactive Computer Graphics 5E Addison-Wesley 2009Implicit SurfacesRay from p0 in direction d p(t) = p0 +t dGeneral implicit surfacef(p) = 0Solve scalar equation f(p(t) = 0General case requires numerical methods21Angel: Int

15、eractive Computer Graphics 5E Addison-Wesley 2009QuadricsGeneral quadric can be written aspTAp + bTp +c = 0Substitute equation of ray p(t) = p0 +t dto get quadratic equation22Angel: Interactive Computer Graphics 5E Addison-Wesley 2009Sphere(p pc) (p pc) r2 = 0p(t) = p0 +t dp0 p0 t2+ 2 p0 (d p0) t +

16、(d p0) (d p0) r2 = 023Angel: Interactive Computer Graphics 5E Addison-Wesley 2009Planesp n + c = 0p(t) = p0 +t dt = -(p0 n + c)/ d n 24Angel: Interactive Computer Graphics 5E Addison-Wesley 2009PolyhedraGenerally we want to intersect with closed objects such as polygons and polyhedra rather than pla

17、nesHence we have to worry about inside/outside testingFor convex objects such as polyhedra there are some fast tests25Angel: Interactive Computer Graphics 5E Addison-Wesley 2009Ray Tracing PolyhedraIf ray enters an object, it must enter a front facing polygon and leave a back facing polygonPolyhedron is formed by intersection of planesRay enters at furthest intersection with front facing planesRay leaves at closest intersection with back facing planesIf entry is further away than ex

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论