GAMES101 Lecture 14

Transcription

Introduction to Computer GraphicsGAMES101, Lingqi Yan, UC Santa BarbaraLecture 14:Ray Tracing 2(Acceleration & Radiometry)http://www.cs.ucsb.edu/ lingqi/teaching/games101.html

Announcements Grading of resubmissions — we’re working on that GTC news: DLSS 2.0- https://zhuanlan.zhihu.com/p/116211994 GTC news: RTXGI- https://developer.nvidia.com/rtxgi Personal feeling- Offline rendering techniques will soon become real-time- Current real-time rendering techniques will still be useful Next lectures won’t be easyGAMES1012Lingqi Yan, UC Santa Barbara

Last Lecture Why ray tracing? Whitted-style ray tracing Ray-object intersections- Implicit surfaces- Triangles Axis-Aligned Bounding Boxes (AABBs)- Understanding — pairs of slabs- Ray-AABB intersectionGAMES1013Lingqi Yan, UC Santa Barbara

Today Using AABBs to accelerate ray tracing- Uniform grids- Spatial partitions Basic radiometry (辐射度量学)GAMES1014Lingqi Yan, UC Santa Barbara

Uniform Spatial Partitions (Grids)

Preprocess – Build Acceleration Grid1. Find bounding boxGAMES1016Lingqi Yan, UC Santa Barbara

Preprocess – Build Acceleration Grid1. Find bounding box2. Create gridGAMES1017Lingqi Yan, UC Santa Barbara

Preprocess – Build Acceleration Grid1. Find bounding box2. Create grid3. Store each objectin overlapping cellsGAMES1018Lingqi Yan, UC Santa Barbara

Ray-Scene IntersectionStep through grid in raytraversal orderFor each grid cellTest intersectionwith all objectsstored at that cellGAMES1019Lingqi Yan, UC Santa Barbara

Grid Resolution?One cell GAMES10110No speedupLingqi Yan, UC Santa Barbara

Grid Resolution?Too many cells GAMES10111Inefficiency dueto extraneousgrid traversalLingqi Yan, UC Santa Barbara

Grid Resolution?Heuristic: GAMES10112#cells C * #objsC 27 in 3DLingqi Yan, UC Santa Barbara

Uniform Grids – When They Work WellDeussen et al; Pharr & Humphreys, PBRTGrids work well on large collections of objectsthat are distributed evenly in size and spaceGAMES10113Lingqi Yan, UC Santa Barbara

Uniform Grids – When They FailJun Yan, Tracy Renderer“Teapot in a stadium” problemGAMES10114Lingqi Yan, UC Santa Barbara

Spatial Partitions

Spatial Partitioning ExamplesOct-TreeKD-TreeBSP-TreeNote: you could have these in both 2D and 3D. In lecture we will illustrate principles in 2D.GAMES10116Lingqi Yan, UC Santa Barbara

KD-Tree Pre-ProcessingAAGAMES10117Lingqi Yan, UC Santa Barbara

KD-Tree Pre-ProcessingABBAGAMES10118Lingqi Yan, UC Santa Barbara

KD-Tree Pre-ProcessingA21C1BB2D4D34535Note: also subdividenodes 1 and 2, etc.AGAMES101C19Lingqi Yan, UC Santa Barbara

Data Structure for KD-TreesInternal nodes store split axis: x-, y-, or z-axissplit position: coordinate of split plane along axischildren: pointers to child nodesNo objects are stored in internal nodesLeaf nodes store GAMES101list of objects20Lingqi Yan, UC Santa Barbara

Traversing a KD-TreeA1CBB2CDD435AGAMES10121Lingqi Yan, UC Santa Barbara

Traversing a KD-TreetminA1CB2BCDDtmax5Internal node: splitAGAMES1014322Lingqi Yan, UC Santa Barbara

Traversing a KD-TreetmintmaxA1CBB2CDD45Assume it’s leaf node:intersect all objectsAGAMES101323Lingqi Yan, UC Santa Barbara

Traversing a KD-TreetminA1CB2BCDDtmax5Internal node: splitAGAMES1014324Lingqi Yan, UC Santa Barbara

Traversing a KD-TreetminA1C tmaxBB2CDD45Leaf node: intersectall objectsAGAMES101325Lingqi Yan, UC Santa Barbara

Traversing a KD-TreeA1C tminB2BCDDtmax5Internal node: splitAGAMES1014326Lingqi Yan, UC Santa Barbara

Traversing a KD-TreeA1CCDDtmax435Leaf node: intersectall objectsAGAMES1012BtminB27Lingqi Yan, UC Santa Barbara

Traversing a KD-TreeA1CthitD2CD435Intersection foundAGAMES101BB28Lingqi Yan, UC Santa Barbara

Object Partitions &Bounding Volume Hierarchy (BVH)

Bounding Volume Hierarchy (BVH)RootGAMES10130Lingqi Yan, UC Santa Barbara

Bounding Volume Hierarchy (BVH)GAMES10131Lingqi Yan, UC Santa Barbara

Bounding Volume Hierarchy (BVH)GAMES10132Lingqi Yan, UC Santa Barbara

Bounding Volume Hierarchy (BVH)ACBCDGAMES101BDA33Lingqi Yan, UC Santa Barbara

Summary: Building BVHsGAMES10134 Find bounding box Recompute the boundingbox of the subsets Stop when necessaryRecursively split set ofobjects in two subsetsStore objects in each leafnodeLingqi Yan, UC Santa Barbara

Building BVHsHow to subdivide a node? Choose a dimension to splitHeuristic #1: Always choose the longest axis in nodeHeuristic #2: Split node at location of median objectTermination criteria? GAMES101Heuristic: stop when node contains few elements(e.g. 5)35Lingqi Yan, UC Santa Barbara

Data Structure for BVHsInternal nodes store Bounding boxChildren: pointers to child nodesLeaf nodes store Bounding boxList of objectsNodes represent subset of primitives in scene GAMES101All objects in subtree36Lingqi Yan, UC Santa Barbara

BVH TraversalIntersect(Ray ray, BVH node) {if (ray misses node.bbox) return;nodeif (node is a leaf node)test intersection with all objs;return closest intersection;hit1 Intersect(ray, node.child1);hit2 Intersect(ray, node.child2);child1child2return the closer of hit1, hit2;}GAMES10137Lingqi Yan, UC Santa Barbara

Spatial vs Object PartitionsSpatial partition (e.g.KD-tree) Partition space intonon-overlapping regions An object can be containedin multiple regionsObject partition (e.g. BVH) Partition set of objects intodisjoint subsets Bounding boxes for each setmay overlap in spaceGAMES10138Lingqi Yan, UC Santa Barbara

Today Using AABBs to accelerate ray tracing- Uniform grids- Spatial partitions Basic radiometry (辐射度量学)- Advertisement: new topics from now on,scarcely covered in other graphics coursesGAMES10139Lingqi Yan, UC Santa Barbara

Radiometry — MotivationObservation In assignment 3, we implement the Blinn-Phong modelLight intensity I is 10, for exampleBut 10 what?Do you think Whitted style ray tracing gives you CORRECT results?All the answers can be found in radiometry GAMES101Also the basics of “Path Tracing”40Lingqi Yan, UC Santa Barbara

RadiometryMeasurement system and units for illuminationAccurately measure the spatial properties of light-New terms: Radiant flux, intensity, irradiance, radiancePerform lighting calculations in a physically correct �——————————My personal way of learning things:GAMES101WHY, WHAT, then HOW41Lingqi Yan, UC Santa Barbara

Radiant Energy and Flux (Power)

Radiant Energy and Flux (Power)Definition: Radiant energy is the energy of electromagneticradiation. It is measured in units of joules, and denoted bythe symbol:Q [J Joule]Definition: Radiant flux (power) is the energy emitted,reflected, transmitted or received, per unit time.dQ [W Watt] [lm lumen]*dtGAMES10143Lingqi Yan, UC Santa Barbara

Flux – #photons flowing through a sensor in unit timeFrom London and UptonGAMES10144Lingqi Yan, UC Santa Barbara

Important Light Measurements of InterestGAMES101Light EmittedFrom A SourceLight FallingOn A SurfaceLight TravelingAlong A Ray“Radiant Intensity”“Irradiance”“Radiance”45Lingqi Yan, UC Santa Barbara

Radiant Intensity

Radiant IntensityDefinition: The radiant (luminous) intensity is the power per unitsolid angle (?) emitted by a point light source.( 体 ) dI(!) d!dI(!) d! Wsr Wsr lm csrlm cd candelasrThe candela is one of the seven SI base units.GAMES10147Lingqi Yan, UC Santa Barbara

Angles and Solid AnglesAngle: ratio of subtended arc lengthon circle to radiusl r Circle has 2 radiansSolid angle: ratio of subtended area onsphere to radius squaredA r2 Sphere has 4 GAMES101l l r rAl r2rsteradians48Lingqi Yan, UC Santa Barbara

Differential Solid AnglesdA (r d )(r sin d ) r2 sin d ddAd! 2 sin d drGAMES10149Lingqi Yan, UC Santa Barbara

Differential Solid AnglesZ2Sphere:S d!2SZZ ZZ 2 d! sin d dS 22S0 Z0ZZ ZZ 2 Z 12 2 sin d d sin d d cos dd00Z 111Z 4 4 4 GAMES101501100Z0 2 Z 00cos ddddcosLingqi Yan, UC Santa Barbara

! as a direction vectorWill use ! to denote adirection vector (unit length)!GAMES10151Lingqi Yan, UC Santa Barbara

Isotropic Point Source ZI d!S2 4 II GAMES101524 Lingqi Yan, UC Santa Barbara

Modern LED LightOutput: 815 lumens(11W LED replacementfor 60W incandescent)Radiant intensity?Assume isotropic:Intensity 815 lumens / 4pi sr 65 candelasGAMES10153Lingqi Yan, UC Santa Barbara

Thank you!(And thank Prof. Ravi Ramamoorthi and Prof. Ren Ng for many of the slides!)

Radiant Energy and Flux (Power) Definition: Radiant energy is the energy of electromagnetic radiation. It is measured in units of joules, and denoted by the symbol: Definition: Radiant flux (power) is the energy emitted, refle