Slide 1OverviewRasterizationRay TracingRasterization vs. Ray TracingRay TracingRay Tracing algorithmsOverviewRay/Object intersectionRay/Object intersectionExample: Ray/Sphere IntersectionExample: Ray/Sphere IntersectionRay/sphere intersectionOverviewRecursive ray tracing: shadowsRecursive Ray Tracing: ReflectionRecursive Ray Tracing: RefractionWhere’s the recursion?Recursive Ray Tracing: ExampleRecursive Ray Tracing: ExampleComputing ray colorsComputing reflection raysComputing refraction raysOverviewDistributed ray tracingDistributed Ray TracingArea shadows with DRTArea shadows with DRTOther effectsStochastic samplingConclusionRay TracingChristian LauterbachCOMP 770, 2/11/2009OverviewRay Tracing vs. rasterizationRay/Object intersection algorithmsRay Tracing methodsRecursive ray tracingDistributed ray tracingRasterizationViewerScreenRay TracingViewerScreenRasterization vs. Ray TracingRasterizationFor each primitive:For each pixel:Is Pixel in Primitive? Yes: Test depth / write colorRay TracingFor each pixel: generate rayFor each primitive:Does ray hit primitive?Yes: Test depth / write colorRay Tracing“Tracing a ray” = find first hit with scene objectNaïve:Test against all scene objectsLike testing all pixels in rasterization!In reality:Acceleration structure gives quick estimate of potentially visible objects for ray(topic of 2nd lection on RT)Ray Tracing algorithmsSo what’s the big deal?Ray Tracing far more flexible paradigmNot limited to primary visibility!Recursive (Whitted) ray tracing:Reflections, Refractions, ShadowsDistributed ray tracing...and many more applicationsOverviewRay Tracing vs. rasterizationRay/Object intersection algorithmsRay Tracing methodsRecursive ray tracingDistributed ray tracingRay/Object intersectionCan intersect ray with many objectsTriangles, PlanesSpheres, Cylinders, ConesBoxes (axis-aligned or otherwise)General polyhedra and many moreEven procedural/implicit objects!Constructive solid geometry (CSG)Implicit surfaces / equationsRay/Object intersectionRay:Origin xDirection dRay formula:x + t*dt > 0xdExample: Ray/Sphere IntersectionSphere equation:(p – S)2 – r2 = 0So let’s plug in ray equation!((x + t*d)– S)2 – r2 = 0Simplify a bit, let v = (x – S)(t*d + v)2 – r2 = 0Expand:t2d2 + 2dvt + v2 - r2 = 0SrExample: Ray/Sphere IntersectionFrom last slide:t2d2 + 2dvt + v2 - r2 = 0Quadratic equation of t of formAt2 + Bt + C = 0Easy to solvet1,2 = -B ± sqrt[ ¼B2 – C ]Two real solutions: why?SrRay/sphere intersectionThis is only one possible algorithmMany more optimized versions existE.g. early exits or less branchesSometimes best intersection algorithm is hardware specific, tooOne solution: auto-tuningOverviewRay Tracing vs. rasterizationRay/Object intersection algorithmsRay Tracing methodsRecursive ray tracingDistributed ray tracingRecursive ray tracing: shadowsViewerLightShadow rayIf first hit of shadow ray closer than distance to light in shadowRecursive Ray Tracing: ReflectionViewerLightReflection rayRecursive Ray Tracing: RefractionViewerLightRefraction rayWhere’s the recursion?ViewerLightReflection rayReflection ray Refraction rayRecursive Ray Tracing: Example(from [Whitted80])Recursive Ray Tracing: ExampleComputing ray colorsHow to get the final pixel color?Every material has local color cDefine reflexivity, refraction factors ρ(i.e. between 1.0 (mirror) and 0.0 (no reflection)Each hit returns its color down the chainEnd result:Color = (1 –ρ) c1 + ρ1 ( (1- ρ2)c2 + ρ2 (c3 …. )))Local color also influenced by shadow rays!Computing reflection raysReflection is pretty simpleIncident angle = Exit angleIncident ray: x + t*d Reflection ray: a + t*(d – 2*n*dot(n,d))(careful, assumes n and d normalized!) naComputing refraction raysRefraction occurs at material boundariesE.g. air-glassDepends on refractive index n of materialsSnell’s law: n 1 * sin(θ1) = n2 * sin(θ2)Special case:total internal reflectiondenser to less dense materialθ > critical anglen1n2θ1θ2OverviewRay Tracing vs. rasterizationRay/Object intersection algorithmsRay Tracing methodsRecursive ray tracingDistributed ray tracingDistributed ray tracingRay Tracing: too idealistic!No point light sources in natureNo perfect reflections etc.Distributed ray tracing ideaSubstitute exact single rays with several probabilistically generated raysDistributed Ray TracingAllows many physically correct effects:Soft area shadowsGlossy, imperfect reflections and refractionsDepth of FieldMotion blur(from [Boulos07])Area shadows with DRTViewerLightShadow rayArea shadows with DRTViewerArea lightn shadow rays for randomly selected points on light Lighting now determined by #rays reach light / #rays shotOther effectsReflections, Refraction similarE.g. sample rays inside cone defined by directionDepth of fieldSample different viewer positions on lensMotion blurSample different time pointsAll work together!Stochastic samplingOne new disadvantage: sampling needs to be high, or artifacts visibleManifests as high-frequency noiseGood sample generation is art in itselfMuch, much slower than simple ray tracing(from [Boulos07])ConclusionRay Tracing advantagesReflections, refraction, shadowsRendering of arbitrary objectsDoes not even need explicit representationUsed for global illumination, many othersDisadvantagesUsually much slower(no hardware acceleration,
View Full Document