3/23/04© University of Wisconsin, CS559 Spring 2004 Last Time Antialiasing –Area-weighted sampling Visibility –Painters algorithm –Depth buffer (Z-buffer)

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.
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
CAP4730: Computational Structures in Computer Graphics Visible Surface Determination.
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
Introduction to 3D Graphics Lecture 5: From Realism to Real-Time Anthony Steed University College London.
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.
1 CSCE 441: Computer Graphics Hidden Surface Removal (Cont.) Jinxiang Chai.
1 Clipping and Hidden Surfaces CS-184: Computer Graphics Prof. James O’Brien.
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.
CSE 872 Dr. Charles B. Owen Advanced Computer Graphics1 Other Rendering Techniques Types of rendering – Wireframe techniques – Scan-line conversion – Reyes.
10/11/2001CS 638, Fall 2001 Today Kd-trees BSP Trees.
10/02/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Octrees.
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.
09/18/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Bump Mapping Multi-pass algorithms.
9/20/2001CS 638, Fall 2001 Today Finishing Up Reflections More Multi-Pass Algorithms Shadows.
Hidden Surface Removal
Visible Surface Determination
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.
Technology and Historical Overview. Introduction to 3d Computer Graphics  3D computer graphics is the science, study, and method of projecting a mathematical.
10/09/2001CS 638, Fall 2001 Today Spatial Data Structures –Why care? –Octrees/Quadtrees –Kd-trees.
Modeling of worlds A complicated object be decomposed into simple objects and represented by hierarchical model A world scene usually contain many objects.
3/4/04© University of Wisconsin, CS559 Spring 2004 Last Time Clipping Lines –Cohen-Sutherland: The use of outcodes and early reject/accept tests –Liang-Barsky:
02/26/02 (c) 2002 University of Wisconsin, CS 559 Last Time Canonical view pipeline Orthographic projection –There was an error in the matrix for taking.
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.
10/26/04© University of Wisconsin, CS559 Fall 2004 Last Time Drawing lines Polygon fill rules Midterm Oct 28.
Visible-Surface Detection Jehee Lee Seoul National University.
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,
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.
CS 325 Introduction to Computer Graphics 03 / 22 / 2010 Instructor: Michael Eckmann.
Implementation II.
David Luebke11/26/2015 CS 551 / 645: Introductory Computer Graphics David Luebke
11/04/04© University of Wisconsin, CS559 Fall 2004 Last Time Visibility –Z-Buffer and transparency –A-buffer –Area subdivision –BSP Trees –Exact Cell-Portal.
1 3D Hidden Surface Removal 김 성 남. 2 Contents Goal Motivation Approaches - back face detection - depth buffer - A-buffer - Scan line - Depth.
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.
Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 5 Hidden Surface Removal and Rasterization Taku Komura.
CS 325 Introduction to Computer Graphics 04 / 07 / 2010 Instructor: Michael Eckmann.
Visible-Surface Detection Methods. To identify those parts of a scene that are visible from a chosen viewing position. Surfaces which are obscured by.
Lecture 30: Visible Surface Detection
Computer Graphics Implementation II
© University of Wisconsin, CS559 Spring 2004
(c) 2002 University of Wisconsin, CS559
Solid Area Scan Conversion or Visible Surface Detection
BSP Trees Binary space partitioning trees.
© University of Wisconsin, CS559 Fall 2004
© University of Wisconsin, CS559 Spring 2004
Graphics Pipeline Hidden Surfaces
CSCE 441: Computer Graphics Hidden Surface Removal
3D Rendering Pipeline Hidden Surface Removal 3D Primitives
Last Time Clipping Homework 4, due Nov 2 in class
© University of Wisconsin, CS559 Fall 2004
Hidden Surface Removal
Presentation transcript:

3/23/04© University of Wisconsin, CS559 Spring 2004 Last Time Antialiasing –Area-weighted sampling Visibility –Painters algorithm –Depth buffer (Z-buffer) –A-buffer –Scanline visibility –Depth Sorting

3/23/04© University of Wisconsin, CS559 Spring 2004 Today Visibility –Area subdivision –BSP Trees –Cell-Portal Project 2 is available, due Friday April 9 No lecture Tuesday March 30

3/23/04© University of Wisconsin, CS559 Spring 2004 Visibility Recap You are given a bunch of polygons do draw and you need to figure out which one is visible at every pixel Issues include: –Efficiency – it is slow to overwrite pixels, or scan convert things that cannot be seen –Accuracy – answer should be right, and behave well when the viewpoint moves –Complexity – object precision visibility may generate many small pieces of polygon

3/23/04© University of Wisconsin, CS559 Spring 2004 Area Subdivision Exploits area coherence: Small areas of an image are likely to be covered by only one polygon –The practical truth of this assertion varies over the years (it’s currently going from mostly false to more true) Three easy cases for determining what’s in front in a given region: 1.a polygon is completely in front of everything else in that region 2.no surfaces project to the region 3.only one surface is completely inside the region, overlaps the region, or surrounds the region

3/23/04© University of Wisconsin, CS559 Spring 2004 Warnock’s Area Subdivision (Image Precision) Start with whole image If one of the easy cases is satisfied (previous slide), draw what’s in front Otherwise, subdivide the region and recurse If region is single pixel, choose surface with smallest depth Advantages: –No over-rendering –Anti-aliases well - just recurse deeper to get sub-pixel information Disadvantage: –Tests are quite complex and slow

3/23/04© University of Wisconsin, CS559 Spring 2004 Warnock’s Algorithm Regions labeled with case used to classify them: 1)One polygon in front 2)Empty 3)One polygon inside, surrounding or intersecting Small regions not labeled Note it’s a rendering algorithm and a HSR algorithm at the same time –Assuming you can draw squares

3/23/04© University of Wisconsin, CS559 Spring 2004 BSP-Trees (Object Precision) Construct a binary space partition tree –Tree gives a rendering order –A list-priority algorithm Tree splits 3D world with planes –The world is broken into convex cells –Each cell is the intersection of all the half-spaces of splitting planes on tree path to the cell Also used to model the shape of objects, and in other visibility algorithms –BSP visibility in games does not necessarily refer to this algorithm

3/23/04© University of Wisconsin, CS559 Spring 2004 BSP-Tree Example A C B A B C

3/23/04© University of Wisconsin, CS559 Spring 2004 Building BSP-Trees Choose polygon (arbitrary) Split its cell using plane on which polygon lies –May have to chop polygons in two (Clipping!) Continue until each cell contains only one polygon fragment Splitting planes could be chosen in other ways, but there is no efficient optimal algorithm for building BSP trees –Optimal means minimum number of polygon fragments in a balanced tree

3/23/04© University of Wisconsin, CS559 Spring 2004 Building Example We will build a BSP tree, in 2D, for a 3 room building –Ignoring doors Splitting edge order is shown –“Back” side of edge is side with the number

3/23/04© University of Wisconsin, CS559 Spring 2004 BSP-Tree Rendering Observation: Things on the opposite side of a splitting plane from the viewpoint cannot obscure things on the same side as the viewpoint Rendering algorithm is recursive descent of the BSP Tree At each node (for back to front rendering): –Recurse down the side of the sub-tree that does not contain the viewpoint Test viewpoint against the split plane to decide which tree –Draw the polygon in the splitting plane Paint over whatever has already been drawn –Recurse down the side of the tree containing the viewpoint

3/23/04© University of Wisconsin, CS559 Spring 2004 Using a BSP-Tree Observation: Things on the opposite side of a splitting plane from the viewpoint cannot obscure things on the same side as the viewpoint A statement about rays – a ray must hit something on this side of the split plane before it hits the split plane and before it hits anything on the back side NOT a statement about distance – things on the far side of the plane can be closer than things on the near side Split plane

3/23/04© University of Wisconsin, CS559 Spring 2004 BSP-Tree Rendering Example A C B A B C st View 2nd3rd4th

3/23/04© University of Wisconsin, CS559 Spring 2004 BSP-Tree Rendering (2) Advantages: –One tree works for any viewing point –Filter anti-aliasing and transparency work Have back to front ordering for compositing –Can also render front to back, and avoid drawing back polygons that cannot contribute to the view Uses two trees – an extra one that subdivides the window Disadvantages: –Can be many small pieces of polygon –Over-rendering

3/23/04© University of Wisconsin, CS559 Spring 2004 Exact Visibility An exact visibility algorithm tells you what is visible and only what is visible –No over-rendering –Warnock’s algorithm is an example Difficult to achieve efficiently in practice –Small detail objects in an environment make it particularly difficult But, in mazes and other simple environments, exact visibility is extremely efficient

3/23/04© University of Wisconsin, CS559 Spring 2004 Cells and Portals Assume the world can be broken into cells –Simple shapes –Rooms in a building, for instance Define portals to be the transparent boundaries between cells –Doorways between rooms, windows, etc In a world like this, can determine exactly which parts of which rooms are visible –Then render visible rooms plus contents

3/23/04© University of Wisconsin, CS559 Spring 2004 Cell and Portal Visibility Start in the cell containing the viewer, with the full viewing frustum Render the walls of that room and its contents Recursively clip the viewing frustum to each portal out of the cell, and call the algorithm on the cell beyond the portal

3/23/04© University of Wisconsin, CS559 Spring 2004 Cell-Portal Example (1) View

3/23/04© University of Wisconsin, CS559 Spring 2004 Cell-Portal Example (2) View

3/23/04© University of Wisconsin, CS559 Spring 2004 Cell-Portal Example (3) View

3/23/04© University of Wisconsin, CS559 Spring 2004 Cell-Portal Example (4) View

3/23/04© University of Wisconsin, CS559 Spring 2004 Cell-Portal Example (5) View

3/23/04© University of Wisconsin, CS559 Spring 2004 Cell-Portal Example (6) View

3/23/04© University of Wisconsin, CS559 Spring 2004 Cell-Portal Operations Must clip polygons to the current view frustum (not the original one) –Can be done with additional hardware clipping planes, if you have them Must clip the view frustum to the portal –Easiest to clip portal to frustum, then set frustum to exactly contain clipped portal In Project 2, you implement these things in software, for a 2.5d environment

3/23/04© University of Wisconsin, CS559 Spring 2004 Cell-Portal Properties Advantages –Extremely efficient - only looks at cells that are actually visible: visibility culling –Easy to modify for approximate visibility - render all of partially visible cells, let depth buffer clean up –Can handle mirrors as well - flip world about the mirror and pretend mirror is a portal Disadvantages –Restricted to environments with good cell/portal structure

3/23/04© University of Wisconsin, CS559 Spring 2004 Project 2 Intro You are given the following: –Rooms, defined in 2D by the edges that surround the room –The height of the ceiling –Each edge is marked opaque or clear –For each clear edge, there is a pointer to the thing on the other side You know where the viewer is and what the field of view is –The viewer is given as (c x,c y,c z ) position –The view frustum is given as a viewing angle and an angle for the field of view (c x,c y,c z ) X

3/23/04© University of Wisconsin, CS559 Spring 2004 Project 2 (2) You don’t have everything needed to do this project yet, but you can do the hardest part Represent the frustum as a left and right clipping line –You don’t have to worry about the top and bottom –Each clip line starts at the viewer’s position and goes to infinity in the viewing direction Write a procedure that clips an edge to the view frustum –This takes a frustum and returns the endpoints of the clipped edge, or a flag to indicate that the edge is not visible

3/23/04© University of Wisconsin, CS559 Spring 2004 Project 2 (3) Write a procedure that takes a room and a frustum, and draws the room –Clip each edge to the frustum –If the edge is visible, draw the wall that the edge represents Create the 3D wall from the 2d piece of edge Project the vertices Draw the polygon in 2D –If the edge is clear, recurse Draw the floor and ceiling first, because they will be behind everything

3/23/04© University of Wisconsin, CS559 Spring 2004 Where We Stand So far we know how to: –Transform between spaces –Draw polygons –Decide what’s in front Next –Deciding a pixel’s intensity and color

3/23/04© University of Wisconsin, CS559 Spring 2004 Normal Vectors The intensity of a surface depends on its orientation with respect to the light and the viewer The surface normal vector describes the orientation of the surface at a point –Mathematically: Vector that is perpendicular to the tangent plane of the surface What’s the problem with this definition? –Just “the normal vector” or “the normal” –Will use n or N to denote Normals are either supplied by the user or automatically computed

3/23/04© University of Wisconsin, CS559 Spring 2004 Transforming Normal Vectors Normal vectors are directions To transform a normal, multiply it by the inverse transpose of the transformation matrix Recall, rotation matrices are their own inverse transpose Don’t include the translation! Use (x,y,z,0) for homogeneous coordinates