University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Hidden Surfaces II Week.

Slides:



Advertisements
Similar presentations
Visible-Surface Detection(identification)
Advertisements

CSC418 Computer Graphics n Polygon normals n Back Faces n Visibility Algorithms.
CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
Graphics Pipeline.
David Luebke5/11/2015 CS 551 / 645: Introductory Computer Graphics David Luebke
Lecture Fall 2001 Visibility Back-Face Culling Painter’s Algorithm.
CS 551 / 645: Introductory Computer Graphics Visible Surface Determination.
CAP4730: Computational Structures in Computer Graphics Visible Surface Determination.
Visibility in Computer Graphics Toni Sellarès Unversitat de Girona
Computer Graphics Visible Surface Determination. Goal of Visible Surface Determination To draw only the surfaces (triangles) that are visible, given a.
Graphics Graphics Korea University cgvr.korea.ac.kr 1 Hidden Surface Removal 고려대학교 컴퓨터 그래픽스 연구실.
CS 445 / 645: Introductory Computer Graphics
UBI 516 Advanced Computer Graphics
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Clipping Week 8, Wed Mar.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Clipping II, Hidden Surfaces.
University of British Columbia CPSC 314 Computer Graphics May-June 2005 Tamara Munzner Scientific Visualization,
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Interpolation Clipping.
Chapter 6: Vertices to Fragments Part 2 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley Mohan Sridharan Based on Slides.
1 Dr. Scott Schaefer Hidden Surfaces. 2/62 Hidden Surfaces.
CS 4731: Computer Graphics Lecture 18: Hidden Surface Removal Emmanuel Agu.
CGDD 4003 THE MASSIVE FIELD OF COMPUTER GRAPHICS.
Hidden Surface Elimination Wen-Chieh (Steve) Lin Institute of Multimedia Engineering I-Chen Lin’ CG Slides, Rich Riesenfeld’s CG Slides, Shirley, Fundamentals.
1 CSCE 441: Computer Graphics Hidden Surface Removal (Cont.) Jinxiang Chai.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Visibility II Week 7,
University of British Columbia CPSC 314 Computer Graphics May-June 2005 Tamara Munzner Sampling, Virtual Trackball,
Vertices and Fragments III Mohan Sridharan Based on slides created by Edward Angel 1 CS4395: Computer Graphics.
Spatial Data Structure: Quadtree, Octree,and BSP tree Mengxia Zhu Fall 2007.
Part I: Basics of Computer Graphics Rendering Polygonal Objects (Read Chapter 1 of Advanced Animation and Rendering Techniques) Chapter
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Visibility Week 9, Fri 31 Oct 2003.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Visibility Week 7, Wed.
University of British Columbia CPSC 414 Computer Graphics © Tamara Munzner 1 Visibility: Z Buffering Week 10, Mon 3 Nov 2003.
Introduction to 3D Graphics John E. Laird. Basic Issues u Given a internal model of a 3D world, with textures and light sources how do you project it.
Hidden Surface Removal
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2010 Tamara Munzner Hidden Surfaces III Week.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2010 Tamara Munzner Clipping II, Hidden Surfaces.
Visible-Surface Detection Jehee Lee Seoul National University.
1Computer Graphics Implementation II Lecture 16 John Shearer Culture Lab – space 2
Implementation II Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Binary Space Partitioning Trees Ray Casting Depth Buffering
Hidden Surface Removal
Implementation II.
1 Visiblity: Culling and Clipping Computer Graphics COMP 770 (236) Spring 2009 January 21 & 26: 2009.
David Luebke11/26/2015 CS 551 / 645: Introductory Computer Graphics David Luebke
Computer Graphics Zhen Jiang West Chester University.
David Luebke 1 12/8/2015 Visibility CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Visible Surface Determination (VSD) To render or not to render, that is the question… 1 of.
Computer Graphics I, Fall 2010 Implementation II.
1 CSCE 441: Computer Graphics Hidden Surface Removal Jinxiang Chai.
01/28/09Dinesh Manocha, COMP770 Visibility Computations Visible Surface Determination Visibility Culling.
Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 5 Hidden Surface Removal and Rasterization Taku Komura.
Hidden Surfaces University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2013 Tamara Munzner.
Computer Graphics One of the central components of three-dimensional graphics has been a basic system that renders objects represented by a set of polygons.
Hidden Surfaces / Depth Test University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2016 Tamara Munzner.
CS 445 / 645 Introduction to Computer Graphics Lecture 21 Visibility Visibility.
Visible Surface Detection
Computer Graphics Implementation II
Visibility Week 9, Fri 31 Oct 2003
CSC418 Computer Graphics Back Faces Visibility Algorithms.
Hidden Surfaces Dr. Scott Schaefer.
CSCE 441: Computer Graphics Hidden Surface Removal
3D Rendering Pipeline Hidden Surface Removal 3D Primitives
Implementation II Ed Angel Professor Emeritus of Computer Science
Visibility: Z Buffering Week 10, Mon 3 Nov 2003
Hidden Surfaces II Week 9, Mon Mar 15
Hidden Surface Removal
CSCE 441: Computer Graphics Hidden Surface Removal (Cont.)
Introduction to Computer Graphics with WebGL
Clipping University of British Columbia CPSC 314 Computer Graphics
Implementation II Ed Angel Professor Emeritus of Computer Science
Presentation transcript:

University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Hidden Surfaces II Week 9, Mon Mar 12

2 Reading for This Time FCG Chap 12 Graphics Pipeline only

3 News Project 3 update Linux executable reposted template update download package again OR just change line 31 of src/main.cpp from int resolution[2]; to int resolution[] = {100,100}; OR implement resolution parsing

4 Review: Polygon Clipping not just clipping all boundary lines may have to introduce new line segments

5 Review: Sutherland-Hodgeman Clipping for each viewport edge clip the polygon against the edge equation for new vertex list after doing all edges, the polygon is fully clipped for each polygon vertex decide what to do based on 4 possibilities is vertex inside or outside? is previous vertex inside or outside?

6 Review: Sutherland-Hodgeman Clipping edge from p[i-1] to p[i] has four cases decide what to add to output vertex list insideoutside p[i] p[i] output insideoutside no output insideoutside i output insideoutside i output p[i] output p[i] p[i-1]

7 Review: Painter’s Algorithm draw objects from back to front problems: no valid visibility order for intersecting polygons cycles of non-intersecting polygons possible

8 Review: BSP Trees preprocess: create binary tree recursive spatial partition viewpoint independent

9 Review: BSP Trees runtime: correctly traversing this tree enumerates objects from back to front viewpoint dependent: check which side of plane viewpoint is on at each node draw far, draw object in question, draw near F N F N FN NF NF F N FN F N

10 Hidden Surface Removal II

11 BSP Demo useful demo:

12 Clarification: BSP Demo order of insertion can affect half-plane extent

13 Summary: BSP Trees pros: simple, elegant scheme correct version of painter’s algorithm back-to-front rendering approach was very popular for video games (but getting less so) cons: slow to construct tree: O(n log n) to split, sort splitting increases polygon count: O(n 2 ) worst-case computationally intense preprocessing stage restricts algorithm to static scenes

14 The Z-Buffer Algorithm (mid-70’s) BSP trees proposed when memory was expensive first 512x512 framebuffer was >$50,000! Ed Catmull proposed a radical new approach called z-buffering the big idea: resolve visibility independently at each pixel

15 The Z-Buffer Algorithm we know how to rasterize polygons into an image discretized into pixels:

16 The Z-Buffer Algorithm what happens if multiple primitives occupy the same pixel on the screen? which is allowed to paint the pixel?

17 The Z-Buffer Algorithm idea: retain depth after projection transform each vertex maintains z coordinate relative to eye point can do this with canonical viewing volumes

18 The Z-Buffer Algorithm augment color framebuffer with Z-buffer or depth buffer which stores Z value at each pixel at frame beginning, initialize all pixel depths to  when rasterizing, interpolate depth (Z) across polygon check Z-buffer before storing pixel color in framebuffer and storing depth in Z-buffer don’t write pixel if its Z value is more distant than the Z value already stored there

19 Interpolating Z barycentric coordinates interpolate Z like other planar parameters

20 Z-Buffer store (r,g,b,z) for each pixel typically bits, can be more for all i,j { Depth[i,j] = MAX_DEPTH Depth[i,j] = MAX_DEPTH Image[i,j] = BACKGROUND_COLOUR Image[i,j] = BACKGROUND_COLOUR} for all polygons P { for all pixels in P { for all pixels in P { if (Z_pixel < Depth[i,j]) { if (Z_pixel < Depth[i,j]) { Image[i,j] = C_pixel Image[i,j] = C_pixel Depth[i,j] = Z_pixel Depth[i,j] = Z_pixel } }}

21 Depth Test Precision reminder: projective transformation maps eye-space z to generic z-range (NDC) simple example: thus:

22 Depth Test Precision therefore, depth-buffer essentially stores 1/z, rather than z! issue with integer depth buffers high precision for near objects low precision for far objects -z eye z NDC -n-f

23 Depth Test Precision low precision can lead to depth fighting for far objects two different depths in eye space get mapped to same depth in framebuffer which object “wins” depends on drawing order and scan- conversion gets worse for larger ratios f:n rule of thumb: f:n < 1000 for 24 bit depth buffer with 16 bits cannot discern millimeter differences in objects at 1 km distance demo: sjbaker.org/steve/omniv/love_your_z_buffer.html

24 Z-Buffer Algorithm Questions how much memory does the Z-buffer use? does the image rendered depend on the drawing order? does the time to render the image depend on the drawing order? how does Z-buffer load scale with visible polygons? with framebuffer resolution?

25 Z-Buffer Pros simple!!! easy to implement in hardware hardware support in all graphics cards today polygons can be processed in arbitrary order easily handles polygon interpenetration enables deferred shading rasterize shading parameters (e.g., surface normal) and only shade final visible fragments

26 Z-Buffer Cons poor for scenes with high depth complexity need to render all polygons, even if most are invisible shared edges are handled inconsistently ordering dependent eye

27 Z-Buffer Cons requires lots of memory (e.g. 1280x1024x32 bits) requires fast memory Read-Modify-Write in inner loop hard to simulate translucent polygons we throw away color of polygons behind closest one works if polygons ordered back-to-front extra work throws away much of the speed advantage

28 Hidden Surface Removal two kinds of visibility algorithms object space methods image space methods

29 Object Space Algorithms determine visibility on object or polygon level using camera coordinates resolution independent explicitly compute visible portions of polygons early in pipeline after clipping requires depth-sorting painter’s algorithm BSP trees

30 Image Space Algorithms perform visibility test for in screen coordinates limited to resolution of display Z-buffer: check every pixel independently performed late in rendering pipeline

31 Projective Rendering Pipeline OCS - object coordinate system WCS - world coordinate system VCS - viewing coordinate system CCS - clipping coordinate system NDCS - normalized device coordinate system DCS - device coordinate system OCS WCS VCS CCS NDCS DCSmodelingtransformationviewingtransformationprojectiontransformationviewporttransformation alter w / w objectworld viewing device normalized device clipping perspectivedivision glVertex3f(x,y,z) glTranslatef(x,y,z)glRotatef(th,x,y,z)....gluLookAt(...) glFrustum(...) glutInitWindowSize(w,h)glViewport(x,y,a,b)

32 Rendering Pipeline Geometry Database Geometry Database Model/View Transform. Model/View Transform. Lighting Perspective Transform. Perspective Transform. Clipping Scan Conversion Scan Conversion Depth Test Depth Test Texturing Blending Frame- buffer Frame- buffer OCS object WCS world VCS viewing CCS clipping NDCS normalized device SCS screen (2D) DCS device (3D) (4D) /w

33 Backface Culling

34 Back-Face Culling on the surface of a closed orientable manifold, polygons whose normals point away from the camera are always occluded: note: backface culling alone doesn’t solve the hidden-surface problem!

35 Back-Face Culling not rendering backfacing polygons improves performance by how much? reduces by about half the number of polygons to be considered for each pixel optimization when appropriate

36 Back-Face Culling most objects in scene are typically “solid” rigorously: orientable closed manifolds orientable: must have two distinct sides cannot self-intersect a sphere is orientable since has two sides, 'inside' and 'outside'. a Mobius strip or a Klein bottle is not orientable closed: cannot “walk” from one side to the other sphere is closed manifold plane is not

37 Back-Face Culling Yes No most objects in scene are typically “solid” rigorously: orientable closed manifolds manifold: local neighborhood of all points isomorphic to disc boundary partitions space into interior & exterior

38 Manifold examples of manifold objects: sphere torus well-formed CAD part

39 Back-Face Culling examples of non-manifold objects: a single polygon a terrain or height field polyhedron w/ missing face anything with cracks or holes in boundary one-polygon thick lampshade

40 Back-face Culling: VCS y z first idea: cull if sometimes misses polygons that should be culled eye

41 Back-face Culling: NDCS y z eye VCS NDCS eye works to cull if y z

42 Invisible Primitives why might a polygon be invisible? polygon outside the field of view / frustum solved by clipping polygon is backfacing solved by backface culling polygon is occluded by object(s) nearer the viewpoint solved by hidden surface removal