Visible Surface Determination

Slides:



Advertisements
Similar presentations
Computer Graphics - Rasterization -
Advertisements

Visible-Surface Detection(identification)
Collisions and Intersections When objects move, test for collision. When projecting surfaces, check for intersections. (Many slides adapted from Amitabh.
Computer Graphics Inf4/MSc Computer Graphics Lecture 9 Visible Surface Determination.
03/12/02 (c) 2002 University of Wisconsin, CS559 Last Time Some Visibility (Hidden Surface Removal) algorithms –Painter’s Draw in some order Things drawn.
David Luebke5/11/2015 CS 551 / 645: Introductory Computer Graphics David Luebke
Occlusion Culling Fall 2003 Ref: GamasutraGamasutra.
Lecture Fall 2001 Visibility Back-Face Culling Painter’s Algorithm.
CAP4730: Computational Structures in Computer Graphics Visible Surface Determination.
Hidden Surface Removal Why make the effort?  Realistic models.  Wasted time drawing. OpenGL and HSR  OpenGL does handle HSR using the depth buffer.
Visibility in Computer Graphics Toni Sellarès Unversitat de Girona
Part I: Basics of Computer Graphics
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.
Vertices and Fragments I CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
Hidden Line Removal Adopted from U Strathclyde’s course page.
A lion in the desert How do you find a lion in the desert? How about when you have a predicate that tells you if the lion is in front or behind a separating.
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.
1 Clipping and Hidden Surfaces CS-184: Computer Graphics Prof. James O’Brien.
Visible-surface Detection Computer Graphics Seminar MUM
A lion in the desert How do you find a lion in the desert? How about when you have a predicate that tells you if the lion is in front or behind a separating.
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.
Hidden Surface Removal
Graphics Pipeline Hidden Surfaces CMSC 435/634. Visibility We can convert simple primitives to pixels Which primitives (or parts of primitives) should.
Graphics Pipeline Hidden Surface CMSC 435/634. Visibility We can convert simple primitives to pixels/fragments How do we know which primitives (or which.
10/29/02 (c) 2002 University of Wisconsin, CS559 Today Hidden Surface Removal Exact Visibility.
10/09/2001CS 638, Fall 2001 Today Spatial Data Structures –Why care? –Octrees/Quadtrees –Kd-trees.
CS 325 Introduction to Computer Graphics 03 / 08 / 2010 Instructor: Michael Eckmann.
CSC418 Computer Graphics n BSP tree n Z-Buffer n A-buffer n Scanline.
The BSP-tree from Prof. Seth MIT.. Motivation for BSP Trees: The Visibility Problem We have a set of objects (either 2d or 3d) in space. We have.
Visible-Surface Detection Jehee Lee Seoul National University.
Hidden Surface Removal 1.  Suppose that we have the polyhedron which has 3 totally visible surfaces, 4 totally invisible/hidden surfaces, and 1 partially.
CS-378: Game Technology Lecture #2.2: Clipping and Hidden Surfaces Prof. Okan Arikan University of Texas, Austin Thanks to James O’Brien, Steve Chenney,
3/23/04© University of Wisconsin, CS559 Spring 2004 Last Time Antialiasing –Area-weighted sampling Visibility –Painters algorithm –Depth buffer (Z-buffer)
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.
Chris Mayer & Nic Shulver Hidden Surface Wire frame drawings Wire frame drawings are quick to produce but are often confusing It is difficult to determine.
CS 325 Introduction to Computer Graphics 03 / 22 / 2010 Instructor: Michael Eckmann.
Binary Space Partitioning Trees Ray Casting Depth Buffering
CS 376 Introduction to Computer Graphics 03 / 21 / 2007 Instructor: Michael Eckmann.
Hidden Surface Removal
Implementation II.
1 3D Hidden Surface Removal 김 성 남. 2 Contents Goal Motivation Approaches - back face detection - depth buffer - A-buffer - Scan line - Depth.
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Visible Surface Determination (VSD) To render or not to render, that is the question… 1 of.
Where We Stand At this point we know how to: –Convert points from local to window coordinates –Clip polygons and lines to the view volume –Determine which.
Presented by: Bhavna Agarwal. Given a bunch of 3D objects predefined in x,y,z; order them in geometry.
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.
Visible surface determination. Problem outline Given a set of 3D objects and a viewing specification, we wish to determine which lines or surfaces are.
COMPUTER GRAPHICS CS 482 – FALL 2015 NOVEMBER 10, 2015 VISIBILITY CULLING HIDDEN SURFACES ANTIALIASING HALFTONING.
Visible-Surface Detection Methods. To identify those parts of a scene that are visible from a chosen viewing position. Surfaces which are obscured by.
Hidden Surface Removal. 2 Goal: Determine which surfaces are visible and which are not. Z-Buffer is just one of many hidden surface removal algorithms.
Lecture 30: Visible Surface Detection
Visible Surface Detection
Computer Graphics Implementation II
Solid Area Scan Conversion or Visible Surface Detection
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
CSCE 441: Computer Graphics Hidden Surface Removal (Cont.)
Introduction to Computer Graphics with WebGL
Implementation II Ed Angel Professor Emeritus of Computer Science
Presentation transcript:

Visible Surface Determination CS32310 H Holstein Oct 2012

Visible Surface Determination Hidden surface removal Why? Occlusion from view point General approach Depth sort

Sorting can be carried out in image precision - that is, a decision is made at each pixel, at screen resolution, asto which surface the pixel represents, and thus, how it is to be rendered. object precision - that is, decisions are based on the geometry of the objects, irrespective of screen resolution, but dependent (in practice) of the available floating point precision. a mixture of object precision (eliminate certain surfaces from consideration) and image precision (resolve the remaining conflicts at the pixel level).

If variable resolution is required (zooming), then image precision methods have to be reworked entirely, while object precision methods (using sorting independently of image resolution) can use their previous results, and need only render on the finer (or coarser) pixel grid.

Complexity If a scene has n surfaces, we might expect an object precision algorithm to take O(n2) time, since every surfaces may have to be tested against every other surface for visibility. On the other hand, if the are N pixels, we might expect an image precision algorithm to take O(nN) time, since every pixel may have to be tested for the visibility in n surfaces. Since the number of pixels N usually greatly exceeds the number of surfaces, the number of decisions to be made is much fewer in the object precision case.

Complexity continued Different algorithms try to reduce these basic counts. Thus, one can consider bounding volumes (or “extents”) to determine roughly whether objects cannot overlap – this reduces the sorting time. With a good sorting algorithm, O(n2) may be reducible to a more manageable O(n log n). Concepts such as depth coherence (the depth of a point on a surface may be predicable from the depth known at a nearby point) can cut down the number of arithmetic steps to be performed.

z-Buffer approach Image precision algorithms may benefit from hardware acceleration. The z-buffer algorithm requires a depth buffer (z-buffer) d[x][y] to record the nearest the rendering of the nearest point encountered so far, to by placed at pixel (x,y). The algorithm relies on the fact that if a nearer object occupying (x,y) is found, then the depth buffer is overwritten with the rendering information from this nearer surface.

z-Buffer algorithm Image precision algorithms may benefit from hardware acceleration. The z-buffer algorithm requires a depth buffer (z-buffer) d[x][y] to record the nearest the rendering of the nearest point encountered so far, to by placed at pixel (x,y). The algorithm relies on the fact that if a nearer object occupying (x,y) is found, then the depth buffer is overwritten with the rendering information from this nearer surface.

for (every pixel) { // initialize the colour to the background // initialize the depth buffer to “far” for every pixel [x][y] for (each facet F){ for (each pixel (x,y) on the facet) if (depth(x,y) < buffer[x][y]){ // F is closest so far set pixel(x,y) to colour of F; d[x][y] = depth(x,y); }

z-Buffer: pros & cons Advantages Disadvantages Very general - deals with intersecting surfaces of arbitrary shape can benefit from depth coherence allows incremental building up of picture in any order can be implemented in hardware Disadvantages Large amount of memory needed (for depths) Brute force Same pixel may be rendered many times

Warnock’s algorithm Based on quadrant subdivision a divide and conquer strategy. If a region is “simple”, render it, otherwise subdivide into four parts. Decision strategies as to whether a region is “simple” are crucial to efficiency. Subdivisions can proceed to pixel level. trade-off between the complexity of testing each facet and doing further subdivision.

colour = proc(F) if (size < 1) return ; // nothing to draw if (size == 1) draw closest pixel; else if isSimple(F) colour(F); else { colour(NW); //recursivecalls colour(NE); colour(SW); colour(SE);}

Warnock’s alg.: pros & cons Of historical interest! Advantage Simple to implement Disadvantages Enforces a seemingly haphazard rendering order (unimportant if results are assembled in a buffer) Scanline coherence difficult to apply Subdivisions may be forced to pixel level

Only some subdivisions are shown. The intersection between the pyramid and block can be solved either geometrically, or by subdivision until a solution becomes feasible.

Painter’s algorithm As each facet is painted into the frame buffer, its colour paints over whatever was drawn there before, just as a painter covers old layers of paint with new ones. Thus, the colour shown at a pixel is the most recently drawn colour. (i) depth-sort the facets (ii) paint entire facets, in order, from the farthest to the closest.

Painter’s algorithm The algorithm works in this simple form only if the surfaces have disjoint depth extents. When the extents overlap, it may be possible to partition the surfaces into disjoint extents, e.g. as is done in a BSP tree (see below). Painter’s algorithm fails: Neither surface is fully in front or behind the other.

BSP trees – binary space partition Binary tree sort Recursive Build the tree Insert nodes, in some order, in the left or right sub-tree, according to potential occlusion by root Traverse tree according to view

BSP trees – binary space partition This algorithm uses the concept of “facet plane” associated with each facet of every solid object in the scene. A facet plane is an infinite plane containing a planar facet of a solid object, It partitions the space into regions “in front of” and “to the back of” the facet plane. “In front of” is determined by the outward facet normal.

BSP trees – append new node Insert a node for facet CD, when CD is in the front half-space of the root facet AB. AB AB Sub-tree root CD Append on the right A Back half-space Inside of AB D B C Front half-space Outside of AB Normal (outward)

BSP trees – append new node Insert a node for facet CD, when CD is in the back half-space of the root facet AB. AB AB AB Sub-tree root D C CD Append on the left A Back half-space Inside of AB B Front half-space Outside of AB Normal (outward)

BSP trees – append new node Insert nodes for facet CD, when CD is cut by the plane of the root facet. AB AB AB Sub-tree root CE ED D Append sub-facets on the left and right E C A Back half-space Inside of AB B Front half-space Outside of AB Normal (outward)

B A C Plane B of facet A cuts facet C. Need to calculate the partitions of C. B A C

BSP trees – Build Tree Example

BSP trees – Build Tree Example Tree construction Start with an arbitrary facet (1), and put into the root. Facet 1 divides the space into “front” and “back”, according to the outward normal. Facet 2 lies behind 1, insert 2 to the left of 1. Facet 3 lies behind 1, (go left); behind 2, insert left of 2. Facet 4 lies bh 1, (left); bh 2, (left); bh 3, insert left of 3 Facet 5 lies bh 1; bh 2; in front 3, insert right of 3 Facet 6 lies bh 1; bh 2; in fr 3; bh 5, insert left of 5

BSP trees – Build Tree Example Insertion of facet 7 Facet 7 lies bh 1; bh 2; to the left of 1. Facet 7 lies both behind 3 and in front of 3, so split 7 into 7a In front of 3) and 7b (behind 3). Insert both portions, starting at node 3. Facet 7a lies in fr 3 (right); bh 5, (left); bh 6, insert left of 6 Facet 7b lies bh 3; bh 4; insert left of 4

BSP trees – Build Tree Example Insertion of facet 8 Facet 8 lies bh 1; bh 2; to the left of 1. Facet 8 lies both behind 3 and in front of 3, so split 8 into 8a (In front of 3) and 8b (behind 3). Insert both portions, starting at node 3. Facet 8a lies in fr 3; bh 5, (left); bh 6; bh 7a, insert left of 7a Facet 8b lies bh 3; bh 4; bh 7b, insert left of 7b

Tree build - Comments Build the BSP tree in this way Possibly for several objects The tree is view-independent, Depends only on the way each facet partitions the space into two halves Shape of tree affected by order of facet node insertion This may affect facet sub-partitioning Does not affect the semantics

Tree Traversal View dependent For each facet, there is a viewing vector Possibly constant, as in parallel projection Possibly position vector dependent, as in perspective projection For each facet, the outward normal is required View direction and normal determine whether the facet is forward or back facing to the viewer Traversal influenced at each facet node by forward/back facing property to viewer

BSP trees – traversal: root front facing CD could obscure something on the plane through AB or behind it: first render AB (root) and then CD X A B Normal (outward) Viewing point C D Root AB CD 29

BSP trees – traversal: root front facing Something on the plane through AB could obscure EF: E first render EF and then AB (root) A Root B AB Normal (outward) X Viewing point EF

BSP trees – traversal: root front facing 1 E 1. First render EF (behind root) 2. then AB (root) 3. then CD (front of root) Left sub-tree A A D Root 2 C B 3 Normal (outward) Right sub-tree X Viewing point

BSP trees – traversal: root front facing When the root is seen as forward facing(+), carry out a Left-Root-Right recursive traversal Render the left sub-tree, then the root, then the right sub-tree 2+ 1 3 behind root In front of root

BSP trees – traversal: root front facing When the root is seen as forward facing(+), carry out a Left-Root-Right recursive traversal Render the left sub-tree, then the root, then the right sub-tree 2+ 1 3 behind root In front of root

BSP trees – traversal: root back facing 1 E 1. First render EF (front of root) 2. then AB (root) 3. then CD Right sub-tree Normal (back facing) A A D Root 2 C B 3 Left sub-tree X Viewing point

BSP trees – traversal: back facing When the root is seen as back facing(-), carry out a Right-Root-Left recursive traversal Traversal is ‘in-order’, so take action (render, as required) on second encountering with the root. 2- 3 1 behind root In front of root

BSP trees – traversal: back facing When the root is seen as back facing(-), carry out a Right-Root-Left recursive traversal Traversal is ‘in-order’, so take action (render, as required) on second encountering with the root. 2- 3 1 behind root In front of root

BSP trees – node splitting Traversal will not encounter cases in which a facet is neither totally in front or behind the root facet, because of prior node splitting. AB AB AB Sub-tree root CE ED D Previously append sub-facets on the left and right E C A Back half-space B Front half-space Normal (outward)

BSP trees – traversal

BSP tree example – traversal Traversal convention L: Left link, R: Right link

BSP tree example – traversal Traversal convention L: Left link, R: Right link

BSP tree example – traversal Traversal convention L: Left link, R: Right link Traversal sequence (by rows): 1R -1 1L 2L 3L 4R -4 4L 7bL 8bR -8b 8bL +7b 7bR +3 3R -5R -5 6L 7aL 8aR -8a 8aL +7a 7aR +6 6R +2 2R exit

BSP tree example – traversal The facets in this sequence are: -1, -4, -8b, +7b, +3, -5, -8a, +7a, +6, +2 Of these, only the ‘+’ facets are forward facing, so the final rendering sequence is +7b, +3, +7a, +6, +2 Traversal sequence (by rows): 1R -1 1L 2L 3L 4R -4 4L 7bL 8bR -8b 8bL +7b 7bR +3 3R -5R -5 6L 7aL 8aR -8a 8aL +7a 7aR +6 6R +2 2R exit

BSP tree example – traversal Of these, only the ‘+’ facets are forward facing, so the final rendering sequence is +7b, +3, +7a, +6, +2

BSP tree example – traversal Of these, only the ‘+’ facets are forward facing, so the final rendering sequence is +7b, +3, +7a, +6, +2

BSP tree example – traversal Of these, only the ‘+’ facets are forward facing, so the final rendering sequence is +7b, +3, +7a, +6, +2

BSP tree example – traversal Of these, only the ‘+’ facets are forward facing, so the final rendering sequence is +7b, +3, +7a, +6, +2

BSP tree example – traversal Of these, only the ‘+’ facets are forward facing, so the final rendering sequence is +7b, +3, +7a, +6, +2

BSP tree example – traversal Of these, only the ‘+’ facets are forward facing, so the final rendering sequence is +7b, +3, +7a, +6, +2

Backface culling This was considered in the lecture notes on projections Easy to apply Object precision method – can sometimes be used with other algorithms to reduce the facet candidates that need to be considered for visible surface determination (e.g. z-buffer). An integral part of the BSP-tree method.

Backface culling – a comment In perspective view, different parts of a plane would have different viewing directions

Backface culling – a comment Does it matter which viewing direction v is used in computing the sign of v.n? v1 v v2 n X Viewing point

Backface culling – a comment Does it matter which viewing direction v is used in computing the sign of v.n? v1 v2 n X Viewing point

Backface culling – a comment Does it matter which viewing direction v is used in computing the sign of v.n? Consider v2.n - v1.n = (v2 – v1).n v1 v2 n X Viewing point

Backface culling – a comment Does it matter which viewing direction v is used in computing the sign of v.n? Consider v2.n - v1.n = (v2 – v1).n (v2 – v1) v1 v2 n X Viewing point

Backface culling – a comment Does it matter which viewing direction v is used in computing the sign of v.n? Consider v2.n - v1.n = (v2 – v1).n (v2 – v1), perpendicular to n v1 v2 n X Viewing point

Backface culling – a comment Does it matter which viewing direction v is used in computing the sign of v.n? Consider v2.n - v1.n = (v2 – v1).n = 0 (v2 – v1), perpendicular to n v1 v2 n X Viewing point

Backface culling – a comment Does it matter which viewing direction v is used in computing the sign of v.n? Consider v2.n - v1.n = (v2 – v1).n = 0 So v2.n = v1.n Ingore this (v2 – v1), perpendicular to n v1 v2 n X Viewing point

Backface culling – a comment Does it matter which viewing direction v is used in computing the sign of v.n? NO! A position vector v to an arbitrary point on the plane will do (e.g. any vertex position vector). v n X Viewing point

END