Upload
wayne
View
26
Download
0
Tags:
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
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
2
Today
Clipping Clipping to view volumeClipping arbitrary polygons
Hidden Surface RemovalZ-BufferBSP TreesOthers
3
ClippingStuff outside view volume should not be drawn
Too close: obscures view
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
5
Clipping Line to Line/PlaneLine segment to be clipped
Line/plane that clips it
6
Clipping Line to Line/PlaneLine segment to be clipped
Line/plane that clips it
7
Clipping Line to Line/PlaneSegment may be on one side
Lines may be parallel
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
9
Polygon Clip to Convex Domain
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
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
12
General Polygon Clipping
13
Weiler AlgorithmDouble edges
General Polygon Clipping
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.
15
Z-BuffersAdd extra depth channel to imageWrite Z values when writing pixelsTest Z values before writing
16
Z-BuffersBenefits
Easy to implementWorks for most any geometric primitiveParallel operation in hardware
LimitationsQuantization and aliasing artifactsOverfillTransparency does not work well
17
Z-BuffersTransparency requires partial sorting:
Partiallytransparent
Opaque
Opaque 1st
2nd
3rdFront
Good
Partiallytransparent
Opaque
Opaque 2nd
3rd
1st
Not Good
18
Z-BuffersRecall depth-value distortions.
It’s a feature...More resolution near viewerBest use of limited precision
19
A-BuffersStore sorted list of “fragments” at each pixelDraw all opaque stuff first then transparentStuff behind full opacity gets ignored
Nice for antialiasing...
20
Scan-line AlgorithmAssume polygons don’t intersectEach time an edge is crossed determine who’s on top
21
Painter’s AlgorithmSort Polygons Front-to-Back
Draw in orderBack-to-Front works also, but wasteful
How to sort quickly?Intersecting polygons?Cycles?
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
23
BSP-Trees
24
BSP-Trees
25
BSP-Trees
26
BSP-Trees
27
BSP-Trees
28
BSP-Trees
+ -
+ - + -
+ +
+
+ +
+
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
30
BSP-Trees
31
BSP-Trees
32
Suggested Reading
Fundamentals of Computer Graphics by Pete Shirley
Chapter 7Clipping in chapter 11.1 and 11.2