CSCE 441: Computer Graphics Hidden Surface Removal (Cont.)OutlineReview: Backface CullingReview: Painter’s ExampleReview: Painter’s AlgorithmReview: Building a BSP TreeRendering with a BSP TreeDifferent View Points?Slide 9Slide 10Slide 11Slide 12Slide 13Slide 14Slide 15Slide 16Slide 17Slide 18Slide 19Slide 20Slide 21Slide 22Slide 23Slide 24Slide 25Slide 26Slide 27Slide 28Slide 29Slide 30Slide 31Slide 32Slide 33Summary: BSP TreesSlide 35Slide 36Depth (“Z”) BufferZ-Buffering ExampleHow to Calculate “z”?Slide 40Slide 41Slide 42Slide 43Slide 44Slide 45Slide 46Slide 47Slide 48Scan Line AlgorithmSlide 50Slide 51Slide 52Slide 53Slide 54Slide 55Slide 56Slide 57Slide 58Slide 59Slide 60Ray CastingSlide 62Slide 63Slide 64Slide 65Hidden Surface removal: openglZ-buffer: openglSummary1CSCE 441: Computer Graphics Hidden Surface Removal (Cont.)Jinxiang Chai2OutlineBackface CullingPainter’s algorithmBSPZ-bufferScan lineRay castingReading: section 9-1 to 9-11, 9-14,9-153Review: Backface Cullingview directionnv0vn, draw polygon4Review: Painter’s Examplez = 0.7z = 0.3z = 0.1Sort by depth:Green rectRed circleBlue triz = 05Review: Painter’s Algorithm1. Sort all objects’ zmin and zmax2. If an object is uninterrupted (its zmin and zmax are adjacent in the sorted list), it is fine3. If 2 objects DO overlap 3.1 Check if they overlap in x - If not, they are fine 3.2 Check if they overlap in y - If not, they are fine - If yes, need to split one65-227-2Review: Building a BSP Tree1 23465-137-14617-27-15-25-1bbbbb fff7Rendering with a BSP TreeHow to traverse the treeDraw “back” polygonsDraw “on” polygonsDraw “front” polygons17-1bf3f4f5-227-25-16bbbb85-227-21Different View Points?1 23465-137-14617-27-15-25-1bbbbb fffDo we need to build a new tree? V095-227-21Different View Points?1 23465-137-14617-27-15-25-1bbbbb fffDo we need to build a new tree? - No, we use the same tree if objects are static105-227-21Different View Points?1 23465-137-14617-27-15-25-1bbbbb fffDo we need to build a new tree? - No, we use the same tree if objects are staticHow can we traverse the tree? V011Rendering with a BSP TreeIf eye is in front of planeDraw “back” polygonsDraw “on” polygonsDraw “front” polygonsIf eye is behind planeDraw “front” polygonsDraw “on” polygonsDraw “back” polygonsElse eye is on planeDraw “front” polygonsDraw “back” polygons1234 567+-6,75bf1,2,3,4V0Vnew12Rendering with a BSP TreeIf eye is in front of planeDraw “back” polygonsDraw “on” polygonsDraw “front” polygonsIf eye is behind planeDraw “front” polygonsDraw “on” polygonsDraw “back” polygonsElse eye is on planeDraw “front” polygonsDraw “back” polygons1234 567+-6,75bf1,2,3,4V0Vnew13Rendering with a BSP TreeIf eye is in front of planeDraw “back” polygonsDraw “on” polygonsDraw “front” polygonsIf eye is behind planeDraw “front” polygonsDraw “on” polygonsDraw “back” polygonsElse eye is on planeDraw “front” polygonsDraw “back” polygons1234 567+-6,75bf1,2,3,4VnewV0141Different View Points?1 23467-27-15-25-1Traversal order:7-1bf3f4f5-227-25-16bbbb+-V0Vnew1151Different View Points?1 23467-27-15-25-1Traversal order:17-1bf3f4f5-227-25-16bbbbV0Vnew1161Different View Points?1 23467-27-15-25-1Traversal order:17-1bf3f4f5-227-25-16bbbb+-V0Vnew1171Different View Points?1 23467-27-15-25-1Traversal order:17-1bf3f4f5-227-25-16bbbb+-V0Vnew1181Different View Points?1 23467-27-15-25-1Traversal order:1->27-1bf3f4f5-227-25-16bbbb+-V0Vnew1191Different View Points?1 23467-27-15-25-1Traversal order:1->2->(7-1)7-1bf3f4f5-227-25-16bbbb+-V0Vnew1201Different View Points?1 23467-27-15-25-1Traversal order:1->2->(7-1)->47-1bf3f4f5-227-25-16bbbb+-V0Vnew1211Different View Points?1 23467-27-15-25-1Traversal order:1->2->(7-1)->4->(5-1)7-1bf3f4f5-227-25-16bbbb+-V0Vnew1221Different View Points?1 23467-27-15-25-1Traversal order:1->2->(7-1)->4->(5-1)->37-1bf3f4f5-227-25-16bbbbV0Vnew1231Different View Points?1 23467-27-15-25-1Traversal order:1->2->(7-1)->4->(5-1)->3->(7-2)->(5-2)->67-1bf3f4f5-227-25-16bbbbV0Vnew1245-227-2Rendering with a BSP Tree1 23465-137-14617-27-15-25-1Traversal order?bbb fffbb255-227-2Rendering with a BSP Tree1 23465-137-14617-27-15-25-1Traversal order?bbb fffbb+-Traversal order?1265-227-2Rendering with a BSP Tree1 23465-137-14617-27-15-25-1Traversal order?bbb fffbb+-Traversal order?1->?275-227-2Rendering with a BSP Tree1 23465-137-14617-27-15-25-1Traversal order?bbb fffbbTraversal order?1->?+-285-227-2Rendering with a BSP Tree1 23465-137-14617-27-15-25-1Traversal order?bbb fffbbTraversal order?1->?+-295-227-2Rendering with a BSP Tree1 23465-137-14617-27-15-25-1Traversal order?bbb fffbbTraversal order?1->?+-305-227-2Rendering with a BSP Tree1 23465-137-14617-27-15-25-1Traversal order?bbb fffbbTraversal order?1->6+-315-227-2Rendering with a BSP Tree1 23465-137-14617-27-15-25-1Traversal order?bbb fffbbTraversal order?1->6->?325-227-2Rendering with a BSP Tree1 23465-137-14617-27-15-25-1Traversal order?1->6->5-2bbb fffbb335-227-2Rendering with a BSP Tree1 23465-137-14617-27-15-25-1Traversal order?1->6->(5-2)->(7-2)->3->4->(5-1)->(7-1)->2bbb fffbb34Summary: BSP TreesPros:Simple, elegant schemeNo depth comparisons neededPolygons split and ordered automaticallyWorks for moving camerasOnly writes to framebuffer (i.e., painters algorithm)35Summary: BSP TreesCons:Computationally intense preprocess stage restricts algorithm to static scenesSplitting increases polygon count Redraws same pixel many timesChoosing splitting plane not an exact scienceNot suitable for moving objects36OutlineBackface CullingPainter’s algorithmBSPZ-bufferScan lineRay castingReading: section 9-1 to 9-11, 9-14,9-1537Depth (“Z”) BufferSimple modification to scan-conversionMaintain a separate buffer storing the closest “z” value for each pixel—depth bufferOnly draw pixel if depth value is closer than stored “z” valueUpdate buffer with closest depth value38Z-Buffering Examplez = 0.7z = 0.3z = 0.1z = 1.0z = 1.0z = 0.3z = 1.0z = 0.3z = 0.1z = 1.0z = 0.7z = 0.3z = 0.1NOTE: Can draw these shapes in any orderNOTE: Can draw these shapes in any order39How to Calculate “z”?Update “z” values using scan line conversion algorithm),(11
View Full Document