+ All Categories
Home > Documents > David Luebke5/11/2015 CS 551 / 645: Introductory Computer Graphics David Luebke...

David Luebke5/11/2015 CS 551 / 645: Introductory Computer Graphics David Luebke...

Date post: 16-Dec-2015
Category:
Upload: gregory-walters
View: 217 times
Download: 0 times
Share this document with a friend
29
David Luebke 03/26/22 CS 551 / 645: Introductory Computer Graphics David Luebke [email protected] http://www.cs.virginia.edu/~cs551
Transcript
Page 1: David Luebke5/11/2015 CS 551 / 645: Introductory Computer Graphics David Luebke cs551@cs.virginia.edu cs551.

David Luebke 04/18/23

CS 551 / 645: Introductory Computer Graphics

David Luebke

[email protected]

http://www.cs.virginia.edu/~cs551

Page 2: David Luebke5/11/2015 CS 551 / 645: Introductory Computer Graphics David Luebke cs551@cs.virginia.edu cs551.

David Luebke 04/18/23

Administrivia

Note changes on homework web page– We were always drawing the icosahedron inside

out…oops

Page 3: David Luebke5/11/2015 CS 551 / 645: Introductory Computer Graphics David Luebke cs551@cs.virginia.edu cs551.

David Luebke 04/18/23

Recap: Visible Surface Determination Reasons for invisible polygons:

– Polygon outside the field of view– Polygon is backfacing– Polygon is occluded by object(s) nearer the

viewpoint

Algorithms for determining which potions of which polygons are visible (unoccluded) are known as visible surface algorithms

Page 4: David Luebke5/11/2015 CS 551 / 645: Introductory Computer Graphics David Luebke cs551@cs.virginia.edu cs551.

David Luebke 04/18/23

Recap: Occlusion

For most interesting scenes, some polygons will overlap:

To render the correct image, we need to determine which polygons occlude which

Page 5: David Luebke5/11/2015 CS 551 / 645: Introductory Computer Graphics David Luebke cs551@cs.virginia.edu cs551.

David Luebke 04/18/23

Recap: Painter’s Algorithm

Simple approach: render the polygons from back to front, “painting over” previous polygons:

Doesn’t work in general case– Intersecting polygons– Visibility cycles:

Page 6: David Luebke5/11/2015 CS 551 / 645: Introductory Computer Graphics David Luebke cs551@cs.virginia.edu cs551.

David Luebke 04/18/23

Recap: Binary Space Partition(BSP) Trees Fuchs et al, 1980 Assumptions:

– Static scene– Moving camera

Commonly used in 3-D video games (e.g., Quake), but going out of style

Still a very powerful, general idea, used in many graphics algorithms

Page 7: David Luebke5/11/2015 CS 551 / 645: Introductory Computer Graphics David Luebke cs551@cs.virginia.edu cs551.

David Luebke 04/18/23

Recap: BSP Trees

– Preprocess: overlay a binary (BSP) tree on objects in the scene

– Runtime: correctly traversing this tree enumerates objects from back to front

– Idea: divide space recursively into half-spaces by choosing splitting planes

Splitting planes can be arbitrarily oriented Notice: nodes are always convex

Page 8: David Luebke5/11/2015 CS 551 / 645: Introductory Computer Graphics David Luebke cs551@cs.virginia.edu cs551.

David Luebke 04/18/23

Recap: BSP Trees

Page 9: David Luebke5/11/2015 CS 551 / 645: Introductory Computer Graphics David Luebke cs551@cs.virginia.edu cs551.

David Luebke 04/18/23

Recap: BSP Trees

Page 10: David Luebke5/11/2015 CS 551 / 645: Introductory Computer Graphics David Luebke cs551@cs.virginia.edu cs551.

David Luebke 04/18/23

Recap: BSP Trees

Page 11: David Luebke5/11/2015 CS 551 / 645: Introductory Computer Graphics David Luebke cs551@cs.virginia.edu cs551.

David Luebke 04/18/23

Recap: BSP Trees

Page 12: David Luebke5/11/2015 CS 551 / 645: Introductory Computer Graphics David Luebke cs551@cs.virginia.edu cs551.

David Luebke 04/18/23

Recap: BSP Trees

Page 13: David Luebke5/11/2015 CS 551 / 645: Introductory Computer Graphics David Luebke cs551@cs.virginia.edu cs551.

David Luebke 04/18/23

Recap: Rendering BSP Trees

renderBSP(BSPtree *T)

BSPtree *near, far;

if (T is a leaf node)

renderObject(T)

if (eye on left side of T->plane)

near = T->left; far = T->right;

else

near = T->right; far = T->left;

renderBSP(far);

renderBSP(near);

Page 14: David Luebke5/11/2015 CS 551 / 645: Introductory Computer Graphics David Luebke cs551@cs.virginia.edu cs551.

David Luebke 04/18/23

Recap: Rendering BSP Trees

Page 15: David Luebke5/11/2015 CS 551 / 645: Introductory Computer Graphics David Luebke cs551@cs.virginia.edu cs551.

David Luebke 04/18/23

Recap: Rendering BSP Trees

Page 16: David Luebke5/11/2015 CS 551 / 645: Introductory Computer Graphics David Luebke cs551@cs.virginia.edu cs551.

David Luebke 04/18/23

Recap: BSP Tree Cons

No bunnies were harmed in my example But what if a splitting plane passes through an

object?– Split the object; give half to each node:

– Worst case: can create up to O(n3) objects!

Ouch

Page 18: David Luebke5/11/2015 CS 551 / 645: Introductory Computer Graphics David Luebke cs551@cs.virginia.edu cs551.

David Luebke 04/18/23

Warnock’s Algorithm (1969)

Elegant scheme based on a powerful general approach common in graphics: if the situation is too complex, subdivide– Start with a root viewport and a list of all primitives– Then recursively:

Clip objects to viewport If number of objects incident to viewport is zero or one,

visibility is trivial Otherwise, subdivide into smaller viewports, distribute

primitives among them, and recurse

Page 19: David Luebke5/11/2015 CS 551 / 645: Introductory Computer Graphics David Luebke cs551@cs.virginia.edu cs551.

David Luebke 04/18/23

Warnock’s Algorithm

What is the terminating condition?

How to determine the correct visible surface in this case?

Page 20: David Luebke5/11/2015 CS 551 / 645: Introductory Computer Graphics David Luebke cs551@cs.virginia.edu cs551.

David Luebke 04/18/23

Warnock’s Algorithm

Pros:– 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

Page 21: David Luebke5/11/2015 CS 551 / 645: Introductory Computer Graphics David Luebke cs551@cs.virginia.edu cs551.

David Luebke 04/18/23

The Z-Buffer Algorithm

Both BSP trees and Warnock’s algorithm were proposed when memory was expensive– Example: first 512x512 framebuffer > $50,000!

Ed Catmull (mid-70s) proposed a radical new approach called z-buffering.

The big idea: resolve visibility independently at each pixel

Page 22: David Luebke5/11/2015 CS 551 / 645: Introductory Computer Graphics David Luebke cs551@cs.virginia.edu cs551.

David Luebke 04/18/23

The Z-Buffer Algorithm

We know how to rasterize polygons into an image discretized into pixels:

Page 23: David Luebke5/11/2015 CS 551 / 645: Introductory Computer Graphics David Luebke cs551@cs.virginia.edu cs551.

David Luebke 04/18/23

The Z-Buffer Algorithm

What happens if multiple primitives occupy the same pixel on the screen? Which is allowed to paint the pixel?

Page 24: David Luebke5/11/2015 CS 551 / 645: Introductory Computer Graphics David Luebke cs551@cs.virginia.edu cs551.

David Luebke 04/18/23

The Z-Buffer Algorithm

Idea: retain depth (Z in eye coordinates) through projection transform– Recall canonical viewing volumes (see slide)– Can transform canonical perspective volume into

canonical parallel volume with:

010011

100

0010

0001

min

min

min z

z

z

M

Page 25: David Luebke5/11/2015 CS 551 / 645: Introductory Computer Graphics David Luebke cs551@cs.virginia.edu cs551.

David Luebke 04/18/23

The Z-Buffer Algorithm

Augment 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 “More distant”: greater than or less than, depending

Page 26: David Luebke5/11/2015 CS 551 / 645: Introductory Computer Graphics David Luebke cs551@cs.virginia.edu cs551.

David Luebke 04/18/23

Interpolating Z

Edge equations: Z is just another planar parameter:

z = Ax + By + C

– Look familiar?– Total cost:

1 more parameter to increment in inner loop

3x3 matrix multiply for setup

– See interpolating color discussion from lecture 10

Edge walking: just interpolate Z along edges and across spans

Page 27: David Luebke5/11/2015 CS 551 / 645: Introductory Computer Graphics David Luebke cs551@cs.virginia.edu cs551.

David Luebke 04/18/23

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 much of the pipeline do occluded

polgyons traverse?– What does this imply for the front of the pipeline?

– How does Z-buffer load scale with visible polygons? With framebuffer resolution?

Page 28: David Luebke5/11/2015 CS 551 / 645: Introductory Computer Graphics David Luebke cs551@cs.virginia.edu cs551.

David Luebke 04/18/23

Z-Buffer Pros

Simple!!! 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

– When does this help?

Page 29: David Luebke5/11/2015 CS 551 / 645: Introductory Computer Graphics David Luebke cs551@cs.virginia.edu cs551.

David Luebke 04/18/23

Z-Buffer Cons

Lots of memory (e.g. 1280x1024x32 bits) Read-Modify-Write in inner loop requires fast

memory Hard to do analytic antialiasing Hard to simulate translucent polygons Precision issues (scintillating, worse with

perspective projection)


Recommended