Occlusion - Al Hastings, Insomniac Games

Download as pdf or txt
Download as pdf or txt
You are on page 1of 23

Occlusion

Occlusion
Visibility determination for static
Visibility determination for static
and dynamic objects
and dynamic objects
(Al Hastings, Insomniac Games)
(Al Hastings, Insomniac Games)

Static Occlusion
Static Occlusion
Essentially it is an implementation of VS
Essentially it is an implementation of VS
(potentially !isible set) concept
(potentially !isible set) concept
"rom a gi!en camera position, t#e
"rom a gi!en camera position, t#e
occlusion database reports $#ic# objects
occlusion database reports $#ic# objects
are potentially !isible
are potentially !isible
Only $or%s for static objects (ufrag, ties,
Only $or%s for static objects (ufrag, ties,
s#rubs, foliage, etc)
s#rubs, foliage, etc)
&#e run'time is simple ( all t#e comple)ity
&#e run'time is simple ( all t#e comple)ity
comes in generating t#e database
comes in generating t#e database

*ynamic Occlusion
*ynamic Occlusion
Implemented using t#e +S, #ard$are pi)el
Implemented using t#e +S, #ard$are pi)el
counters
counters
-sed for dynamic objects (mobys, real'time
-sed for dynamic objects (mobys, real'time
lig#ts and particle effects)
lig#ts and particle effects)
Visibility determination is computed based on
Visibility determination is computed based on
bounding !olumes (sp#eres, cones, AA..s) and
bounding !olumes (sp#eres, cones, AA..s) and
not on t#e actual geometry
not on t#e actual geometry
&#ere is a one frame lag ( t#e - uses t#e
&#ere is a one frame lag ( t#e - uses t#e
results t#at t#e +S, computed on t#e pre!ious
results t#at t#e +S, computed on t#e pre!ious
frame/ &#is leads to complications/
frame/ &#is leads to complications/

Static Occlusion ipeline
Static Occlusion ipeline
0) aint grids $#ere t#e camera can go
0) aint grids $#ere t#e camera can go
1) Auto'generate sample points from grids
1) Auto'generate sample points from grids
2) +un ps2 utility to determine !isibility
2) +un ps2 utility to determine !isibility
3) Group objects into 1435 6clusters7
3) Group objects into 1435 6clusters7
8) 9ompress t#e !isibility database
8) 9ompress t#e !isibility database
:) ;atc# up t#e database to t#e latest
:) ;atc# up t#e database to t#e latest
assets in t#e le!el
assets in t#e le!el

ainting t#e grids
ainting t#e grids
Grids are uniform and non'#ierarc#ical Grids are uniform and non'#ierarc#ical
-sually 1m on a side, sometimes larger -sually 1m on a side, sometimes larger
&ypically 14,444 ( 044,444 on a le!el &ypically 14,444 ( 044,444 on a le!el
ainting is done in'game by running around $it# t#e ainting is done in'game by running around $it# t#e
c#aracter/ c#aracter/
It<s a !ery manual process ( it can ta%e a day or more to It<s a !ery manual process ( it can ta%e a day or more to
populate a large le!el $it# grids/ And t#ere is ongoing populate a large le!el $it# grids/ And t#ere is ongoing
maintenance $or% as t#e le!el c#anges/ maintenance $or% as t#e le!el c#anges/
.ut t#e manual process #as some ad!antages= .ut t#e manual process #as some ad!antages=

Adaptable to any type of gameplay Adaptable to any type of gameplay

If t#ere<s a problem $it# t#e grids, it<s easy to find and easy to If t#ere<s a problem $it# t#e grids, it<s easy to find and easy to
fi)/ fi)/


Generating t#e sample points
Generating t#e sample points
Automated process on ps2 t#at runs $#ene!er
Automated process on ps2 t#at runs $#ene!er
t#e grids are edited/
t#e grids are edited/
-ses run'time collision tests to (try to) a!oid
-ses run'time collision tests to (try to) a!oid
putting samples inside geometry ($#ic# can lean
putting samples inside geometry ($#ic# can lean
to a lot of o!er'inclusion)
to a lot of o!er'inclusion)
+elies on t#e collision geometry being a close
+elies on t#e collision geometry being a close
matc# to t#e render geometry/
matc# to t#e render geometry/
Attempts to place samples at t#e corners of
Attempts to place samples at t#e corners of
eac# grid, or as close as t#e collision $ill allo$/
eac# grid, or as close as t#e collision $ill allo$/
&ypically a le!el ends up $it# 0/8) more sample
&ypically a le!el ends up $it# 0/8) more sample
points t#an grids/
points t#an grids/



*etermining Visibility
*etermining Visibility
&#is is done using a ps2 stand'alone app called
&#is is done using a ps2 stand'alone app called
>occlgen</
>occlgen</
E!entually $e could mo!e t#is bac% to run on a
E!entually $e could mo!e t#is bac% to run on a
9/ Speed is a toss'up currently/
9/ Speed is a toss'up currently/
: renders are done for eac# sample point to get
: renders are done for eac# sample point to get
2:4
2:4
? !isibility/
? !isibility/
@arge le!els can reAuire up$ards of a #alf
@arge le!els can reAuire up$ards of a #alf
million renders/ &#is process could ta%e as long
million renders/ &#is process could ta%e as long
as 04 #ours on +esistance/
as 04 #ours on +esistance/
End result is a bit'!ector for eac# grid indicating
End result is a bit'!ector for eac# grid indicating
$#ic# objects are !isible/ &#is data can be
$#ic# objects are !isible/ &#is data can be
se!eral #undred ;egs/
se!eral #undred ;egs/


Grouping objects into >clusters<
Grouping objects into >clusters<
rocessing mo!es bac% to t#e 9 no$
rocessing mo!es bac% to t#e 9 no$
1435 clusters on a le!el/ &ypically 3'5 objects in
1435 clusters on a le!el/ &ypically 3'5 objects in
a cluster/
a cluster/
9lusters are formed from objects t#at are !isible
9lusters are formed from objects t#at are !isible
from similar sets of grids/ &#is introduces less
from similar sets of grids/ &#is introduces less
error t#an basing t#e groupings on spatial
error t#an basing t#e groupings on spatial
pro)imity/
pro)imity/
&#is stage can ta%e se!eral more #ours (uses a
&#is stage can ta%e se!eral more #ours (uses a
brute'force algorit#m $#ic# could be impro!ed)
brute'force algorit#m $#ic# could be impro!ed)
9lustering introduces o!er'inclusion error
9lustering introduces o!er'inclusion error
(typically 04B to 14B, but $orse on larger
(typically 04B to 14B, but $orse on larger
le!els)
le!els)

9ompressing t#e database
9ompressing t#e database
At run'time, eac# grid stores a 18:'byte array
At run'time, eac# grid stores a 18:'byte array
indicating t#e onCoff !isibility for eac# of t#e 1435
indicating t#e onCoff !isibility for eac# of t#e 1435
clusters
clusters
"urt#er compression is done by combining grids
"urt#er compression is done by combining grids
$it# !ery similar !isibility lists/
$it# !ery similar !isibility lists/
&#is stage can ta%e up to an #our of processing
&#is stage can ta%e up to an #our of processing
&#is also introduces o!er'inclusion error/
&#is also introduces o!er'inclusion error/
&ypically it adds less error t#an clustering/
&ypically it adds less error t#an clustering/
+un'time budget for occlusion data is 1 ;egs/
+un'time budget for occlusion data is 1 ;egs/

Syncing t#e database
Syncing t#e database
Visibility is re'computed once per day at most/
Visibility is re'computed once per day at most/
.ut t#e le!el art c#anges muc# more Auic%ly/
.ut t#e le!el art c#anges muc# more Auic%ly/
Occlusion data s#ould decay gracefully as t#e
Occlusion data s#ould decay gracefully as t#e
art c#anges/ .ut in t#e past t#is is t#e stage t#at
art c#anges/ .ut in t#e past t#is is t#e stage t#at
#as pro!en most problematic/
#as pro!en most problematic/
In principle, adding or mo!ing an object $ill only
In principle, adding or mo!ing an object $ill only
in!alidate occlusion on t#at object $#ile %eeping
in!alidate occlusion on t#at object $#ile %eeping
it intact on t#e rest of t#e le!el/
it intact on t#e rest of t#e le!el/
&#e ne$ tools s#ould ma%e t#is more robust
&#e ne$ tools s#ould ma%e t#is more robust
because $e no$ #a!e proper -I*s for eac#
because $e no$ #a!e proper -I*s for eac#
object/
object/

D#at<s good about it
D#at<s good about it
Very fast to Auery at run'time ( almost free
Very fast to Auery at run'time ( almost free
+elati!ely lo$ memory footprint
+elati!ely lo$ memory footprint
*oesn<t impose any restrictions on le!el
*oesn<t impose any restrictions on le!el
construction tec#niAues
construction tec#niAues

D#at<s bad about it
D#at<s bad about it
@abor intensi!e and time intensi!e process
@abor intensi!e and time intensi!e process
Hard to %eep it up'to'date during
Hard to %eep it up'to'date during
production
production
9an<t #andle mo!ing geometry, deforming
9an<t #andle mo!ing geometry, deforming
geometry, destructible geometry
geometry, destructible geometry
Suffers from some o!er'inclusion (large
Suffers from some o!er'inclusion (large
ties are t#e biggest problem, compression
ties are t#e biggest problem, compression
error is a secondary problem)
error is a secondary problem)
;onolit#ic database (#ard to stream, etc)
;onolit#ic database (#ard to stream, etc)

*ynamic Occlusion
*ynamic Occlusion
Eo pre'computed data is in!ol!ed/
Eo pre'computed data is in!ol!ed/
otentially !isible objects render a
otentially !isible objects render a
bounding !olume t#en c#ec% on t#e ne)t
bounding !olume t#en c#ec% on t#e ne)t
frame if any pi)els $ere !isible/
frame if any pi)els $ere !isible/
&#ings t#at use dynamic occlusion=
&#ings t#at use dynamic occlusion=

;obys
;obys

+eal'time @ig#ts
+eal'time @ig#ts

Effects
Effects


roblems caused by one'frame lag
roblems caused by one'frame lag
It<s possible to see a one'frame dropout
It<s possible to see a one'frame dropout
$#en an on'screen object becomes un'
$#en an on'screen object becomes un'
occluded/
occluded/
Special'case code is reAuired to #andle
Special'case code is reAuired to #andle
camera cuts, mode transitions, etc/
camera cuts, mode transitions, etc/
On'screen, occluded objects need to re'
On'screen, occluded objects need to re'
test t#eir !isibility e!ery frame/
test t#eir !isibility e!ery frame/

D#at<s good about it
D#at<s good about it
+elati!ely lig#t$eig#t system (rendering
+elati!ely lig#t$eig#t system (rendering
t#e bounding !olumes usually ta%es a
t#e bounding !olumes usually ta%es a
fraction of a millisecond)
fraction of a millisecond)
Dor%s $it# any le!el design
Dor%s $it# any le!el design
&ypically it manages to cull t#at !ast
&ypically it manages to cull t#at !ast
majority of objects t#at s#ould be culled/
majority of objects t#at s#ould be culled/

D#at<s bad about it
D#at<s bad about it
.asing occlusion on bounding !olume
.asing occlusion on bounding !olume
!isibility $or%s poorly for some objects
!isibility $or%s poorly for some objects
(long, t#in mobys in particular)
(long, t#in mobys in particular)
One frame lag issues
One frame lag issues
Visibility spi%es can occur after camera
Visibility spi%es can occur after camera
cuts and mode transitions
cuts and mode transitions

"uture Dor%
"uture Dor%
E)plore using +S, conditional rendering
E)plore using +S, conditional rendering
to remo!e one'frame lag in certain
to remo!e one'frame lag in certain
situations/
situations/
E)tend system to $or% $ell for large'scale
E)tend system to $or% $ell for large'scale
mo!ing objects (use actual geometry for
mo!ing objects (use actual geometry for
!isibility test instead of bounding !olume)
!isibility test instead of bounding !olume)
A!oid !isibility spi%es $it# better #andling
A!oid !isibility spi%es $it# better #andling
of mode transitions and camera cuts
of mode transitions and camera cuts

FuestionsG
FuestionsG

You might also like