Visibility: Z Buffering

Similar documents
Hidden Surfaces II. Week 9, Mon Mar 15

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

Class of Algorithms. Visible Surface Determination. Back Face Culling Test. Back Face Culling: Object Space v. Back Face Culling: Object Space.

Hidden Surfaces / Depth Test

Painter s Algorithm: Problems

Hidden surface removal. Computer Graphics

CS4620/5620: Lecture 14 Pipeline

Visible-Surface Detection Methods. Chapter? Intro. to Computer Graphics Spring 2008, Y. G. Shin

Identifying those parts of a scene that are visible from a chosen viewing position, and only process (scan convert) those parts

University of British Columbia CPSC 314 Computer Graphics May-June Tamara Munzner Sampling, Virtual Trackball, Hidden Surfaces

Page 1. Area-Subdivision Algorithms z-buffer Algorithm List Priority Algorithms BSP (Binary Space Partitioning Tree) Scan-line Algorithms

Computer Graphics. Bing-Yu Chen National Taiwan University The University of Tokyo

Computer Graphics. Lecture 9 Hidden Surface Removal. Taku Komura

Computer Graphics. Bing-Yu Chen National Taiwan University

CSE528 Computer Graphics: Theory, Algorithms, and Applications

CSE328 Fundamentals of Computer Graphics: Concepts, Theory, Algorithms, and Applications

Computing Visibility. Backface Culling for General Visibility. One More Trick with Planes. BSP Trees Ray Casting Depth Buffering Quiz

COMP30019 Graphics and Interaction Scan Converting Polygons and Lines

Triangle Rasterization

Visible Surface Detection. (Chapt. 15 in FVD, Chapt. 13 in Hearn & Baker)

Rendering. Converting a 3D scene to a 2D image. Camera. Light. Rendering. View Plane

FROM VERTICES TO FRAGMENTS. Lecture 5 Comp3080 Computer Graphics HKBU

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

CSE 167: Lecture #5: Rasterization. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

Computer Graphics. Rendering. by Brian Wyvill University of Calgary. cpsc/enel P 1

CS 498 VR. Lecture 18-4/4/18. go.illinois.edu/vrlect18

Announcements. Written Assignment2 is out, due March 8 Graded Programming Assignment2 next Tuesday

CSE 167: Introduction to Computer Graphics Lecture #4: Vertex Transformation

Clipping & Culling. Lecture 11 Spring Trivial Rejection Outcode Clipping Plane-at-a-time Clipping Backface Culling

The Traditional Graphics Pipeline

Overview. Pipeline implementation I. Overview. Required Tasks. Preliminaries Clipping. Hidden Surface removal

CS452/552; EE465/505. Clipping & Scan Conversion

CEng 477 Introduction to Computer Graphics Fall 2007

The Traditional Graphics Pipeline

Graphics and Interaction Rendering pipeline & object modelling

Lecture 4. Viewing, Projection and Viewport Transformations

Pipeline Operations. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2018 Lecture 11

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

EECE 478. Learning Objectives. Learning Objectives. Rasterization & Scenes. Rasterization. Compositing

Visibility and Occlusion Culling

Rasterization Overview

Pipeline Operations. CS 4620 Lecture 14

Topic #1: Rasterization (Scan Conversion)

Spatial Data Structures

Notes on Assignment. Notes on Assignment. Notes on Assignment. Notes on Assignment

8. Hidden Surface Elimination

The Traditional Graphics Pipeline

S U N G - E U I YO O N, K A I S T R E N D E R I N G F R E E LY A VA I L A B L E O N T H E I N T E R N E T

CHAPTER 1 Graphics Systems and Models 3

Pipeline Operations. CS 4620 Lecture 10

9. Visible-Surface Detection Methods

LOD and Occlusion Christian Miller CS Fall 2011

Determination (Penentuan Permukaan Tampak)

Computer Graphics II

VISIBILITY & CULLING. Don t draw what you can t see. Thomas Larsson, Afshin Ameri DVA338, Spring 2018, MDH

CSE 167: Introduction to Computer Graphics Lecture #9: Visibility. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2018

Spatial Data Structures

RASTERISED RENDERING

Chapter 8: Implementation- Clipping and Rasterization

Rasterization. MIT EECS Frédo Durand and Barb Cutler. MIT EECS 6.837, Cutler and Durand 1

Computer Graphics. Lecture 9 Environment mapping, Mirroring

Computer Graphics Shadow Algorithms

Hidden Surface Removal

Werner Purgathofer

CSE 167: Introduction to Computer Graphics Lecture #5: Projection. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2017

Drawing Fast The Graphics Pipeline

Rendering. Basic Math Review. Rasterizing Lines and Polygons Hidden Surface Remove Multi-pass Rendering with Accumulation Buffers.

Computer Graphics: 8-Hidden Surface Removal

Culling. Computer Graphics CSE 167 Lecture 12

TDA362/DIT223 Computer Graphics EXAM (Same exam for both CTH- and GU students)

Final projects. Rasterization. The Graphics Pipeline. Illumination (Shading) (Lighting) Viewing Transformation. Rest of semester. This week, with TAs

Projection Matrix Tricks. Eric Lengyel

Computer Graphics. Shadows

From Vertices to Fragments: Rasterization. Reading Assignment: Chapter 7. Special memory where pixel colors are stored.

Spatial Data Structures

Rasterization and Graphics Hardware. Not just about fancy 3D! Rendering/Rasterization. The simplest case: Points. When do we care?

Clipping. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

Computergrafik. Matthias Zwicker. Herbst 2010

INFOGR Computer Graphics. J. Bikker - April-July Lecture 11: Visibility. Welcome!

The Graphics Pipeline. Interactive Computer Graphics. The Graphics Pipeline. The Graphics Pipeline. The Graphics Pipeline: Clipping

Spatial Data Structures

CSE 167: Introduction to Computer Graphics Lecture #5: Rasterization. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2015

CSE 167: Introduction to Computer Graphics Lecture #11: Visibility Culling

Ray tracing. Computer Graphics COMP 770 (236) Spring Instructor: Brandon Lloyd 3/19/07 1

CSE 167: Lecture #4: Vertex Transformation. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

COMPUTER GRAPHICS COURSE. Rendering Pipelines

Renderer Implementation: Basics and Clipping. Overview. Preliminaries. David Carr Virtual Environments, Fundamentals Spring 2005

CMSC427 Advanced shading getting global illumination by local methods. Credit: slides Prof. Zwicker

Projection and viewing. Computer Graphics CSE 167 Lecture 4

Shadow Algorithms. CSE 781 Winter Han-Wei Shen

Spatial Data Structures

Surface Graphics. 200 polys 1,000 polys 15,000 polys. an empty foot. - a mesh of spline patches:

3D Object Representation

Hidden Surface Elimination: BSP trees

Last Time. Why are Shadows Important? Today. Graphics Pipeline. Clipping. Rasterization. Why are Shadows Important?

Let s start with occluding contours (or interior and exterior silhouettes), and look at image-space algorithms. A very simple technique is to render

Shadows in the graphics pipeline

Topics. From vertices to fragments

POWERVR MBX. Technology Overview

Transcription:

University of British Columbia CPSC 414 Computer Graphics Visibility: Z Buffering Week 1, Mon 3 Nov 23 Tamara Munzner 1

Poll how far are people on project 2? preferences for Plan A: status quo P2 stays due Tue Nov 4, stays 1% of total grade P3 is the big one stays 15%, due Fri Nov 28 Plan B: P2 is the big one P2 extension to Mon Nov 1, upgrade weight to 15% P3 smaller, downgrade weight to 1%, due Fri Dec 5 Week 1, Mon 3 Nov 3 Tamara Munzner 2

Demo sample program remember, download all 3 textures to run this! you should also use the checkerboard image questions? Week 1, Mon 3 Nov 3 Tamara Munzner 3

Readings Chapter 8.8: hidden surface removal Week 1, Mon 3 Nov 3 Tamara Munzner 4

News yet more extra office hours TBD check newsgroup Week 1, Mon 3 Nov 3 Tamara Munzner 5

University of British Columbia CPSC 414 Computer Graphics Visibility recap Tamara Munzner 6

Invisible Primitives why might a polygon be invisible? polygon outside the field of view / frustum clipping polygon is backfacing backface culling polygon is occluded by object(s) nearer the viewpoint hidden surface removal Week 1, Mon 3 Nov 3 Tamara Munzner 7

Back-Face Culling on the surface of a closed manifold, polygons whose normals point away from the camera are always occluded: note: backface culling alone doesn t solve the hidden-surface problem! Week 1, Mon 3 Nov 3 Tamara Munzner 8

Back-face Culling: NDCS VCS y z eye NDCS eye y z works to cull if > N Z Week 1, Mon 3 Nov 3 Tamara Munzner 9

Painter s Algorithm draw objects from back to front problems: no valid visibility order for intersecting polygons cycles of non-intersecting polygons possible Week 1, Mon 3 Nov 3 Tamara Munzner 1

BSP Trees preprocess: create binary tree recursive spatial partition Week 1, Mon 3 Nov 3 Tamara Munzner 11

BSP Trees runtime: correctly traversing this tree enumerates objects from back to front check which side of plane viewpoint is on draw far, draw object in question, draw near Week 1, Mon 3 Nov 3 Tamara Munzner 12

Summary: BSP Trees pros: simple, elegant scheme only writes to framebuffer (no reads to see if current polygon is in front of previously rendered polygon, i.e., painters algorithm) cons: thus very popular for video games (but getting less so) computationally intense preprocess stage restricts algorithm to static scenes slow time to construct tree: O(n log n) to split, sort Week 1, Mon 3 Nov 3 Tamara Munzner 13

recursive viewport subdivision, stop if polygons Warnock s Algorithm background color 1 polygon object color down to single pixel explicitly find depths of all objects in viewport Week 1, Mon 3 Nov 3 Tamara Munzner 14

pros: Warnock s Algorithm very elegant scheme extends to any primitive type cons: hard to embed hierarchical schemes in hardware complex scenes usually have small polygons and high depth complexity thus most screen regions come down to the single-pixel case Week 1, Mon 3 Nov 3 Tamara Munzner 15

The Z-Buffer Algorithm both BSP trees and Warnock s algorithm were proposed when memory was expensive example: first 512x512 framebuffer > $5,! Ed Catmull (mid-7s) proposed a radical new approach called z-buffering. the big idea: resolve visibility independently at each pixel Week 1, Mon 3 Nov 3 Tamara Munzner 16

The Z-Buffer Algorithm we know how to rasterize polygons into an image discretized into pixels: Week 1, Mon 3 Nov 3 Tamara Munzner 17

The Z-Buffer Algorithm what happens if multiple primitives occupy the same pixel on the screen? Which is allowed to paint the pixel? Week 1, Mon 3 Nov 3 Tamara Munzner 18

The Z-Buffer Algorithm idea: retain depth (Z in eye coordinates) through projection transform use canonical viewing volumes each vertex has z coordinate (relative to eye point) intact Week 1, Mon 3 Nov 3 Tamara Munzner 19

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 and store in pixel of Z-buffer suppress writing to a pixel if its Z value is more distant than the Z value already stored there Week 1, Mon 3 Nov 3 Tamara Munzner 2

Interpolating Z edge equations: Z just another planar parameter: z = (-D - Ax By) / C if walking across scanline by (Dx) znew = zold (A/C)(Dx) total cost: 1 more parameter to increment in inner loop 3x3 matrix multiply for setup edge walking: just interpolate Z along edges and across spans Week 1, Mon 3 Nov 3 Tamara Munzner 21

Z-buffer store (r,g,b,z) for each pixel typically 8+8+8+24 bits, can be more for all i,j { Depth[i,j] = MAX_DEPTH Image[i,j] = BACKGROUND_COLOUR } for all polygons P { for all pixels in P { if (Z_pixel < Depth[i,j]) { Image[i,j] = C_pixel Depth[i,j] = Z_pixel } } } Week 1, Mon 3 Nov 3 Tamara Munzner 22

Week 1, Mon 3 Nov 3 Tamara Munzner 23 Depth Test Precision reminder: projective transformation maps eyespace z to generic z-range (NDC) simple example: thus: = 1 1 1 1 1 z y x b a z y x T = 1 1 1 1 1 z y x b a z y x T eye eye eye NDC z b a z b z a z + = + = eye eye eye NDC z b a z b z a z + = + =

Depth Test Precision therefore, depth-buffer essentially stores 1/z, rather than z! this yields precision problems with integer depth buffers: z NDC -n -f -z eye Week 1, Mon 3 Nov 3 Tamara Munzner 24

Depth Test Precision precision of depth buffer is bad for far objects depth fighting: 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 < 1 for 24 bit depth buffer Week 1, Mon 3 Nov 3 Tamara Munzner 25

Z-buffer hardware support in graphics cards poor for high-depth-complexity scenes need to render all polygons, even if most are invisible eye jaggies : pixel staircase along edges Week 1, Mon 3 Nov 3 Tamara Munzner 26

The A-Buffer antialiased, area-averaged accumulation buffer z-buffer: one visible surface per pixel A-buffer: linked list of surfaces data for each surface includes RGB, Z, area-coverage percentage,... Week 1, Mon 3 Nov 3 Tamara Munzner 27

The Z-Buffer Algorithm 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? Week 1, Mon 3 Nov 3 Tamara Munzner 28

simple!!! Z-Buffer Pros easy to implement in hardware 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 Week 1, Mon 3 Nov 3 Tamara Munzner 29

Z-Buffer Cons lots of memory (e.g. 128x124x32 bits) with 16 bits cannot discern millimeter differences in objects at 1 km distance Read-Modify-Write in inner loop requires fast memory hard to do analytic antialiasing we don t know which polygon to map pixel back to shared edges are handled inconsistently ordering dependent hard to simulate translucent polygons we throw away color of polygons behind closest one Week 1, Mon 3 Nov 3 Tamara Munzner 3

Visibility object space algorithms explicitly compute visible portions of polygons painter s algorithm: depth-sorting, BSP trees image space algorithms operate on pixels or scan-lines visibility resolved to the precision of the display Z-buffer, Warnock s Week 1, Mon 3 Nov 3 Tamara Munzner 31

Hidden Surface Removal 2 classes of methods image-space algorithms perform visibility test for every pixel independently limited to resolution of display performed late in rendering pipeline object-space algorithms determine visibility on a polygon level in camera coordinates resolution independent early in rendering pipeline (after clipping) expensive Week 1, Mon 3 Nov 3 Tamara Munzner 32

Pick up Homework 1 Week 1, Mon 3 Nov 3 Tamara Munzner 33