CS559: Computer Graphics Lecture 12: Antialiasing & Visibility Li Zhang Spring 2008.

Slides:



Advertisements
Similar presentations
Visible-Surface Detection(identification)
Advertisements

Compositing and Blending Ed Angel Professor Emeritus of Computer Science University of New Mexico 1 E. Angel and D. Shreiner: Interactive Computer Graphics.
CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
Computer Graphics Viewing, Rendering, Antialiasing گرد آوري و تاليف: دكتر احمد رضا نقش نيل چي دانشگاه اصفهان گروه مهندسي كامپيوتر.
David Luebke1/19/99 CS 551/651: Antialiasing David Luebke
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
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.
CECS461 Computer Graphics II University of Missouri at Columbia Hidden Surface Removal.
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.
CS 551 / CS 645 Antialiasing. What is a pixel? A pixel is not… –A box –A disk –A teeny tiny little light A pixel is a point –It has no dimension –It occupies.
Compositing and Blending Mohan Sridharan Based on slides created by Edward Angel 1 CS4395: Computer Graphics.
Compositing and Blending - Chapter 8 modified by Ray Wisman Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Clipping II, Hidden Surfaces.
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.
Sampling, Aliasing, & Mipmaps
Hidden Surface Elimination Wen-Chieh (Steve) Lin Institute of Multimedia Engineering I-Chen Lin’ CG Slides, Rich Riesenfeld’s CG Slides, Shirley, Fundamentals.
Now Playing: Big Bird Eddie Floyd from The Complete Stax-Volt Singles Volume 1 ( ) Released April 30, 1991.
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.
CSE 872 Dr. Charles B. Owen Advanced Computer Graphics1 Other Rendering Techniques Types of rendering – Wireframe techniques – Scan-line conversion – Reyes.
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.
Computer Graphics Shadows
09/18/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Bump Mapping Multi-pass algorithms.
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.
Computer Graphics Mirror and Shadows
Computer Graphics Inf4/MSc Computer Graphics Lecture 9 Antialiasing, Texture Mapping.
10/29/02 (c) 2002 University of Wisconsin, CS559 Today Hidden Surface Removal Exact Visibility.
Antialiasing CAP4730: Computational Structures in Computer Graphics.
Modeling of worlds A complicated object be decomposed into simple objects and represented by hierarchical model A world scene usually contain many objects.
CS559: Computer Graphics Lecture 9: Projection Li Zhang Spring 2008.
CSC418 Computer Graphics n BSP tree n Z-Buffer n A-buffer n Scanline.
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.
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,
Real-Time rendering Chapter 4.Visual Appearance 4.4. Aliasing and antialiasing 4.5. Transparency,alpha,and compositing 4.6. Fog 4.7. Gamma correction
3/23/04© University of Wisconsin, CS559 Spring 2004 Last Time Antialiasing –Area-weighted sampling Visibility –Painters algorithm –Depth buffer (Z-buffer)
CS 325 Introduction to Computer Graphics 03 / 22 / 2010 Instructor: Michael Eckmann.
Binary Space Partitioning Trees Ray Casting Depth Buffering
CS559: Computer Graphics Lecture 9: Rasterization Li Zhang Spring 2008.
David Luebke11/26/2015 CS 551 / 645: Introductory Computer Graphics David Luebke
CS559: Computer Graphics Lecture 12: Antialiasing & Visibility Li Zhang Spring 2008.
Lecture 6 Rasterisation, Antialiasing, Texture Mapping,
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.
CS559: Computer Graphics Lecture 11: Antialiasing & Visibility, Intro to OpenGL Li Zhang Spring 2010.
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.
CS 325 Introduction to Computer Graphics 03 / 10 / 2010 Instructor: Michael Eckmann.
David Luebke 3/17/2016 Advanced Computer Graphics Antialiasing David Luebke
CS559: Computer Graphics Lecture 9: Projection Li Zhang Spring 2008.
(c) 2002 University of Wisconsin, CS559
© University of Wisconsin, CS559 Fall 2004
© University of Wisconsin, CS559 Spring 2004
Graphics Pipeline Hidden Surfaces
CSCE 441: Computer Graphics Hidden Surface Removal
Anti-aliased and accelerated ray tracing
Sweep Fill Details For row = min to row=max
(c) 2002 University of Wisconsin, CS559
Hidden Surface Removal
Presentation transcript:

CS559: Computer Graphics Lecture 12: Antialiasing & Visibility Li Zhang Spring 2008

Today Antialising Hidden Surface Removal Reading: – Shirley ch 3.7, 8 – OpenGL ch 1

Last time (x 1, y 1 ) (x 0, y 0 ) A3A3 A1A1 A2A2 P Line drawing Triangle filling

Aliasing in rendering One of the most common rendering artifacts is the “jaggies”. Consider rendering a white polygon against a black background: We would instead like to get a smoother transition:

Other types of Aliasing Image warping Motion Aliasing Aliased Anti-Aliased Original Images from answers.com If you were to only look at the clock every 50 minutes then the minute hand would appear to rotate anticlockwise. The hour hand would still rotate in the correct direction as you have satisfied nyquist. The second hand would jitter around depending on how accurate you were with your observations.

Anti-aliasing Q: How do we avoid aliasing artifacts? 1.Sampling: Increase sampling rate -- not practical for fixed resolution display. 2.Pre-filtering: Smooth out high frequences analytically. Requires an analytic function. 3.Combination: Supersample and average down. Example - polygon: Memory requirement?

Anti-aliasing Q: How do we avoid aliasing artifacts? 1.Sampling: Increase sampling rate -- not practical for fixed resolution display. 2.Pre-filtering: Smooth out high frequences analytically. Requires an analytic function.

Box filter Consider a line as having thickness (all good drawing programs do this) Consider pixels as little squares Set brightness according to the proportion of the square covered by the line 1/ /8 1/

Weighted Sampling Place the “filter” at each pixel, and integrate product of pixel and line Common filters are Gaussians

Anti-aliasing Q: How do we avoid aliasing artifacts? 1.Sampling: Increase sampling rate -- not practical for fixed resolution display. 2.Pre-filtering: Smooth out high frequences analytically. Requires an analytic function. 3.Combination: Supersample and average down. Example - polygon: Memory requirement?

Implementing antialiasing Assuming this is a 2X supersampling grid, how to achieve anti-aliasing without using 4X memory? Rasterize shifted versions of the triangle on the original grid, accumulate the color, and divide the final image by the number of shifts

Canonical  Window Transform (-1,-1) (1,1) n y -1 (x min,y min )=(-0.5,-0.5) n x -1 (x max, y max )=(n x -0.5,n y -0.5)

Polygon anti-aliasing

3D Geometry Pipeline Model Space (Object Space) World Space Eye Space (View Space) Rotation Translation Resizing Canonical View Space Screen Space (2D) Rotation Translation Image Space (pixels) Raster Space

Visibility Given a set of polygons, which is visible at each pixel? (in front, etc.). Also called hidden surface removal Very large number of different algorithms known. Two main classes: – Object precision computations that operate on primitives – triangle A occludes triangle B – Image precision computations at the pixel level – pixel P sees point Q

Painter’s Algorithm Draw objects in a back-to-front order

Painter’s algorithm Failure case

Z-buffer (image precision) The Z-buffer or depth buffer algorithm [Catmull, 1974] is probably the simplest and most widely used. For each pixel on screen, have at least two buffers – Color buffer stores the current color of each pixel The thing to ultimately display – Z-buffer stores at each pixel the depth of the nearest thing seen so far Also called the depth buffer

Z-buffer Here is pseudocode for the Z-buffer hidden surface algorithm: How to compute shades/color? How to compute depth z? A3A3 A1A1 A2A2 P Triangle filling

Precision of depth Depth resolution not uniform More close to near plane, less further away Common mistake: set near = 0, far = infty. Don’t do this. Can’t set near = 0; lose depth resolution. n f -z y n f f n

Advantages: – Simple and now ubiquitous in hardware A z-buffer is part of what makes a graphics card “3D” – Computing the required depth values is simple Disadvantages: – Depth quantization errors can be annoying – Can’t easily do transparency Other issues of Z buffer

The A-buffer (Image Precision) Handles transparent surfaces and filter anti- aliasing At each pixel, maintain a pointer to a list of polygons sorted by depth

The A-buffer (Image Precision) if polygon is opaque and covers pixel, insert into list, removing all polygons farther away if polygon is transparent, insert into list, but don’t remove farther polygons

A-Buffer Composite For each pixel, we have a list of

The A-buffer (2) Advantage: – Can do more than Z-buffer – Alpha can represent partial coverage as well Disadvantages: – Not in hardware, and slow in software – Still at heart a z-buffer: depth quantization problems But, used in high quality rendering tools

Binary-space partitioning (BSP) trees Problem for Painter’s algorithm: Order is view dependent Idea: – Do extra preprocessing to allow quick display from any viewpoint. Key observation: A polygon A is painted in correct order if – Polygons on far side of A are painted first – A is painted next – Polygons on near side of A are painted last. Solution: build a tree to recursively partition the space and group polygons Why it works? What’s the assumption? A B C D eye E A C B DE

BSP tree creation procedure MakeBSPTree: takes PolygonList L returns BSPTree Choose polygon A from L to serve as root Split all polygons in L according to A node  A node.neg  MakeBSPTree(Polygons on neg. side of A) node.pos  MakeBSPTree(Polygons on pos. side of A) return node end procedure

Plane equation a b c (b-a)x(c-a) f(p) = n T (p-a) Plane equation: p Positive side f(p) > 0 Negative side f(p) < 0 n=

Split Triangles a b c D E abc => aED, Ebc, EcD

BSP tree display procedure DisplayBSPTree: Takes BSPTree T if T is empty then return if viewer is in front (on pos. side) of T.node DisplayBSPTree(T. _____ ) Draw T.node DisplayBSPTree(T._____) else DisplayBSPTree(T. _____) Draw T.node DisplayBSPTree(T. _____) end if end procedure

Performance Notes Does how well the tree is balanced matter? – No Does the number of triangles matter? – Yes Performance is improved when fewer polygons are split --- in practice, best of ~ 5 random splitting polygons are chosen. BSP is created in world coordinates. No projective matrices are applied before building tree.

BSP-Tree Rendering (2) Advantages: – One tree works for any viewing point – transparency works Have back to front ordering for compositing – Can also render front to back, and avoid drawing back polygons that cannot contribute to the view Major innovation in Quake Disadvantages: – Can be many small pieces of polygon

3D Geometry Pipeline Model Space (Object Space) World Space Eye Space (View Space) Rotation Translation Resizing Canonical View Space Screen Space (2D) Rotation Translation Image Space (pixels) Raster Space