David Luebke11/26/2015 CS 551 / 645: Introductory Computer Graphics David Luebke...

Post on 14-Dec-2015

221 views 0 download

transcript

David Luebke 04/18/23

CS 551 / 645: Introductory Computer Graphics

David Luebke

cs551@cs.virginia.edu

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

David Luebke 04/18/23

Recap: 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?

David Luebke 04/18/23

Recap: 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)

David Luebke 04/18/23

Ray Tracing

Idea: – trace a ray from the eyepoint through the center

of each pixel– Color pixel according to the first object the ray hits– Simple! No need for:

Perspective projection matrices Clipping Scan conversion of polygons

David Luebke 04/18/23

Ray Tracing

An example:

ScreenEyepoint Scene

David Luebke 04/18/23

Ray Tracing

An example:

ScreenEyepoint Scene

David Luebke 04/18/23

Ray Tracing

Two flavors of the algorithm:– Ray casting just finds visible surfaces– Recursive ray tracing traces additional rays from

those surfaces for sophisticated shading Shadows Reflection Refraction

David Luebke 04/18/23

Ray Tracing: The Catch

Ray tracing is a simple, powerful way to determine visibility & shading

So why don’t we always use it?

David Luebke 04/18/23

Ray Tracing: The Catch

Ray tracing is a simple, powerful way to determine visibility & shading

So why don’t we always use it? Too slow!

– Complexity proportional to # of pixels– Typical screen: ~1,000,000 pixels– Typical scene:« 1,000,000 polygons

David Luebke 04/18/23

Visibility Algorithms

The Z-buffer is an image-space algorithm– Takes place at the end of the pipeline, in screen-

space coordinates

BSP Trees are an object-space algorithm– Takes place in world-space coordinates

Warnock’s algorithm is a hybrid – Uses both screen-space and object-space

information

How would you classify ray casting?

David Luebke 04/18/23

Visibility Algorithms

The 70’s were the decade of analytic object-space algorithms

In the mid-80’s, memory got cheap enough that Z-buffers became the practical choice

Then history repeated itself… Next up: conservative visibility algorithms for

reducing load from the front end of the rendering pipeline

David Luebke 04/18/23

Conservative Visibility Agorithms

View-frustum culling– Organize primitives into clumps with a simple

bounding volume– Before rendering the primitives in a clump, test its

bounding volume against the view frustum If the clump is entirely outside the view frustum, don’t

render any of the primitives If the clump intersects the view frustum, render normally If the clump is entirely within the view frustum, can

render with clipping disabled

David Luebke 04/18/23

Efficient View-Frustum Culling

How big should the clumps be?– Choose minimum size so:

cost testing bounding volume << cost clipping primitive

– Organize bounding volumes into a hierarchy for more efficient testing

A general strategy known as hierarchical bounding volumes

David Luebke 04/18/23

Efficient View-Frustum Culling

What shape should bounding volumes be?– Spheres and axis-aligned bounding boxes are

simple to calculate and cheap to test– Oriented bounding boxes converge asymptotically

faster in theory– Lots of other volumes have been proposed, but

most people still use spheres and AABBs.

David Luebke 04/18/23

Efficient View-Frustum Culling

Where in the pipeline should view-frustum culling be performed?– As early as possible (world coordinates)

David Luebke 04/18/23

Cells & Portals

Goal: walk through architectural models (buildings, cities, catacombs…)

These divide naturally into cells– Rooms, alcoves, corridors…

Transparent portals connect cells– Doorways, entrances, windows…

Key observation: cells only see each other through portals!

David Luebke 04/18/23

Cells & Portals

Idea: – Create an adjacency graph of cells– Starting with cell containing eyepoint, traverse

graph, rendering visible cells – A cell is only visible if it can be seen through a

sequence of portals Need a line of sight So cell visibility reduces to testing portal sequences…

David Luebke 04/18/23

Cells & Portals

A

D

H

FCB

E

G

H

B C D F G

EA

David Luebke 04/18/23

Cells & Portals

A

D

H

FCB

E

G

H

B C D F G

EA

David Luebke 04/18/23

Cells & Portals

A

D

H

FCB

E

G

H

B C D F G

EA

David Luebke 04/18/23

Cells & Portals

A

D

H

FCB

E

G

H

B C D F G

EA

David Luebke 04/18/23

Cells & Portals

A

D

H

FCB

E

G

H

B C D F G

EA

David Luebke 04/18/23

Cells & Portals

Can even figure out which cells a particular cell will never see:

Ex: H will never see F; B can only see H

This can further speed up culling

A

D

H

FCB

E

G

David Luebke 04/18/23

Overview

Recap: visible surfaces; Z-buffer Other exact algorithms

– BSP trees– Ray casting

Conservative algorithms– View-frustum culling– Cells & portals– Occlusion culling

David Luebke 04/18/23

Occlusion Culling

When cells and portals don’t work…– Trees in a forest– A crowded train station

Need general occlusion culling algs:– Dynamic scenes, aggregate occluders– Open problem, little work so far:

Hierarchical Z-Buffer (Greene 93) Hierarchical Occlusion Maps (Zhang 97)