Hidden Surfaces II. Week 9, Mon Mar 15

Similar documents
Visibility: Z Buffering

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

Painter s Algorithm: Problems

Hidden Surfaces / Depth Test

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

CEng 477 Introduction to Computer Graphics Fall 2007

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

CS4620/5620: Lecture 14 Pipeline

Hidden surface removal. Computer Graphics

Pipeline Operations. CS 4620 Lecture 10

Pipeline Operations. CS 4620 Lecture 14

CSE528 Computer Graphics: Theory, Algorithms, and Applications

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

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

CS 381 Computer Graphics, Fall 2008 Midterm Exam Solutions. The Midterm Exam was given in class on Thursday, October 23, 2008.

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

Computer Graphics. Lecture 9 Hidden Surface Removal. Taku Komura

University of British Columbia CPSC 314 Computer Graphics Jan-Apr Tamara Munzner. Viewing 4. Page 1

COMP30019 Graphics and Interaction Scan Converting Polygons and Lines

Rasterization Overview

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

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

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

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

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

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

FROM VERTICES TO FRAGMENTS. Lecture 5 Comp3080 Computer Graphics HKBU

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

Computer Graphics. Bing-Yu Chen National Taiwan University

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

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

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

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

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

Graphics and Interaction Rendering pipeline & object modelling

Shading, Advanced Rendering. Week 7, Wed Feb 28

9. Visible-Surface Detection Methods

Chapter 8: Implementation- Clipping and Rasterization

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

Computer Graphics. - Clipping - Philipp Slusallek & Stefan Lemme

3D Polygon Rendering. Many applications use rendering of 3D polygons with direct illumination

Lecture 4. Viewing, Projection and Viewport Transformations

The Traditional Graphics Pipeline

The Traditional Graphics Pipeline

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

CHAPTER 1 Graphics Systems and Models 3

3D Rendering Pipeline (for direct illumination)

Introduction to Visualization and Computer Graphics

Sung-Eui Yoon ( 윤성의 )

Drawing Fast The Graphics Pipeline

University of British Columbia CPSC 314 Computer Graphics Jan-Apr Tamara Munzner. Viewing 4.

8. Hidden Surface Elimination

Models and Architectures. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

Computer Graphics. Shadows

The Traditional Graphics Pipeline

Computer Graphics II

Werner Purgathofer

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

Computergrafik. Matthias Zwicker. Herbst 2010

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

Viewing/Projections IV. Week 4, Fri Feb 1

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

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

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

Models and Architectures

Hidden Surface Removal

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

Introduction to Computer Graphics with WebGL

Realtime 3D Computer Graphics Virtual Reality

Drawing the Visible Objects

Course Title: Computer Graphics Course no: CSC209

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

Projection and viewing. Computer Graphics CSE 167 Lecture 4

Sung-Eui Yoon ( 윤성의 )

3D Graphics Pipeline II Clipping. Instructor Stephen J. Guy

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

- Rasterization. Geometry. Scan Conversion. Rasterization

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

From Vertices To Fragments-1

Computer Graphics Lecture 11

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

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

Drawing Fast The Graphics Pipeline

3D Rasterization II COS 426

Culling. Computer Graphics CSE 167 Lecture 12

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

RASTERISED RENDERING

CS 488. More Shading and Illumination. Luc RENAMBOT

Chapter 11 Global Illumination. Part 1 Ray Tracing. Reading: Angel s Interactive Computer Graphics (6 th ed.) Sections 11.1, 11.2, 11.

Lighting/Shading III. Week 7, Wed Mar 3

GUERRILLA DEVELOP CONFERENCE JULY 07 BRIGHTON

Clipping and Scan Conversion

Today. Rendering pipeline. Rendering pipeline. Object vs. Image order. Rendering engine Rendering engine (jtrt) Computergrafik. Rendering pipeline

Today. CS-184: Computer Graphics. Lecture #10: Clipping and Hidden Surfaces. Clipping. Hidden Surface Removal

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

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

OXFORD ENGINEERING COLLEGE (NAAC Accredited with B Grade) DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING LIST OF QUESTIONS

Triangle Rasterization

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

OpenGl Pipeline. triangles, lines, points, images. Per-vertex ops. Primitive assembly. Texturing. Rasterization. Per-fragment ops.

Transcription:

University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2010 Tamara Munzner Hidden Surfaces II Week 9, Mon Mar 15 http://www.ugrad.cs.ubc.ca/~cs314/vjan2010

ews yes, I'm granting the request for course marking scheme change old scheme: midterm 20%, final 25% 45% of grade is exam marks argument: midterm is 50 minutes, final is 150 minutes, so want 25/75% division vs 45/55% new scheme: midterm 12%, final 33% we'll check - if you would get a better grade in course with old scheme, we'll use that instead 2

Correction: P1 Hall of ame: Winner Sung-Hoon (ick) Kim 3

urther Clarification: Blinn-Phong Model only change vs Phong model is to have the specular calculation to use (h n) instead of (v r) full Blinn-Phong lighting model equation has ambient, diffuse, specular terms # lights I total = k a I ambient + " I i ( k d (n l i ) + k s (n h i ) nshiny ) i=1 just like full Phong model equation # lights I total = k a I ambient + " I i ( k d (n l i ) + k s (v r i ) nshiny ) i=1 4

Reading for Hidden Surfaces CG Sect 8.2.3 Z-Buffer CG Sect 12.4 BSP Trees (8.1, 8.2 2nd ed) 5

Review: Cohen-Sutherland Line Clipping outcodes 4 flags encoding position of a point relative to top, bottom, left, and right boundary OC(p1)== 0 && OC(p2)==0 trivial accept (OC(p1) & OC(p2))!= 0 trivial reject 1010 1000 1001 p1 0010 0000 0001 p2 p3 0110 0100 0101 x= x=x min x=x max y=y max y=y min 6

Review: Polygon Clipping not just clipping all boundary lines may have to introduce new line segments 7

Review: Sutherland-Hodgeman Clipping for each viewport edge clip the polygon against the edge equation for new vertex list after doing all edges, the polygon is fully clipped for each polygon vertex decide what to do based on 4 possibilities is vertex inside or outside? is previous vertex inside or outside? 8

Review: Sutherland-Hodgeman Clipping edge from p[i-1] to p[i] has four cases decide what to add to output vertex list inside p[i-1] outside inside outside inside outside p[i] inside p[i] outside p[i-1] p[i] p[i-1] p[i] p[i-1] p[i] output i output no output i output p[i] output 9

Review: Painter s Algorithm draw objects from back to front problems: no valid visibility order for intersecting polygons cycles of non-intersecting polygons possible 10

Binary Space Partition Trees (1979) BSP Tree: partition space with binary tree of planes idea: divide space recursively into half-spaces by choosing splitting planes that separate objects in scene preprocessing: create binary tree of planes runtime: correctly traversing this tree enumerates objects from back to front 11

Creating BSP Trees: Objects 12

Creating BSP Trees: Objects 13

Creating BSP Trees: Objects 14

Creating BSP Trees: Objects 15

Creating BSP Trees: Objects 16

Splitting Objects no bunnies were harmed in previous example but what if a splitting plane passes through an object? split the object; give half to each node Ouch 17

Traversing BSP Trees tree creation independent of viewpoint preprocessing step tree traversal uses viewpoint runtime, happens for many different viewpoints each plane divides world into near and far for given viewpoint, decide which side is near and which is far check which side of plane viewpoint is on independently for each tree vertex tree traversal differs depending on viewpoint! recursive algorithm recurse on far side draw object recurse on near side 18

Traversing BSP Trees query: given a viewpoint, produce an ordered list of (possibly split) objects from back to front: renderbsp(bsptree *T) BSPtree *near, *far; if (eye on left side of T->plane) near = T->left; far = T->right; else near = T->right; far = T->left; renderbsp(far); if (T is a leaf node) renderobject(t) renderbsp(near); 19

BSP Trees : Viewpoint A 20

BSP Trees : Viewpoint A 21

BSP Trees : Viewpoint A decide independently at each tree vertex not just left or right child! 22

BSP Trees : Viewpoint A 23

BSP Trees : Viewpoint A 24

BSP Trees : Viewpoint A 1 1 25

BSP Trees : Viewpoint A 1 2 1 2 26

BSP Trees : Viewpoint A 2 1 1 2 27

BSP Trees : Viewpoint A 2 1 1 2 28

BSP Trees : Viewpoint A 2 1 3 1 2 3 29

BSP Trees : Viewpoint A 1 3 4 2 1 2 4 3 30

BSP Trees : Viewpoint A 1 3 4 5 2 5 1 2 4 3 31

BSP Trees : Viewpoint A 1 3 4 5 2 8 6 7 9 5 1 2 9 6 4 3 8 7 32

BSP Trees : Viewpoint B 33

BSP Trees : Viewpoint B 8 9 7 6 4 5 2 1 1 3 5 9 8 2 7 6 4 3 34

BSP Tree Traversal: Polygons split along the plane defined by any polygon from scene classify all polygons into positive or negative half-space of the plane if a polygon intersects plane, split polygon into two and classify them both recurse down the negative half-space recurse down the positive half-space 35

useful demo: BSP Demo http://symbolcraft.com/graphics/bsp 36

pros: Summary: BSP Trees simple, elegant scheme correct version of painter s algorithm back-to-front rendering approach was very popular for video games (but getting less so) cons: slow to construct tree: O(n log n) to split, sort splitting increases polygon count: O(n 2 ) worst-case computationally intense preprocessing stage restricts algorithm to static scenes 37

Clarification: BSP Demo order of insertion can affect half-plane extent 38

pros: Summary: BSP Trees simple, elegant scheme correct version of painter s algorithm back-to-front rendering approach was very popular for video games (but getting less so) cons: slow to construct tree: O(n log n) to split, sort splitting increases polygon count: O(n 2 ) worst-case computationally intense preprocessing stage restricts algorithm to static scenes 39

The Z-Buffer Algorithm (mid-70 s) BSP trees proposed when memory was expensive first 512x512 framebuffer was >$50,000! Ed Catmull proposed a radical new approach called z-buffering the big idea: resolve visibility independently at each pixel 40

The Z-Buffer Algorithm we know how to rasterize polygons into an image discretized into pixels: 41

The Z-Buffer Algorithm what happens if multiple primitives occupy the same pixel on the screen? which is allowed to paint the pixel? 42

The Z-Buffer Algorithm idea: retain depth after projection transform each vertex maintains z coordinate relative to eye point can do this with canonical viewing volumes 43

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 check Z-buffer before storing pixel color in framebuffer and storing depth in Z-buffer don t write pixel if its Z value is more distant than the Z value already stored there 44

Interpolating Z barycentric coordinates interpolate Z like other planar parameters 45

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] = BACKGROUD_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 } } } 46

Depth Test Precision reminder: perspective transformation maps eye-space (view) z to DC z thus: 47

48 Correction: Ortho Camera Projection camera s back plane parallel to lens infinite focal length no perspective convergence just throw away z values x and y coordinates do not change with respect to z in this projection!!! " # $ $ $ % & =!!! " # $ $ $ % & 0 y x z y x p p p!!!! " # $ $ $ $ % &!!!! " # $ $ $ $ % & =!!!! " # $ $ $ $ % & 1 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 1 z y x z y x p p p P near far near far near far bot top bot top bot top left right left right left right P!!!!!!!!!! " # $ $ $ $ $ $ $ $ $ $ % & ' + ' ' ' ' + ' ' ' + ' ' = 1 0 0 0 2 0 0 0 2 0 0 0 2 ' week4.day2, slide 18

Depth Test Precision therefore, depth-buffer essentially stores 1/z, rather than z! issue with integer depth buffers high precision for near objects low precision for far objects z DC -n -f -z eye 49

Depth Test Precision low precision can lead to depth fighting for far objects two different depths in eye space get mapped to same depth in framebuffer which object wins depends on drawing order and scanconversion gets worse for larger ratios f:n rule of thumb: f:n < 1000 for 24 bit depth buffer with 16 bits cannot discern millimeter differences in objects at 1 km distance demo: sjbaker.org/steve/omniv/love_your_z_buffer.html 50

Z-Buffer Algorithm Questions 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? 51

simple!!! Z-Buffer Pros easy to implement in hardware hardware support in all graphics cards today 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 52

Z-Buffer Cons poor for scenes with high depth complexity need to render all polygons, even if most are invisible eye shared edges are handled inconsistently ordering dependent 53

Z-Buffer Cons requires lots of memory (e.g. 1280x1024x32 bits) requires fast memory Read-Modify-Write in inner loop hard to simulate translucent polygons we throw away color of polygons behind closest one works if polygons ordered back-to-front extra work throws away much of the speed advantage 54

Hidden Surface Removal two kinds of visibility algorithms object space methods image space methods 55

Object Space Algorithms determine visibility on object or polygon level using camera coordinates resolution independent explicitly compute visible portions of polygons early in pipeline after clipping requires depth-sorting painter s algorithm BSP trees 56

Image Space Algorithms perform visibility test for in screen coordinates limited to resolution of display Z-buffer: check every pixel independently performed late in rendering pipeline 57

Projective Rendering Pipeline glvertex3f(x,y,z) object world viewing OCS WCS VCS modeling transformation gltranslatef(x,y,z) glulookat(...) / w glrotatef(th th,x,y,z)... perspective division OCS - object coordinate system glutinitwindowsize(w,h) WCS - world coordinate system glviewport(x,y,a,b) VCS - viewing coordinate system viewport transformation CCS - clipping coordinate system DCS - normalized device coordinate system DCS - device coordinate system viewing transformation alter w projection transformation glrustum(...) clipping CCS normalized device DCS device DCS 58

Geometry Database normalized device DCS device DCS Scan Conversion object OCS (3D) Rendering Pipeline world WCS Model/View Transform. Texturing viewing VCS Lighting Depth Test Perspective Transform. screen SCS (2D) Blending clipping CCS (4D) Clipping ramebuffer /w 59