Introduction to Computer Graphics Hidden Surface Removal Rama

  • Slides: 13
Download presentation
Introduction to Computer Graphics: Hidden Surface Removal Rama C. Hoetzlein, 2011 Cornell University Lecture

Introduction to Computer Graphics: Hidden Surface Removal Rama C. Hoetzlein, 2011 Cornell University Lecture Notes

Hidden Surface Removal Depth Sorting Given a collection of polygons: What order do we

Hidden Surface Removal Depth Sorting Given a collection of polygons: What order do we draw them in?

Hidden Surface Removal • Object-space approach: use pairwise testing between polygons (objects) partially obscuring

Hidden Surface Removal • Object-space approach: use pairwise testing between polygons (objects) partially obscuring can draw independently • Worst case complexity O(n 2) for n polygons Angel: Interactive Computer Graphics 5 E © Addison-Wesley 2009 3

Painter’s Algorithm • Render polygons in back to front order so that polygons behind

Painter’s Algorithm • Render polygons in back to front order so that polygons behind others are simply painted over B behind A as seen by viewer Angel: Interactive Computer Graphics 5 E © Addison-Wesley 2009 Fill B then A 5

Depth Sorting • Requires ordering of polygons first – O(n log n) calculation for

Depth Sorting • Requires ordering of polygons first – O(n log n) calculation for ordering – Not every polygon is either in front or behind all other polygons • Order polygons and deal with easy cases first, harder later Polygons sorted by distance from COP Angel: Interactive Computer Graphics 5 E © Addison-Wesley 2009 6

Depth Sorting - Hard Cases cyclic overlap Easy cases – One polygon is completely

Depth Sorting - Hard Cases cyclic overlap Easy cases – One polygon is completely behind the other. Just “paint” over it. penetration Angel: Interactive Computer Graphics 5 E © Addison-Wesley 2009 7

Scan-Line Algorithm • Can combine shading and hsr through scan line algorithm scan line

Scan-Line Algorithm • Can combine shading and hsr through scan line algorithm scan line i: no need for depth information, can only be in no or one polygon scan line j: need depth information only when in more than one polygon Angel: Interactive Computer Graphics 5 E © Addison-Wesley 2009 9

Z-Buffer Algorithm • As we render each polygon, compare the depth of each pixel

Z-Buffer Algorithm • As we render each polygon, compare the depth of each pixel to depth in z buffer • If less, place shade of pixel in color buffer and update z buffer Angel: Interactive Computer Graphics 5 E © Addison-Wesley 2009 11

Hidden Surfaces vs. Object Culling Hidden Surface Removal Goal: Render polygons in correct order.

Hidden Surfaces vs. Object Culling Hidden Surface Removal Goal: Render polygons in correct order. 1. Depth Sorting 2. Painter’s Algorithm 3. Scan Line Algorithm 4. Z-Buffer Object Culling 1. Bounding Boxes 2. Binary Space Trees Goal: Avoid rendering non-visible objects.