Hermite splines in networked games
A brief introduction to hiding network latency in multiplayer games using cubic Hermite splines and interpolation.
Splines are curves consisting of piecewise polynomials. They are defined by a set of control points and they are useful in multiplayer games for smoothing out movement of players.
When a game client receives player positions over the network, they represent the state of the game as it was at the time of sending1. Due to network latency, those positions are samples of player positions in the past.
It would be prohibitively costly, in terms of bandwidth, to send player positions with a very high frequency. Thus the client is destined to only receive player positions at sparse intervals. To improve gameplay, the client may predict the next position of players, but ultimately it has to move the players to the new correct positions when data arrives.
This is a fundamental problem of latency: The client has to correct the positions upon receiving data. If done poorly, we end up with corrections that “snap” the players to their new positions. As game developers, we are faced with the callenge of hiding these artefacts.
Before tackling splines, let’s first consider how linear interpolation could be used. The naïve approach is to move the player towards the latest known position. That is, interpolate between the current position and the latest known data point from the server.

The linear interpolation in figure 1 is undesirable. Even if the server would send positions with a high frequencey, the player would appear to stutter and move unnaturally.
Networks tend to transmit data with varying speed; packets may get dropped and bandwidth can be congested. It’s therefore better to keep moving the player even when we don’t have the next confirmed position from the server. This is referred to as dead reckoning2 in engineering litterature. The server will have to send player velocities along with the positions.

In figure 2 we can see dead reckoning incorporated into the mix. The player appears to be moving without interruption, which is both more realistic and visually pleasing.
This treatment of positions and velocities is an improvement from our first attempt. It can be enough for top-down games, where players and objects have limited changes to velocity. However, there’s a visible jank every time the velocity changes.
Looking at figure 2, it is still evident that the player’s position is interpolated. The movement is far from natural. In games with acceleration, such as gravity or the movement of a car, we’ll need something more realistic. We want trajectories and we’ll get those with curves.
Spline interpolation, and especially Cubic Hermite Splines suit this problem well.
Linear interpolation refresher
In order to derive the equations for splines, let us first consider lines in parametric form:
In matrix form, a line is defined by the coefficients , and a power basis. The power basis for a :th degree polynomial are the monomials .
In parametric form it’s trivial to generate points on the curve; hence it’s commonly used for trajectories. Exactly what we need.
We can express linear interpolation between two points , in parametric form as
where is the interpolation parameter. Note how the interpolation is defined in terms of our points and . We can consider these to be the control points for our linear interpolation. Although trivial, this connection is insightful for understanding splines in matrix form later.
With higher degree3 polynomials, we get curves. A common choice is the cubic curve, defined in parametric form as
Here a problem emerges: how should we define an interpolation curve between two points?
For linear interpolation, with a first degree polynomial, the solution is unique. There’s only one possible shortest path from to . With curves, however, we lose the unique solution. There are many curves between two points.
To get a unique solution, we need to add constraints.
Continuity and other constraints
A cubic curve is uniquely defined by four points (a quadratic curve requires three)4. On the other hand, it is also uniquely defined by two points and the first derivatives at those points. This is the rationale for spline continuity.

Splines, recall, are piecewise polynomials. Their typical use is to define a curve over a set of control points. Since they are piecewise defined, it’s useful to consider how segments of the spline are joined together. This is defined by continuity constraints at the bounds.
The most common families of continuity constraints are parametric and geometric continuity5.
Parametric continuity, or continuity, means that the :th derivative is continuous. It is only applicable to parametric curves, which is why we insisted on using the parametric form in the previous section. For example, continuity means that the “zeroth” derivative, the value of , matches at the join6.
Geometric continuity, on the other hand, is a measure of smoothness. Zeroth-order geometric continuity is the same as continuity, but for higher the definitions differ5. We won’t consider geometric continuity for now.
What set of constraints to apply, is ultimately determined by the use case. We want to sync player positions and interpolate between those. Smooth transitions in position and velocity is what we were lacking in linear interpolation.
With that in mind, we turn to Hermite splines, which enforce continuity. This is applicable for moving players without snapping (0th derivative, i.e. position) and adjusting their velocity (1st derivative of position) smoothly.
We’ll define the splines in terms of positions and velocities.
Cubic Hermite splines in matrix form
We use splines to define an interpolation curve interpolating known player positions. If we have more than two positions to interpolate through, we’ll define the spline piecewise for each pair.
The decomposition of linear interpolation in directs us to the general matrix form. A spline in general matrix form may be written as
where (geometry) is a matrix of the control points, is the spline basis or blending functions and is the power basis.
Different families of splines can be obtained by choosing the spline basis accordingly. We won’t discuss the derivation of spline basis’ here, but they are widely documented7,8.
Instead, we’ll jump directly to Cubic Hermite splines. For two control points , and two tangents , , the spline is given by9
The tangents , correspond to the velocities at each of the positions and . You should see a resemblence between this matrix form spline and the linear interpolation in equation .
This composition is useful, since the server is sending player positions and velocities to the client. By substituting those for the constants in the geometry matrix , we obtain a smooth curve from one position to the next.
Furthermore, since and don’t depend on , so they can be precomputed for the interpolation steps. This is relevant for interpolating a large number of players or objects.

Figure figure 2, shows the spline interpolation in effect. It is pleasing to watch.
In networked games, player positions are sent with regular intervals. Servers run calculations at a constant rate, colloquially known as the tick rate.
For the purpose of this article, we’ll assume the server sends a message every tick – though this need not be the case for all games.
Messages from the server could contain data for the latest tick, or data for the last ticks. The client should then use the data to interpolate position and velocity, and continue with dead reckoning. Dead reckoning can be thought of as a form of prediction.
The drawback with dead reckoning is that the position may overshoot, and interpolation will move the character backwards.
To fix this, more advanced prediction models are used. These may estimating message arrival times, take into account level geometry, and incorporate inputs to improve the result. Client side movement, which can also be thought of as prediction, is often used to make a player’s controls feel snappy.
Relation to other splines
Besides Hermite splines, there are many other kinds of splines. Their main differences lie in their constraints and how the control points influence the curve.
Splines can easily be converted from one form to another by a change of basis and control points. This works as long as the degrees for the two kinds of splines match. For example, we could convert cubic Hermite splines to cubic B-splines8.
Recall the general matrix for for a spline shown in equation . To convert from a basis to another basis , we’ll use the rules for matrix inverses.
Thus, we obtain the new control points , corresponding to the new basis, by multiplying the old control points with .
Splines are quite fun, so consider implementing or playing around with them. A great starting point is this interactive spline playground I found on the web.
-
We’re considering server-authoritative games here. ↩
-
Dead reckoning on Wikipedia. ↩
-
The degree of a polynomial corresponds with the highest exponent that is non-zero. The order of a polynomial is a loaded term with varying definitions. ↩
-
Advanced Engineering Mathematics, 8th Edition, ISBN 047133328-X, by Kreyzig E. ↩
-
Course notes for CS184: Foundations of Computer Graphics at UC Berkeley, 1998. ↩ ↩2
-
Course notes for CPSC 4050 / 6050 Computer Graphics at Clemson University, 2004. ↩
-
Charles Hermite on Wikipedia. ↩
-
Cubic B-Splines on Wikipedia. ↩ ↩2
-
The order of the points, control points, as well as matrices varies throughout literature. ↩