Dead reckoning and smoothing

advertisement
Dead Reckoning
References:
Gamasutra (1), Gamedev (1)
Forum articles (1)
Introduction
Fast-paced interaction in twitch games
Players expect the level of performance
of distributed games to approximate
that of single computer/player game
Solution: dedicated network (end-toend latency 150-200 ms)
Fall 2012
2
Dead Reckoning
From DIS (distributed interactive simulation)
protocol of SIMNET project, DoD, USA


Was for networking tank simulators
Objectives: latency hiding, bandwidth reduction
Basic Ideas:


Fall 2012
Agree in advance on a set of algorithms that can
be used by all players to extrapolate the behavior
of entities
Update threshold: how far reality should be
allowed to get from these extrapolations before a
correction is issued
3
Dead Reckoning
If the motion is still within the
DR threshold (on Owner),
no updates required.
Positiont1  Positiont0
[point-to-point]
Positiont1  Positiont0  vt1  t0 
[linear]
1
t1  t0 2
Position t1  Position t0  vt1  t0  
2a
Fall 2012
[quadratic]
4
DR Algorithm (point-to-point)
New packet [p]
New packet [p]
No path
Noticeably jerky unless one
packet is received per frame
Fall 2012
5
DR Algorithm (linear)
moves along
this v,
until …
New packet [p,v]
Path does not consider
change of velocity
Fall 2012
6
DR Algorithm (quadratic)
moves along
this v and a,
until …
New packet [p,v,a]
NewPosition = OldPosition + Velocity*time + 0.5*Acceleration*(time)2
Path does not consider
change of acceleration – jerk
Fall 2012
7
PDU (protocol data unit)
Data packet representing each entity



Kinematic state: position, velocity,
acceleration, orientation
Other info: damage level, turret …
Which dead reckoning algorithm to use
Threshold: jerkiness vs. more PDUs to
be sent
Fall 2012
8
Smoothing
Jerkiness: due to sudden update of
position
Use smoothing algorithm to lessen the
apparent jerkiness [more later]
Fall 2012
9
Extension
Predictive Contract


State-based, rather than kinematic-based
State: “drive along road to waypoint”
 If the definition of roads, the specific waypoint,
the way of driving (right-side), … are known to
all players, the vehicle could be computed w/o
any network traffic

Fall 2012
Others: “turn on/off the sensors”, “send
out radio report”
10
Summary
Dead reckoning is not free: every
computer runs an algorithm to
extrapolate each entity
Trade processor cycles to reduced
network use and apparent latency
If all entities behave unpredictably all
the time, DR offers little gain
Fall 2012
11
DR Smoothing with Cubic Splines (ref)
Jerkiness is due to the sudden update of position
The following method ensures smooth positional
transition while ensuring accuracy by packet (server)
updates
Only cubic (parametric) curve can represent R3 curve
[quadratic curves are planar]
Hermite curves are most common. Two points and
their corresponding tangents need to be specified (by
quadratic kinematics laws)
Fall 2012
12
A Draftsman’s Spline
Fall 2012
13
Math of Hermite Curves
h1(s) = 2s33s2 + 1
h2(s) = 2s3 + 3s2
h3(s) = s3  2s2 + s
h4(s) = s3  s2
P(s) = P1h1(s) + P2h2(s) + T1h3(s) + T2h4(s)
P’(s)=P1h1’(s) + P2h2’(s) + T1h3’(s) + T2h4’(s)
h1’ = 6s2  6s h2’ = 6s2+6s h3’= 3s2  4s+1 h4’=
3s2 – 2s
Note: end tangent vectors are dP/ds
Fall 2012
14
Reparameterization
If theparameteris t (time):
t
dt
s
ds 
T
T
p(t )  P( s (t ))
dp(t ) dP( s ) ds dP( s ) 1
dp(t ) dP( s ) ds
velocit
y




dt
ds dt
ds T
dt
ds dt
dP
dp

(1)  T
(T )
ds
dt
s=1
t=T
Fall 2012
s=0
t=0
dP
dp

( 0)  T
( 0)
ds
dt
15
Algorithm
When a packet [p,v,a] arrives, begin creating
a cubic spline for next position

Approximate (extrapolate) the [p,v] after time T
A piece of Hermite curve is defined by two
end points and two end tangents




Fall 2012
P1: current position
T1: (scaled) current velocity
P2: extrapolated position after T
T: estimated interval
T2: (scaled) velocity after T
between packets
16
Details
Move with current spline
P2
T2
The position gradually changes
from P1 (s=0) to P2 (s=1, t=T)
T1
P1
New packet [p,v,a]
Start a new spline by
1. Current [p,v]
2. New [p,v] computed by
[p,v,a] after time T
Fall 2012
17
Download