MIT EECS 6.837, Teller and Durand1MIT EECS 6.837Frédo Durand and Seth TellerSome slides courtesy of Leonard McMillanRay TracingMIT EECS 6.837, Teller and Durand2Administrative• Assignment 4– Due Friday 11 at 5pm– Polygon rasterization– Phong highlight• Office hour this week– Teller & Durand 4-035 Thursday from 4 to 6– Ngan 4 to 7 Thursday W20–Friday • Durand 9-10 in NE43-254• Ngan 11-12 NE43-256• Teller 2:30-3:30 NE43-252MIT EECS 6.837, Teller and Durand3Today: Ray Tracing• And review of Ray Casting with slides with time!Image by Turner WhittedMIT EECS 6.837, Teller and Durand4Today: Ray TracingImages and animation byHenrik WannJensenMIT EECS 6.837, Teller and Durand5References• Shirley Chapter 9• Other specialized books:• Online resourceshttp://www.irtc.org/http://www.acm.org/tog/resources/RTNews/html/http://www.povray.org/http://www.siggraph.org/education/materials/HyperGraph/raytrace/rtrace0.htmhttp://www.siggraph.org/education/materials/HyperGraph/raytrace/rt_java/raytrace.htmlMIT EECS 6.837, Teller and Durand6Overview• Ray casting• Transformations• Ray-Primitive intersection• Advanced ray casting• Ray TracingMIT EECS 6.837, Teller and Durand7Scan Conversion and Visibility• Hidden surfaces eliminated at each pixel– z buffering– Scanline algorithms– Shading computed many times at each pixel– Each pixel stores only constant stateMIT EECS 6.837, Teller and Durand8Limitations of Scan Conversion• Restricted to scan-convertableprimitives– Object polygonalization • Faceting, shading artifacts• Effective resolution hardware dependent (aliasing)• No handling of shadows, reflection, transparency• Problem of overdraw (high depth complexity)• What if there are more triangles than pixels?MIT EECS 6.837, Teller and Durand9Graphics Pipeline Review• Primitives are processed one at a time• All analytic processing early on• Sampling occurs late• Minimal state required (immediate mode rendering)• Processing is forward-mappingMIT EECS 6.837, Teller and Durand10Ray Casting Outline• For every pixel construct a ray from the eye • For every object in the scene– Find closest intersection with the ray – Compute normal at point of intersection• Compute color for pixel (e.g. Phong)MIT EECS 6.837, Teller and Durand11Ray CastingObject Cast ( Point R, Ray D ) {find minimum t>0 such that R + t D hits objectif ( object hit )return objectelse return background object}MIT EECS 6.837, Teller and Durand12Ray CastingFrameBuffer Render ( frustum, viewport ) {For each raster yFor each pixel xD = ray from eye through pixel x, yobj = Cast ( eye, D );FrameBuffer[x,y] = obj->color}MIT EECS 6.837, Teller and Durand13Ray Casting for Visibility• Advantages?– Smooth variation of normal, silhouettes– Generality: can render anything with which a ray can be intersected !– Compactness of representation– Atomic operationMIT EECS 6.837, Teller and Durand14Ray Casting for Visibility• Disadvantages?– Time complexity (N objects, R pixels)–?– Wasted work at “background" pixels– Why aren't ray casters usually found in hardware?MIT EECS 6.837, Teller and Durand15Ray Casting vs. Scan conversion• Ray casting:– More and more used in production • Final Fantasy, The Cell, Fight Club, The City of Lost Children– Some hardware is appearing– Volume Rendering• Scan conversion– Graphics card– Pixar Renderman• Toy Story, Monsters, Jurassic Park, Most of Final FantasyMIT EECS 6.837, Teller and Durand16Durer’s Ray casting machine• Albrecht Durer, 16thcenturyMIT EECS 6.837, Teller and Durand17Durer’s Ray casting machine• Albrecht Durer, 16thcenturyMIT EECS 6.837, Teller and Durand18Durer’s Ray casting machine• Albrecht Durer, 16thcenturyMIT EECS 6.837, Teller and Durand19Questions?• Image by Henrik Wann Jensen using Ray Casting (and some other advanced techniques)MIT EECS 6.837, Teller and Durand20Overview• Ray casting• Transformations• Ray-Primitive intersection• Advanced ray casting• Ray TracingMIT EECS 6.837, Teller and Durand21First Step - From Pixels to RaysMIT EECS 6.837, Teller and Durand22Ray-Scene Intersection• Given a ray, & a scene of transformed primitives– Determine:• Closest ray-primitive intersection P, if any• Primitive's surface normal N at point P•Compute t for each intersection, and retain tminMIT EECS 6.837, Teller and Durand23Ray-Primitive Intersection• First concentrate on individual primitives• Ray is typically generated in world space• Primitives defined in object space, then transformed• What are our options?MMIT EECS 6.837, Teller and Durand24Opt 1: Intersection in World Space• Transform primitive into world space– Reexpress it there, then perform intersectionMMIT EECS 6.837, Teller and Durand25Opt 1: Intersection in World Space• Option 1: transform primitive into world space– Reexpress it there, then perform intersection• Polygon: vertices p as Mp, plane H as HM-1– Polyhedra: collections of polygonsMRDMIT EECS 6.837, Teller and Durand26Opt 1: Intersection in World Space• Option 1: transform primitive into world space• Polygon: vertices as Mp, plane as HM-1• Quadrics Q: transform as MQM-1– But: quadric class is not invariant !• Torii, spline surfaces, other primitives: harder.MMIT EECS 6.837, Teller and Durand27Opt 1: Intersection in World Space• Option 1: transform primitive into world space• Requires one transformation rule for each class of object• Any better idea?MMIT EECS 6.837, Teller and Durand28Opt 2: Intersection in Object Space• Transform ray into object space!– Intersections straightforward, even trivial there• How do we transform the ray's origin and direction?M-1MIT EECS 6.837, Teller and Durand29Opt 2: Intersection in Object Space• Transform ray origin into object space–R’ = M-1R• How do we transform the ray's direction?M-1RDWorldObjectMIT EECS 6.837, Teller and Durand30Ray Transformation• How do we transform the ray's direction?– NOT as D’ = M-1DM-1RDWorldObjectMIT EECS 6.837, Teller and Durand31Direction vector transformation• “Endpoints" of ray have equal translations• Equivalently: ray is a pure direction• So: transform both ends, subtract resultsM-1RDWorldObjectMIT EECS 6.837, Teller and Durand32Direction vector transformation• Equivalent to ignoring translation part of M• Instead, use• Again: can treat direction (a; b; c) as homogeneous (a; b; c; 0)• Inventor supplies this
View Full Document