Interpolation

Overview

Depending on the settings in our project, data may not always arrive at a smooth 60 frames per second through the network. This is completely okay, but in order to make state changes (e.g. movement, rotation) appear smooth on the client, we use interpolation.

Interpolation is a type of estimation, a method of constructing new data points within the range of a discrete set of known data points.

The way interpolation works in coherence is that we wait for three data points and then start smoothing the subsequent values according to the interpolation parameters defined in the interpolation settings provided.

Binding Interpolation Settings

In the Configure window, each binding displays its interpolation settings next to it.

Built-in interpolation settings for position and rotation are provided out-of-the-box, but you are free to create your own and use them instead.

You can also create an interpolation settings asset: Assets > Create > coherence > Interpolation Settings

There, you have a few settings you can tweak:

  • Interpolation Type: the type of interpolation used. If set to None, the value will simply snap to the closest sample point without any blending.

  • Smooth Time: additional smoothing can be applied (using SmoothDamp) to clear out any jerky movement after regular interpolation has been performed.

  • Max Smoothing Speed: the maximum speed at which the value can change, unless teleporting.

  • Teleport Distance: if two consecutive samples are further apart than this, the value will "teleport" or snap to the new sample immediately without interpolating or smoothing in between.

  • Latency Control: Auto

    • With Latency Control set to Auto, latency will automatically adapt to the average sample delta time for all samples in the buffer. This allows each binding to operate with minimal latency without having to extrapolate data.

    • Factor: fudge factor applied to the average sample delta time. A factor of 1 means latency is exactly equal to time between samples, so the interpolated value should reach the last sample in the buffer at the exact time when a new sample is expected to arrive.

      • In general, a factor of 1.1 is recommended to keep from running out of samples (due to network fluctuations).

      • For spline interpolation, a factor of at least 2 is recommended, because the spline algorithm requires staying two samples behind to produce smooth curves.

  • Latency Control: Manual

    • With Latency Control set to Manual, latency is fixed so the interpolated value always stays a certain time behind the game time.

    • Latency: seconds the interpolated value will trail being the game time.

  • Overshooting

    • Max: how far into dead reckoning to venture when the time fraction exceeds 100%, as percentage of the sample rate.

    • Retraction: how fast to pull back to 100% when overshooting the allowed dead reckoning maximum (in seconds)

Interpolation works both in baked and reflection modes. You can change these settings at runtime via the Configure window (editor) or accessing the binding and changing the interpolation settings yourself:

if (coherenceSync.TryGetBinding(typeof(Transform), "position", out IBinding binding)
{
    // change your interpolation settings at runtime
    binding.InterpolationSettings = ...
}

Last updated