32
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, Zoran Popovic, Jessica Hodgins V2005-06-1.1

CS-378: Game Technology

  • Upload
    wayne

  • View
    26

  • Download
    0

Embed Size (px)

DESCRIPTION

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, Zoran Popovic, Jessica Hodgins V2005-06-1.1. Today. Clipping Clipping to view volume Clipping arbitrary polygons - PowerPoint PPT Presentation

Citation preview

Page 1: CS-378: Game Technology

CS-378: Game TechnologyLecture #2.2: Clipping and

Hidden Surfaces

Prof. Okan ArikanUniversity of Texas, Austin

Thanks to James O’Brien, Steve Chenney, Zoran Popovic, Jessica HodginsV2005-06-1.1

Page 2: CS-378: Game Technology

2

Today

Clipping Clipping to view volumeClipping arbitrary polygons

Hidden Surface RemovalZ-BufferBSP TreesOthers

Page 3: CS-378: Game Technology

3

ClippingStuff outside view volume should not be drawn

Too close: obscures view

Page 4: CS-378: Game Technology

4

ClippingStuff outside view volume should not be drawn

Too close: obscures viewToo far:

ComplexityZ-buffer problems

Too high/low/right/left:Memory errorsBroken algorithmsComplexity

Page 5: CS-378: Game Technology

5

Clipping Line to Line/PlaneLine segment to be clipped

Line/plane that clips it

Page 6: CS-378: Game Technology

6

Clipping Line to Line/PlaneLine segment to be clipped

Line/plane that clips it

Page 7: CS-378: Game Technology

7

Clipping Line to Line/PlaneSegment may be on one side

Lines may be parallel

Page 8: CS-378: Game Technology

8

Polygon Clip to Convex Domain

Convex domain defined by collection of planes (or lines or hyper-planes)Planes have outward pointing normalsClip against each plane in turnCheck for early/trivial rejection

Page 9: CS-378: Game Technology

9

Polygon Clip to Convex Domain

Page 10: CS-378: Game Technology

10

Polygon Clip to Convex Domain

Inside Outside

s

p

Output p

Inside Outside

sp

Output i

Inside Outside

s

p

No output

Inside Outside

sp

Output i and p

i

i

Page 11: CS-378: Game Technology

11

Polygon Clip to Convex Domain

Sutherland-Hodgman algorithmBasically edge walking

Clipping done often... should be efficient

Liang-Barsky parametric space algorithmSee text for clipping in 4D homogenized coordiantes

Page 12: CS-378: Game Technology

12

General Polygon Clipping

Page 13: CS-378: Game Technology

13

Weiler AlgorithmDouble edges

General Polygon Clipping

Page 14: CS-378: Game Technology

14

Hidden Surface RemovalTrue 3D to 2D projection would put every thing overlapping into the view plane.We need to determine what’s in front and display only that.

Page 15: CS-378: Game Technology

15

Z-BuffersAdd extra depth channel to imageWrite Z values when writing pixelsTest Z values before writing

Page 16: CS-378: Game Technology

16

Z-BuffersBenefits

Easy to implementWorks for most any geometric primitiveParallel operation in hardware

LimitationsQuantization and aliasing artifactsOverfillTransparency does not work well

Page 17: CS-378: Game Technology

17

Z-BuffersTransparency requires partial sorting:

Partiallytransparent

Opaque

Opaque 1st

2nd

3rdFront

Good

Partiallytransparent

Opaque

Opaque 2nd

3rd

1st

Not Good

Page 18: CS-378: Game Technology

18

Z-BuffersRecall depth-value distortions.

It’s a feature...More resolution near viewerBest use of limited precision

Page 19: CS-378: Game Technology

19

A-BuffersStore sorted list of “fragments” at each pixelDraw all opaque stuff first then transparentStuff behind full opacity gets ignored

Nice for antialiasing...

Page 20: CS-378: Game Technology

20

Scan-line AlgorithmAssume polygons don’t intersectEach time an edge is crossed determine who’s on top

Page 21: CS-378: Game Technology

21

Painter’s AlgorithmSort Polygons Front-to-Back

Draw in orderBack-to-Front works also, but wasteful

How to sort quickly?Intersecting polygons?Cycles?

Page 22: CS-378: Game Technology

22

BSP-TreesBinary Space Partition Trees

Split space along planesAllows fast queries of some spatial relations

Simple construction algorithmSelect a plane as sub-tree rootEverything on one side to one childEverything on the other side to other childUse random polygon for splitting plane

Page 23: CS-378: Game Technology

23

BSP-Trees

Page 24: CS-378: Game Technology

24

BSP-Trees

Page 25: CS-378: Game Technology

25

BSP-Trees

Page 26: CS-378: Game Technology

26

BSP-Trees

Page 27: CS-378: Game Technology

27

BSP-Trees

Page 28: CS-378: Game Technology

28

BSP-Trees

+ -

+ - + -

+ +

+

+ +

+

Page 29: CS-378: Game Technology

29

Visibility TraversalVariation of in-order-traversal

Child oneSub-tree rootChild two

Select “child one” based on location of viewpoint

Child one on same side of sub-tree root as viewpoint

Page 30: CS-378: Game Technology

30

BSP-Trees

Page 31: CS-378: Game Technology

31

BSP-Trees

Page 32: CS-378: Game Technology

32

Suggested Reading

Fundamentals of Computer Graphics by Pete Shirley

Chapter 7Clipping in chapter 11.1 and 11.2