Introduction to Computer Graphics Farhana Bandukwala, Phd Lecture 17: Hidden Surface Removal – Object Space Algorithms Outline
Total Page:16
File Type:pdf, Size:1020Kb
Introduction to Computer Graphics Farhana Bandukwala, PhD Lecture 17: Hidden surface removal – Object Space Algorithms Outline • BSP Trees • Octrees BSP Trees · Binary space partitioning trees · Steps: 1. Group scene objects into clusters (clusters of polygons) 2. Find plane, if possible that wholly separates clusters 3. Clusters on same side of plane as viewpoint can obscure clusters on other side 4. Each cluster can be recursively subdivided P1 P1 back A front D P2 P2 3 1 front back front back P2 B D C A B C 3,1,2 3,2,1 1,2,3 2,1,3 2 BSP Trees,contd · Suppose the tree was built with polygons: 1. Pick 1 polygon (arbitrary) as root 2. Its plane is used to partition space into front/back 3. All intersecting polygons are split into two 4. Recursively pick polygons from sub-spaces to partition space further 5. Algorithm terminates when each node has 1 polygon only P1 P1 back P6 front P3 P2 back front back P5 P2 P4 P3 P4 P6 P5 BSP Trees,contd · Traverse tree in order: 1. Start from root node 2. If view point in front: a) Draw polygons in back branch b) Then root polygon c) Then polygons in front branch 3. If view point in back: a) Draw polygons in front branch b) Then root polygon c) Then polygons in back branch 4. Recursively perform front/back test and traverse child nodes P1 P1 back P6 front P3 P2 back front back P5 P2 P4 P3 P4 P6 P5 Octrees · Consider splitting volume into 8 octants · Build tree containing polygons in each octant · If an octant has more than minimum number of polygons, split again 4 5 4 5 4 5 1 0 5 0 0 1 5 5 0 1 1 1 7 0 1 0 2 3 5 7 7 3 3 2 3 2 3 Octrees, contd · Best suited for orthographic projection · Display polygons in octant farthest from viewer first · Then those nodes that share a border with this octant · Recursively display neighboring octant · Last display closest octant Octree, example y 2 4 Viewpoint 8 11 6 12 114 12 14 9 6 10 13 1 5 3 5 x z Octants labeled in the order drawn given the viewpoint shown here.