1 / 17

Vertices and Fragments III

Vertices and Fragments III. Mohan Sridharan Based on slides created by Edward Angel. Objectives. This lecture: Survey hidden-surface algorithms. More about these algorithms later . Hidden Surface Removal. Object-space approach: use pair-wise testing between polygons (objects).

paxton
Download Presentation

Vertices and Fragments III

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Vertices and Fragments III Mohan Sridharan Based on slides created by Edward Angel CS4395: Computer Graphics

  2. Objectives • This lecture: • Survey hidden-surface algorithms. • More about these algorithms later  CS4395: Computer Graphics

  3. Hidden Surface Removal • Object-space approach: use pair-wise testing between polygons (objects). • Worst case complexity O(n2) for n polygons. • Best-case sorting algorithms: O(n log(n)). can draw independently partially obscuring CS4395: Computer Graphics

  4. Painter’s Algorithm • Render polygons in back to front order so that polygons behind others are simply painted over. Fill B then A B behind A as seen by viewer CS4395: Computer Graphics

  5. Depth Sort • Requires ordering of polygons first: • O(n log n) calculation for ordering. • Not every polygon is in front or behind other polygons. • Order polygons and deal with easy cases first, harder later. Polygons sorted by distance from COP CS4395: Computer Graphics

  6. Easy Cases • A lies behind all other polygons: • Can render. • Polygons overlap in z but not in either x or y: • Can render independently: CS4395: Computer Graphics

  7. Hard Cases cyclic overlap Overlap in all directions but can render because all vertices of one polygon on one side of the plane of the other polygon. penetration CS4395: Computer Graphics

  8. Back-Face Removal (Culling)  Face is visible iff 90   -90 equivalently cos   0 orv• n  0 Plane of face has form ax + by +cz +d =0 but after normalizationn = ( 0 0 1 0)T Need only test the sign of c. In OpenGL we can simply enable culling but may not work correctly if we have non-convex objects CS4395: Computer Graphics

  9. Image Space Approach • Look at each projector (nm for an nxm frame buffer) and find closest of k polygons. • Complexity O(nmk). • Ray tracing. • z-buffer. CS4395: Computer Graphics

  10. z-Buffer Algorithm • Use a buffer called the Z (or depth) buffer to store the depth of the closest object at each pixel found so far. • 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. CS4395: Computer Graphics

  11. Efficiency • If we work scan line by scan line as we move across a scan line, the depth changes satisfy ax + by + cz=0. In screen spacex = 1 Along scan line y = 0 z = - x CS4395: Computer Graphics

  12. 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. CS4395: Computer Graphics

  13. Implementation • Need a data structure to store: • Flag for each polygon (inside/outside). • Incremental structure for scan lines that stores which edges are encountered. • Parameters for planes. CS4395: Computer Graphics

  14. Visibility Testing • In many real-time applications, we want to eliminate as many objects as possible within the application: • Reduce burden on pipeline. • Reduce traffic on bus. • Partition with Binary Spatial Partition (BSP) Tree. CS4395: Computer Graphics

  15. Simple Example Consider 6 parallel polygons. top view The plane of A separates B and C from D, E and F. CS4395: Computer Graphics

  16. BSP Tree • Can continue recursively: • Plane of C separates B from A. • Plane of D separates E and F. • Can put this information in a BSP tree: • Use for visibility and occlusion testing . CS4395: Computer Graphics

  17. Summary • Looked at hidden-surface removal algorithms. • OpenGL includes Z-buffering. • Better organization of objects required to properly and efficiently render complex scenes. CS4395: Computer Graphics

More Related