mo_chardesign2/ mo_chardesign2/ New iMap

Slides:



Advertisements
Similar presentations
Visible-Surface Detection(identification)
Advertisements

CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
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
Lecture Fall 2001 Visibility Back-Face Culling Painter’s Algorithm.
Hidden Surface Removal CSE 581. Visibility Assumption: All polygons are opaque What polygons are visible with respect to your view frustum?  Outside:
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.
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.
CS 4731: Computer Graphics Lecture 18: Hidden Surface Removal Emmanuel Agu.
Tomas Mőller © 2000 Speeding up your game The scene graph Culling techniques Level-of-detail rendering (LODs) Collision detection Resources and pointers.
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.
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
10/11/2001CS 638, Fall 2001 Today Kd-trees BSP Trees.
Hidden Surface Removal
Visible Surface Determination
BSP Trees, Quadtrees & Octrees Glenn G. Chappell U. of Alaska Fairbanks CS 481/681 Lecture Notes Wednesday, January 28, 2004.
Graphics Pipeline Hidden Surfaces CMSC 435/634. Visibility We can convert simple primitives to pixels Which primitives (or parts of primitives) should.
10/29/02 (c) 2002 University of Wisconsin, CS559 Today Hidden Surface Removal Exact Visibility.
CS 450: COMPUTER GRAPHICS VISIBLE SURFACE DETECTION SPRING 2015 DR. MICHAEL J. REALE.
Modeling of worlds A complicated object be decomposed into simple objects and represented by hierarchical model A world scene usually contain many objects.
The Visibility Problem In many environments, most of the primitives (triangles) are not visible most of the time –Architectural walkthroughs, Urban environments.
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.
Using BSP for CD Ref: BSP in deBerg et al ’ s book (url)url.
Hidden Surface Removal 1.  Suppose that we have the polyhedron which has 3 totally visible surfaces, 4 totally invisible/hidden surfaces, and 1 partially.
03/14/02 (c) 2002 University of Wisconsin, CS559 Last Time Some more visibility (Hidden Surface Removal) algorithms –A-buffer –Scanline –Depth sorting.
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.
Binary Space Partitioning Trees Ray Casting Depth Buffering
Implementation II.
1 Visiblity: Culling and Clipping Computer Graphics COMP 770 (236) Spring 2009 January 21 & 26: 2009.
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.
Computer Graphics I, Fall 2010 Implementation II.
1 CSCE 441: Computer Graphics Hidden Surface Removal Jinxiang Chai.
CS559: Computer Graphics Lecture 12: Antialiasing & Visibility Li Zhang Spring 2008.
01/28/09Dinesh Manocha, COMP770 Visibility Computations Visible Surface Determination Visibility Culling.
BSP Tree Supplement Jyun-Ming Chen. Fall Kd-Tree and BSP tree kd-tree is a special kind of bsp tree.
Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 5 Hidden Surface Removal and Rasterization Taku Komura.
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.
09/23/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Reflections Shadows Part 1 Stage 1 is in.
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
Computer Graphics Implementation II
(c) 2002 University of Wisconsin, CS559
Solid Area Scan Conversion or Visible Surface Detection
Hidden Surface Removal
© University of Wisconsin, CS559 Fall 2004
Hidden Surfaces Dr. Scott Schaefer.
© University of Wisconsin, CS559 Spring 2004
CSCE 441: Computer Graphics Hidden Surface Removal
Implementation II Ed Angel Professor Emeritus of Computer Science
Lecture 13 Clipping & Scan Conversion
CSCE 441: Computer Graphics Hidden Surface Removal (Cont.)
Hidden Surface Removal
Implementation II Ed Angel Professor Emeritus of Computer Science
Presentation transcript:

mo_chardesign2/ mo_chardesign2/ New iMap

CS3241: Computer Graphics

Where are we? All the objects are set up in the scene And they are polygonal models A camera (view point) is set After all the transformations (including the perspective transformation) So we now have many many polygons on the screen Transform all the polygon vertices into the screen coordinates

Transformation/Viewing

Drawing Order? ?

But how do we know the order? Scan Convert Algorithm

Keeping the z Values After Perspective Transformation

Wrong Drawing Order

Hidden Surface Removal (HSR)

Two Main Approaches I. Control the drawing order of objects Sort the order of polygons according to “depth” Draw polygons from furthest to nearest View dependent The depth order changes when the viewpoint changes II. Draw objects in a random order Then for each pixel drawn by a new object If there is already some object drawn, decide if the new object should overwrite it or not

Various HSR Algorithms Type 1: Depth Sorting Weiler-Atherton Algorithm Binary Space-Partitioning (BSP) Tree Type 2: Z-buffer Warnock's Algorithm Ray-casting (in the lecture of ray tracing) …. etc. All of them are performed after perspective transformation Except Ray-casting

(Object-precision Algorithm)

Type 1: Controlling Drawing Order Goal: For a bunch of polygons, we sort them according to the “depth” and draw the “deepest” first However, sometime there is no possible correct order: So, we have to break the polygons

Type 1a: Depth Sort Breaking two polygons Polygon A Polygon B Determine “who” covers “who” in this area

Type 1a:Depth Sort Weiler-Atherton Algorithm Computing intersections of polygons A generic polygon clipping algorithm (detail omitted) For two polygons and B, we can compute the union of A and B the intersection of A and B A minus B B minus A

Set A and Set B Union Intersection A - B

Type 1a: Depth Sort Polygon A Polygon B

Type 1a: Depth Sort Polygon A Polygon A in B Polygon A minus B

Type 1a: Depth Sort Polygon B minus A Polygon B in A

Type 1a: Depth Sort Drawing order 1. Polygons “A – B” and “B - A” 2. Polygon “B in A” Polygon A - B Polygon B -A Polygon B in A

Type 1a: Depth Sorting Drawing order: Determine which one to draw first Polygon “A in B” or Polygon “B in A” In this case, draw “A in B” first then draw “B in A” if polygon B is transparent If B is not transparent, we can ignore or skip drawing “A in B” directly Do not need to care about “A-B” or “B-A” If they do not intersect other polygons in the screen

Type 1a: Depth Sorting Advantages Handle transparency Especially good if The order is predictable and there is no need for polygon clipping Disadvantages Need special care for penetrating polygons Computational expensive n polygons produce n C 2 intersections i.e. O(n 2 ) And for each pair of polygon, we could produce O(m 2 ) if each polygon has m edges

Type Ib: Binary Space Partitioning An industrial standard for real time 3D games such as FPS Doom, Counterstrike, Quake, etc… Input: An environment modeled by polygons Preprocess the environment and produce a BSP tree Output Base on the BSP tree, output a drawing order from the furthest away to the nearest polygon

The First FPS There are free versions on web and iPad/iPhone The iPad version is totally free on the Japanese iStore

Recap: Binary Search Tree dimensional space

Recap: Binary Search Tree dimensional space 2 sub-spaces Internal node Leaf

Type 1b: Binary Space Partitioning Idea: Subdivide the entire space by a binary tree Each internal node is a division of a partition/space Each leaf is a part of the space with only one polygon Divide into two steps I. Preparation II. Rendering A B C (Use a bird’s eye view for illustration)

Type 1b: BSP-tree Preparation Initialization Let S = the entire space Pick any polygon, say Polygon A Let H A be the hyperplane that contains A and divides S into two subspace S 1 and S 2 A B C HAHA

Type 1b: BSP-tree Build a node by polygon A Break every polygon in S by H A Build the two children of A by the two subspaces S 1 and S 2 Repeat until the subspace contains only 1 polygon A B1B1 C HAHA B2B2 A B1B1

Type 1b: BSP-tree A B1B1 HAHA B2B2 A B1B1 B2B2 C2C2 C1C1 C1C1 C2C2 Prepare the BSP-tree for rendering:

Type 1b: BSP-tree Rendering A B1B1 HAHA B2B2 A B1B1 B2B2 C2C2 C1C1 C1C1 C2C2 Depending on the viewpoint p Start from the root For each node there is one polygon and two sub-spaces in the two children 1. Recursively draw the sub-tree behind the polygon from the view point p 2. Draw the polygon of the node 3. Recursively, draw the sub-tree in front of the polygon from the view point p p = in-order traversal of a BSP tree

A B1B1 HAHA B2B2 A B1B1 B2B2 C2C2 C1C1 C1C1 C2C2 For example, for the following viewpoints, their drawing order will be p 1 : B 1, A, C 1, B 2, C 2 p 2 : C 1, B 2, C 2, A, B 1 p1p1 p2p2 Type 1b: BSP-tree Detailed exercises in tutorials

Type 1b: BSP-tree Advantage: Once the tree is computed, the tree can handle all viewpoints, i.e. efficient Handle transparency Indeed, it’s a standard format (. BSP files) to store the environment for many games E.g. Quake, Half-life, Call of Duty, etc Disadvantages Cannot handle moving/changing environments Preprocessing time is long

(Image-precision Algorithm)

Type 2a: Z-buffer Algorithm When we draw a pixel on the screen It is from a pixel by the scan conversion algorithm We may store the color onto the color buffer (memory) The choices are: To overwrite the original values already there, or Do not write anything, i.e. ignoring the current pixel The main idea of z-buffer algorithm: Allocate another buffer to store the z values of all the pixel drawn

Keeping the z Values 2 Cases: Draw blue first, then overwritten by yellow Draw yellow first, then the blue pixel is skipped when the blue polygon is drawn 2 Cases: Draw blue first, then overwritten by yellow Draw yellow first, then the blue pixel is skipped when the blue polygon is drawn After Perspective Transformation Yellow or blue?

Type 2a: Z-buffer Algorithm For every pixel of a polygon (during SCA) will (usually) have a different z values

Type 2a: Z-buffer Algorithm The main idea of z-buffer algorithm: Allocate another buffer to store the z values of all the pixel drawn, namely z-buffer E.g. a 1024 x 768 screen has a memory size of 1024 x 768 array of “double” values Before drawing, initialize every value to be infinity When we draw a pixel, we compare its z value with the one on the z-buffer If the depth is smaller, overwrite Else, do nothing, namely, do NOT draw this pixel

Initial Screen z-buffer (Let 9 be the maximum z value)

Type 2a: Z-buffer Algorithm Advantages No pre-sorting is necessary, no explicit intersection/object-object comparisons are required, i.e. Fast and simple Handles cyclic and penetrating polygons Can make use of ∆z to speed up in the incremental SCA Disadvantages Can handle only opaque objects, namely, transparency is not handled Well… can somehow fix it partially… A single point sampling process, i.e. severe aliasing. E.g. two polygons on the same plane but with different shapes “Z fighting” Problem in a sub-pixel level The z-buffer's finite precision does not provide adequate resolution for scene with small objects separated far apart (in z) and for intersections of distant objects. (i.e. 2 pts close together may become touching each other due to rounding )

Z-fighting When two polygons are contained in the same plane and overlapping with each other Theoretically, their z values are exactly the same at every pixel But, practically, numerical errors

Type 2b: Warnock's Algorithm Subdivide the screen until The area only contains one polygon, or The area is one pixel big For the one pixel big area Determine which polygon to draw by intersecting a line to all the polygons in that pixel

(Reducing the number of polygons rendered)

Speed-up Enhancements 1. Skipping (eliminating) objects outside the view frustum Many many methods… 2. Back face culling For each polygon, define one side is “outside” and the other “inside” Only draw the polygon if the “outside” face is facing the viewer Only these three polygons are actually drawn by SCA, the rest are skipped

Polygon Normal

Back face culling For each polygon, define one side is “outside” and the other “inside” Only draw the polygon if the “outside” face is facing the eye by testing if the dot product of the two vectors V and N is greater than zero V: eye position minus a point on the polygon N: normal vector of the polygon N V

Recap:Polygon Orientations For a triangle with three vertices v 1, v 2 and v 3 The order (v 1, v 3, v 2 ) and ( v 3, v 2, v 1 ) are considered to be equivalent during drawing, e.g. glVertex But the order ( v 1, v 2, v 3 ) is considered to be different (or “opposite”) (v 1, v 3, v 2 ) and ( v 3, v 2, v 1 ) describe a facing direction of a polygon/triangle Right-hand rule The order (v 1, v 2, v 3 ) creates an opposite facing direction So, geometry is the same, but normal vector for that polygon will be different Usually we follow the “natural” order in the polygon list to define the “outward” direction of an object v1v1 v2v2 v3v3

Vertex List and Polygon List For example, if it is a “solid” ball, the triangle below must be stored in the order of (v1, v3, v2) or (v3,v2,v1) or (v2,v1,v3) But NOT (v1,v2,v3) or some other orders

Back Face Culling

OpenGL Z-buffer (depth buffer) Setup: glEnable(GL_DEPTH_TEST); glDepthMask(GL_TRUE); Every time clearing the screen glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); Back face culling Setup glEnable(GL_CULL_FACE); glCullFace(GL_FRONT); or glCullFace(GL_BACK); Then draw all polygons in an anti-clockwise or a clockwise order

Outline Effect A polygonal model Draw the outline The division between polygon being “backface culled” and not culled

Conclusion This all COMPUTATIONAL GEOMETRY! Z-buffer is not superior, but most “user friendly” Most suitable for hardware implementation Other algorithms are more suitable for software implementation Performance depends on The number of polygons Size of the output Those who are interested: Quake’s HSR techniques:

Admin HW1 All marked already, just some IVLE bugs and we will upload the marks ASAP HW2 Deadline 30 th Sept (delayed) Midterm next next lecture in class 12 th Oct Start sharply at 2:00 pm 1 hour Open Book Scope: everything (lecture, tutorial, hw) before 8 Oct See IVLE lesson plan for details Make-up lecture Oct 22 nd, 23 rd or 25 th ?