8/18/2019 Graphics14-SurfaceDetectionMethods
1/95
Course Website: http://www.comp.dit.ie/bmacnamee
Computer Graphics:Surface Detection Methods
http://www.comp.dit.ie/bmacnameehttp://www.comp.dit.ie/bmacnamee
8/18/2019 Graphics14-SurfaceDetectionMethods
2/95
2
of
28Contents
Today we wi start to ta!e a oo! at "isibesurface detection techni#ues:
– Why surface detection$
–
%ac! face detection – Depth&buffer method
– '&buffer method
–
Scan&ine method
8/18/2019 Graphics14-SurfaceDetectionMethods
3/95
(
of
28Why$
We must determine what is "isibe within ascene from a chosen "iewin) position
*or (D words this is !nown as visible
surface detection or hidden surfaceelimination
8/18/2019 Graphics14-SurfaceDetectionMethods
4/95
+
of
28Two Main 'pproaches
,isibe surface detection a)orithms arebroady cassified as:
– Object Space Methods: Compares ob-ects
and parts of ob-ects to each other within thescene definition to determine which surfaces
are "isibe
– Image Space Methods: ,isibiity is decided
point&by&point at each pie position on thepro-ection pane
ma)e space methods are by far the more
common
8/18/2019 Graphics14-SurfaceDetectionMethods
5/95
0
of
28Two Main 'pproaches
Object-space methods (Continuous):
Implemented in WCS considering the geometrical relationships
beteen the actual objects!It compares the objects " parts of
objects to each other ithin the scene definition to determine
hich surfaces as hole should e label as visible!
1Image Space methods (discrete):
Implemented in screen co-ordinate s#stem considering the
relationships b$ images of objects in their final configuration at
pi%el level!&isibilit# is decided point b# point at each pi%el positionon the projection plane!
8/18/2019 Graphics14-SurfaceDetectionMethods
6/95
of
283%45CT S6'C5 '7G3T9MS
•3b-ect space a)orithms do their wor! on the ob-ectsthemse"es before they are con"erted to pies in the
frame buffer. The resoution of the dispay de"ice is
irree"ant here as this cacuation is done at the
mathematica e"e of the ob-ects
• for each object a in the scene determine which parts of object a are
visible (involves comparing the polyons in object a to other polygons
in a and to polygons in every other object in the scene)
8/18/2019 Graphics14-SurfaceDetectionMethods
7/95
of
28M'G5 S6'C5 '7G3T9MS
•Image space a)orithms do their wor! as the ob-ects arebein) con"erted to pies in the frame buffer. The
resoution of the dispay de"ice is important here as this
is done on a pie by pie basis.
•
for each pixel in the frame buffer determine which polygonis closest to the viewer at that pixel location colour the pixel
with the colour of that polygon at that location
8/18/2019 Graphics14-SurfaceDetectionMethods
8/95
8
of
28C95C;
8/18/2019 Graphics14-SurfaceDetectionMethods
9/95
@
of
28
• There are aso times when we may notwant to cu out poy)ons that are behind
other poy)ons. f the frontmost poy)on is
transparent then we want to be abe toAsee throu)hA it to the poy)ons that are
behind it as shown beow:
8/18/2019 Graphics14-SurfaceDetectionMethods
10/95
B
of
28
Which ob-ects are transparent in the
abo"e scene$
8/18/2019 Graphics14-SurfaceDetectionMethods
11/95
BB
of
28C3955
8/18/2019 Graphics14-SurfaceDetectionMethods
12/95
B2
of
285T5
8/18/2019 Graphics14-SurfaceDetectionMethods
13/95
B(
of
285T5
8/18/2019 Graphics14-SurfaceDetectionMethods
14/95
B+
of
285T5 *or
more detaiE chec!s woud then be made on the ob-ect in
the bo.
• There are many ways to define the boundin) bo. The
simpest way is to ta!e the minimum and maimum E FE
and ? "aues to create a bo. Fou can aso ha"e
boundin) boes that rotate with the ob-ectE boundin)
spheresE boundin) cyindersE etc.
8/18/2019 Graphics14-SurfaceDetectionMethods
15/95
B0
of
28Two Main 'pproaches
8/18/2019 Graphics14-SurfaceDetectionMethods
16/95
B
of
28Two Main 'pproaches
8/18/2019 Graphics14-SurfaceDetectionMethods
17/95
B
of
28%ac!&*ace Detection
The simpest thin) we can do is find thefaces on the bac!s of poyhedra and discard
them
8/18/2019 Graphics14-SurfaceDetectionMethods
18/95
B8
of
28%ac!&*ace Detection =cont>
We !now from before that a point = x, y, z > isbehind a poy)on surface if:
where A, B, C H D are the pane parametersfor the surface
This can actuay be made e"en easier if we
or)anise thin)s to suit ourse"es
0
8/18/2019 Graphics14-SurfaceDetectionMethods
19/95
B@
of
28%ac!&*ace Detection =cont>
5nsure we ha"e a ri)ht handed system withthe "iewin) direction aon) the ne)ati"e z &ais
8/18/2019 Graphics14-SurfaceDetectionMethods
20/95
2
of
28%ac!&*ace Detection =cont>
n )enera bac!&face detection can beepected to eiminate about haf of the
poy)on surfaces in a scene from further
"isibiity testsMore compicated surfaces
thou)h scupper us
We need better techni#uesto hande these !ind of
situations
8/18/2019 Graphics14-SurfaceDetectionMethods
21/95
2B
of
28%ac!&*ace Detection =cont>
8/18/2019 Graphics14-SurfaceDetectionMethods
22/95
22
of
28Depth&%uffer Method
Compares surface depth "aues throu)houta scene for each pie position on the
pro-ection pane
Nsuay appied to scenes ony containin)poy)ons
's depth "aues can be computed easiyE
this tends to be "ery fast 'so often caed the J&buffer method
8/18/2019 Graphics14-SurfaceDetectionMethods
23/95
2(
of
28Depth&%uffer Method =cont>
/ m a ) e s t a ! e n f r o m 9 e a r n H % a ! e r E K C o m p u t e r G r a p h i c
s w i t h 3 p e n G 7 L = 2 + >
8/18/2019 Graphics14-SurfaceDetectionMethods
24/95
2+
of
28Depth&%uffer ')orithm
B. nitiaise the depth buffer and frame bufferso that for a buffer positions = x, y>
depth%uff=E y> O B.
frame%uff=E y> O b)Coour
8/18/2019 Graphics14-SurfaceDetectionMethods
25/95
20
of
28Depth&%uffer ')orithm =cont>
2. 6rocess each poy)on in a sceneE one ata time
– *or each pro-ected = x, y> pie position of a
poy)onE cacuate the depth z =if not aready!nown>
– f J P depth%uff=E y>E compute the surface
coour at that position and set
depth%uff=E y> O J
frame%uff=E y> O surfCoour=E y>
'fter a surfaces are processed depth%uffand frame%uff wi store correct "aues
8/18/2019 Graphics14-SurfaceDetectionMethods
26/95
2
of
28C'7CN7'T3< 3* ?
8/18/2019 Graphics14-SurfaceDetectionMethods
27/95
2
of
28C'7CN7'T3< 3* ?
8/18/2019 Graphics14-SurfaceDetectionMethods
28/95
28
of
28Cacuatin) Depth
't any surface position the depth iscacuated from the pane e#uation as:
*or any scan ine ad-acent x positions differ
by QBE as do ad-acent y positions
C
D By Ax z
−−−=
C
D By x A z
−−+−=
)1('
C
A z z −='
8/18/2019 Graphics14-SurfaceDetectionMethods
29/95
2@
of
28terati"e Cacuations
The depth&buffer a)orithm proceeds bystartin) at the top "erte of the poy)on
Then we recursi"ey cacuate the x&
coordinate "aues down a eft ed)e of thepoy)on
The x "aue for the be)innin) position on
each scan ine can be cacuated from thepre"ious one
m x x 1
' −= where m is the sope
8/18/2019 Graphics14-SurfaceDetectionMethods
30/95
(
of
28terati"e Cacuations =cont>
Depth "aues aon) the ed)e bein)considered are cacuated usin)
C
Bm
A
z z
+
−='
8/18/2019 Graphics14-SurfaceDetectionMethods
31/95
(B
of
28terati"e Cacuations =cont>
top scan ine
bottom scan ine
y scan ine
y & B scan ine
x x’
8/18/2019 Graphics14-SurfaceDetectionMethods
32/95
(2
of
28 '&%uffer Method
The '&buffer method is an etension of thedepth&buffer method
The '&buffer method is "isibiity detection
method de"eoped at 7ucasfim Studios forthe renderin) system 5F5S =0enders
."erythin) 1ou ."er Saw>
8/18/2019 Graphics14-SurfaceDetectionMethods
33/95
((
of
28 '&%uffer Method =cont>
The '&buffer epands on the depth buffermethod to aow transparencies
The !ey data structure in the '&buffer is the
accumulation buffer
(+
8/18/2019 Graphics14-SurfaceDetectionMethods
34/95
(+
of
28 '&%uffer Method =cont>
f depth is RO E then the surface data fied
stores the depth of that pie position as
before
f depth P then the data fied stores a
pointer to a in!ed ist of surface data
(0
8/18/2019 Graphics14-SurfaceDetectionMethods
35/95
(0
of
28 '&%uffer Method =cont>
Surface information in the '&buffer incudes: – G% intensity components – 3pacity parameter – Depth
– 6ercent of area co"era)e
– Surface identifier
– 3ther surface renderin) parameters
The a)orithm proceeds -ust i!e the depthbuffer a)orithm
The depth and opacity "aues are used to
determine the fina coour of a pie
(
8/18/2019 Graphics14-SurfaceDetectionMethods
36/95
(
of
28
(
8/18/2019 Graphics14-SurfaceDetectionMethods
37/95
(
of
286'
8/18/2019 Graphics14-SurfaceDetectionMethods
38/95
(8
of
286'
8/18/2019 Graphics14-SurfaceDetectionMethods
39/95
(@
of
286'
8/18/2019 Graphics14-SurfaceDetectionMethods
40/95
+
of
286'
8/18/2019 Graphics14-SurfaceDetectionMethods
41/95
+B
of
286'
8/18/2019 Graphics14-SurfaceDetectionMethods
42/95
+2
of
286'
8/18/2019 Graphics14-SurfaceDetectionMethods
43/95
+(
of
286'
8/18/2019 Graphics14-SurfaceDetectionMethods
44/95
++
of
286'
8/18/2019 Graphics14-SurfaceDetectionMethods
45/95
+0
of
286'
8/18/2019 Graphics14-SurfaceDetectionMethods
46/95
+
of
286'
8/18/2019 Graphics14-SurfaceDetectionMethods
47/95
+
of
28Scan&7ine Method
'n ima)e space method for identifyin)"isibe surfaces
Computes and compares depth "aues
aon) the "arious scan&ines for a scene
+8
8/18/2019 Graphics14-SurfaceDetectionMethods
48/95
+8
of
28Scan&7ine Method =cont>
To faciitate the search for surfaces crossin)a )i"en scan&ine an acti"e ist of ed)es is
formed for each scan&ine as it is processed
The acti"e ist stores ony those ed)es thatcross the scan&ine in order of increasin)
'so a fa) is set for each surface to indicate
whether a position aon) a scan&ine is eitherinside or outside the surface
+@
8/18/2019 Graphics14-SurfaceDetectionMethods
49/95
+@
of
28Scan&7ine Method
0
8/18/2019 Graphics14-SurfaceDetectionMethods
50/95
0
of
28Scan&7ine Method
0B
8/18/2019 Graphics14-SurfaceDetectionMethods
51/95
0B
of
28Scan&7ine Method
02
8/18/2019 Graphics14-SurfaceDetectionMethods
52/95
02
of
28Scan&7ine Method
0(
8/18/2019 Graphics14-SurfaceDetectionMethods
53/95
of
28Scan&7ine Method
0+
8/18/2019 Graphics14-SurfaceDetectionMethods
54/95
of
28Scan&7ine Method =cont>
Two important tabes are maintained: – The ed)e tabe
– The surface facet tabe
The ed)e tabe contains: – Coordinate end points of each ine in the
scene
– The in"erse sope of each ine
– 6ointers into the surface facet tabe to
connect ed)es to surfaces
00
S = >
8/18/2019 Graphics14-SurfaceDetectionMethods
55/95
of
28Scan&7ine Method =cont>
The surface facet tabes contains: – The pane coefficients
– Surface materia properties
–
3ther surface data – Maybe pointers into the ed)e tabe
0
S 7i M h d = >
8/18/2019 Graphics14-SurfaceDetectionMethods
56/95
of
28Scan&7ine Method =cont>
6ie positions across each scan&ine areprocessed from eft to ri)ht
't the eft intersection with a surface the
surface fa) is turned on 't the ri)ht intersection point the fa) is
turned off
We ony need to perform depth cacuationswhen more than one surface has its fa)
turned on at a certain scan&ine position
0
S 7i M th d 5
8/18/2019 Graphics14-SurfaceDetectionMethods
57/95
of
28Scan 7ine Method 5ampe
/ m
a ) e s t a ! e n f r o m 9 e a r n H
% a ! e r E K C o m p u t e r G r a p h i c s w i t h 3 p e n G 7 L = 2 + >
08
S 7i M th d 7i it ti
8/18/2019 Graphics14-SurfaceDetectionMethods
58/95
of
28Scan&7ine Method 7imitations
The scan&ine method runs into troube whensurfaces cut throu)h each other or
otherwise cycicay o"erap
Such surfaces need to be di"ided
/ m
a ) e s t a ! e n f r o m 9 e a r n H
% a ! e r E K C o m p u t e r G r a p h i c s w i t h 3 p e n G 7 L = 2 + >
0@
W'
8/18/2019 Graphics14-SurfaceDetectionMethods
59/95
of
28W'
8/18/2019 Graphics14-SurfaceDetectionMethods
60/95
of
28W'
8/18/2019 Graphics14-SurfaceDetectionMethods
61/95
of
28W'
8/18/2019 Graphics14-SurfaceDetectionMethods
62/95
of
28W'
8/18/2019 Graphics14-SurfaceDetectionMethods
63/95
of
28W'
8/18/2019 Graphics14-SurfaceDetectionMethods
64/95
of
28W'
8/18/2019 Graphics14-SurfaceDetectionMethods
65/95
of
28W'
8/18/2019 Graphics14-SurfaceDetectionMethods
66/95
of
28Summary
We need to ma!e sure that we ony draw"isibe surfaces when renderin) scenes
There are a number of techni#ues for doin)this such as
– %ac! face detection
– Depth&buffer method
– '&buffer method
–
Scan&ine method
8/18/2019 Graphics14-SurfaceDetectionMethods
67/95
of
2877NM
8/18/2019 Graphics14-SurfaceDetectionMethods
68/95
of
287G9T S3NC5S
@
f 7G9T S3NC5S
8/18/2019 Graphics14-SurfaceDetectionMethods
69/95
of
287G9T S3NC5S
fD**NS5 H S65CN7'
8/18/2019 Graphics14-SurfaceDetectionMethods
70/95
of
28 5*75CT3
8/18/2019 Graphics14-SurfaceDetectionMethods
71/95
of
28 'M%5
8/18/2019 Graphics14-SurfaceDetectionMethods
72/95
(
of
8/18/2019 Graphics14-SurfaceDetectionMethods
73/95
of
28
+
of
8/18/2019 Graphics14-SurfaceDetectionMethods
74/95
of
28
0
of
8/18/2019 Graphics14-SurfaceDetectionMethods
75/95
of
28
of
8/18/2019 Graphics14-SurfaceDetectionMethods
76/95
of
28
of
8/18/2019 Graphics14-SurfaceDetectionMethods
77/95
of
28
8
of
8/18/2019 Graphics14-SurfaceDetectionMethods
78/95
of
28
@
of
8/18/2019 Graphics14-SurfaceDetectionMethods
79/95
of
28
8
of
8/18/2019 Graphics14-SurfaceDetectionMethods
80/95
of
28
8B
of
8/18/2019 Graphics14-SurfaceDetectionMethods
81/95
of
28
82
of
8/18/2019 Graphics14-SurfaceDetectionMethods
82/95
of
28
8(
of
8/18/2019 Graphics14-SurfaceDetectionMethods
83/95
of
28
8+
of
8/18/2019 Graphics14-SurfaceDetectionMethods
84/95
of
28
80
of
8/18/2019 Graphics14-SurfaceDetectionMethods
85/95
28
8
of
8/18/2019 Graphics14-SurfaceDetectionMethods
86/95
28
8
of
8/18/2019 Graphics14-SurfaceDetectionMethods
87/95
28
88
of
8/18/2019 Graphics14-SurfaceDetectionMethods
88/95
28
8@
of
8/18/2019 Graphics14-SurfaceDetectionMethods
89/95
28
@
of
8/18/2019 Graphics14-SurfaceDetectionMethods
90/95
28
@B
of
8/18/2019 Graphics14-SurfaceDetectionMethods
91/95
28
@2
of
8/18/2019 Graphics14-SurfaceDetectionMethods
92/95
28
@(
of
8/18/2019 Graphics14-SurfaceDetectionMethods
93/95
28
@+
of
8/18/2019 Graphics14-SurfaceDetectionMethods
94/95
28
@0
of
8/18/2019 Graphics14-SurfaceDetectionMethods
95/95
28