![Page 1: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/1.jpg)
Fall 2006 revised 1
Frustum Culling in OpenGL
Ref: MarkMoley.com
![Page 2: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/2.jpg)
Fall 2006 revised 2
Culling Techniques
![Page 3: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/3.jpg)
Fall 2006 revised 3
Outline
Introduction View Frustum Plane Equation
Frustum Plane ExtractionFrustum/Point/Sphere Inclusion Tests
![Page 4: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/4.jpg)
Fall 2006 revised 4
Definition (View Frustum)
the volume of space that includes everything visible from a given viewpointdefined by six planes arranged in the shape of a pyramid with the top chopped offIf a point is inside this volume then it's in the frustum and it's visible, and vice versa Visible here mean potentially visible. It might be
behind another point that obscures it, but it's still in the frustum. … the scope of occlusion culling
![Page 5: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/5.jpg)
Fall 2006 revised 5
View Frustum (cont)
![Page 6: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/6.jpg)
Fall 2006 revised 6
Definition (Plane)
Divide the space into two halves; extends to infinityany given point is (in front of | behind | on) the plane. In R3, a plane is defined by four numbers: A plane equation: Ax + By + Cz +D =
0
![Page 7: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/7.jpg)
Fall 2006 revised 7
Plane Equation
normal behind is ),,( if0
on is ),,( if0
side normalon is ),,( if0
: vectornormal
to),,( from distance
0:
000
000
000
222
000
000
zyx
zyx
zyx
d
CBA
CBA
DCzByAxd
zyxSigned
DCzByAx
T
![Page 8: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/8.jpg)
Fall 2006 revised 8
Normalized Plane Equation
D
DCzByAxd
zyxSigned
CBACBA
DCzByAxT
:origin todistance Signed
to),,( from distance
1, : vectornormal
0:
000
000
222
![Page 9: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/9.jpg)
Fall 2006 revised 9
Frustum Culling
Idea: If object is not in frustum, do not send it
through pipeline (it is not visible) Wrap the object in a bounding volume; test
the bounding volume against frustum (in world coordinate system) Sphere, bounding boxes, …
Tasks: Frustum plane extraction Inclusion tests for different bounding
volumes
![Page 10: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/10.jpg)
Fall 2006 revised 10
Frustum Plane Extraction
The rendering pipeline:
PMst
s
coordinate device normalized :u
coordinateobject :
matrix viewmodel :
matrix projection:
M
P
PMs ut
In frustum culling, s is usually a point on BV, in world coordinate
In frustum culling, s is usually a point on BV, in world coordinate
![Page 11: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/11.jpg)
Fall 2006 revised 11
Rendering Pipeline (cont)
Tzyx
T
tt
t
t
tt
w
z
y
x
w
z
y
x
Twzyx
uuu
s
s
s
s
cccc
cccc
cccc
cccc
t
t
t
t
sssss
w
z
w
y
w
x
:coordinate Clip
:coordinateObject
151173
141062
13951
12840
PMs ut
In OpenGL,clip volume is [-
1,1]3
c : product of
PM
![Page 12: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/12.jpg)
Fall 2006 revised 12
Frustum Plane Extraction (Left)
00
11
wxxww
w
xx
ttttt
t
tu
w
z
y
x
w
z
y
x
s
s
s
s
cccc
cccc
cccc
cccc
t
t
t
t
151173
141062
13951
12840 ux
uy
-1 1
Left Cic
sccscscth
i in row theis where
00
,
,3,0,3,0
![Page 13: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/13.jpg)
Fall 2006 revised 13
Left Plane (cont)The left plane in clip coordinate:
The corresponding equation in world coordinate:
0
010
equation esatisfy th that 1
15121187430
,3,0,3,0
cczccyccxcc
zyxccscc
zyxsallT
xu 1 ux
uy
-1 1
Left
151173
141062
13951
12840
cccc
cccc
cccc
cccc
C
![Page 14: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/14.jpg)
Fall 2006 revised 14
Frustum Plane Extraction (Right)
00
11
xwwxw
w
xx
ttttt
t
tu
ux
uy
-1 1
Right Cin row theis where
00
,
,0,3,0,3
thi ic
sccscsc
w
z
y
x
w
z
y
x
s
s
s
s
cccc
cccc
cccc
cccc
t
t
t
t
151173
141062
13951
12840
![Page 15: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/15.jpg)
Fall 2006 revised 15
Right Plane (cont)
The right plane in clip coordinate:
The corresponding equation in world coordinate:
1xu ux
uy
-1 1
Right
0
010
equation esatisfy th that 1
12158114703
,0,3,0,3
cczccyccxcc
zyxccscc
zyxsallT
![Page 16: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/16.jpg)
Fall 2006 revised 16
Summary [far] 0
[near] 0
[top] 0
[bottom] 0
[right] 0
[left] 0
141510116723
141510116723
13159115713
13159115713
12158114703
12158114703
ccxccyccxcc
ccxccyccxcc
ccxccyccxcc
ccxccyccxcc
ccxccyccxcc
ccxccyccxcc
MV][[Proj]
151173
141062
13951
12840
cccc
cccc
cccc
cccc
C
![Page 17: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/17.jpg)
Fall 2006 revised 17
PointInFrustum Test
A point in frustumin all 6 halfspaces
The valid sides of all halfspaces
are > 0
![Page 18: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/18.jpg)
Fall 2006 revised 18
SphereInFrustum Test
p p
PointInOffsetFrustum Test
Minkowski sum of sphere and frustum
Minkowski sum of sphere and frustum
![Page 19: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/19.jpg)
Fall 2006 revised 19
Minkowski Sum Coordinate
dependent!
![Page 20: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/20.jpg)
Fall 2006 revised 20
Signed Distance to Left Plane
Plane equations are further normalized to facilitate distance computation
ux
uy
-1 1
Left
frustum outside ispoint if 0
frustum[3]frustum[2]frustum[1]frustum[0]),,( 000000
d
zyxzyxd
d<0
![Page 21: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/21.jpg)
Fall 2006 revised 21
Remarks
Use bounding spheres Can be conservative if the object is
slender
Use hierarchical bounding volume where appropriate (see next page)BoxInFrustum: complicated and expensive AABB: already so OBB: more so
![Page 22: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/22.jpg)
Fall 2006 revised 22
How can bounding volume hierarchies help?
View-frustum culling
Ray-tracing
Collision detection
![Page 23: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/23.jpg)
Fall 2006 revised 23
View-frustum culling
Ray-tracing
Collision detection
How can bounding volume hierarchies help?
![Page 24: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/24.jpg)
Fall 2006 revised 24
How can bounding volume hierarchies help?
View-frustum culling
Ray-tracing
Collision detection
![Page 25: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/25.jpg)
Fall 2006 revised 25
How can bounding volume hierarchies help?
View-frustum culling
Ray-tracing
Collision detection
![Page 26: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/26.jpg)
Fall 2006 revised 26
Example (Culling Off: FPS 15.5)
![Page 27: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/27.jpg)
Fall 2006 revised 27
Example (Culling On: FPS 31.0)
![Page 28: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/28.jpg)
Fall 2006 revised 28
Epilogue
Portal renderingWorld coordinates?!Plane representation in R3
![Page 29: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/29.jpg)
Fall 2006 revised 29
Indoor Scenes
Similar to building walkthroughOcclusions in scene are common (culling important)Geometric database can be huge; preprocessing is required to facilitate smooth viewing
![Page 30: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/30.jpg)
Fall 2006 revised 30
Preprocessing for Indoor Scenes
Potential visible set (PVS) only load the rooms that are visible from the
current room
![Page 31: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/31.jpg)
Fall 2006 revised 31
M
RK
L
Ki
B
C
E1
23
4
5
6
7
8
M
R
B
C
L
K
E
Ki
1
6
2
3
4
5
7
8
Portal RenderingPortal Rendering
![Page 32: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/32.jpg)
Fall 2006 revised 32
Portal Rendering
only render the other rooms in PVS if the “portal surfaces” are in sight
![Page 33: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/33.jpg)
Fall 2006 revised 33
Earlier, we said…
PMst
s
coordinate clip :u
coordinate world:
PMs ut
But aren’t s local
coordinates?
![Page 34: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/34.jpg)
Fall 2006 revised 34
Recall Pipeline…
Model Transform
Viewing Transform
ModelviewMatrix
worldcoordinates
![Page 35: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/35.jpg)
Fall 2006 revised 35
Frustum Culling Scenario
the scene is (mostly) static and specified in their world coordinate (the modeling transform is identity)
the viewer navigates around them, changing the viewing transform only
![Page 36: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/36.jpg)
Fall 2006 revised 36
Therefore …
Model Transform
Viewing Transform
ModelviewMatrix
worldcoordinates
I
s
t u
t = PMs M : viewing transform s : world coordinate
![Page 37: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/37.jpg)
Fall 2006 revised 37
VerificationL R
X
Z
x–z+10 –x–z+10
![Page 38: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/38.jpg)
Fall 2006 revised 38
Supplement: Representing a Plane in R3
Rdcdc
z
y
x
zyx
bAx
zyx
,,
1
0
1
0
1
1
0
solution space null
ofsolution Complete
02
Rdcdc
z
y
x
z
y
x
,,
1
0
1
0
1
1
0
0
2
solution complete
0
0
2
solution particular
x: pivot variable
![Page 39: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/39.jpg)
Fall 2006 revised 39
Plane in R3 (cont)
0
1
1
1
,
0
0
2
,,
1
0
1
0
1
1
0
0
2
solution complete
02
npxnp
Rdcdc
z
y
x
zyx
p
n
x
![Page 40: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/40.jpg)
Fall 2006 revised 40
Summary
Algebraic equationParametric equationVector equationDepending on the application, select the most suitable equation In/out test Projection …
![Page 41: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/41.jpg)
Fall 2006 revised 41
Screen-Space Bounding Box (SSBB)
Compute and display the screen-space bounding box of an AABB (axis-aligned bounding box)Convert world coordinates to clip coordinates, perspective-divide to get normalized device coordinate (and then window coordinates)
Useful in GPU-assisted collision detection applications
![Page 42: Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com](https://reader036.vdocument.in/reader036/viewer/2022062320/56649d825503460f94a6791e/html5/thumbnails/42.jpg)
Fall 2006 revised 42
Display Viewing Frustum
Useful for projective texturing (showing where the projector is)Useful for illustrating frustum cullingGiven [-1,1]3 clip coordinates, determine their corresponding world coordinates to render