Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Client/Server Interpolation for Simulations

Client/Server Interpolation for Simulations

Talk at Vienna Dart meetup

Avatar for Markus Ritberger

Markus Ritberger

February 09, 2016

Other Decks in Programming

Transcript

  1. How can we sync a simulation with multiple clients? It

    depends on your goals Number of players? Bandwidth? Latency?
  2. Deterministic Lockstep The Simulation is running both on client and

    server Only player inputs are sent over the wire Simulation has to be deterministic Comparable physic states
  3. Cons Determinism is hard (float inaccuracy) Clients need to do

    physics themselves Gets harder with more players
  4. Snapshot Interpolation Simulation runs only on the server States are

    sent to client Client interpolates and renders state
  5. UDP over TCP No UDP in your browser WebSockets run

    on TCP Maybe in the future with WebRTC For now we forget about UDP, packet-loss and jittering
  6. Interpolation „In the mathematical field of numerical analysis, interpolation is

    a method of constructing new data points within the range of a discrete set of known data points.“ - wikipedia
  7. Cons High bandwidth (introduces snapshot optimization) Needs buffer for jitter

    and bandwidth (latency) We have to send everything that should be visible
  8. State Synchronization Mix of deterministic lockstep and snapshot interpolation Game

    runs on server and client send state and inputs as often as possible No interpolation needed
  9. Pros Updates can be prioritized Bandwidth can be optimized easily

    Minimum added latency Buffer only for jitter not for interpolation
  10. Input prediction Imagine you have to wait until your input

    has been processed by the server Instead of waiting for the server to update your own position, the local client just predicts the results of its own user commands If server returns a different result, a correction must be made
  11. Conclusion Deterministic lockstep for deterministic games with small player count

    (consoles) Snapshot interpolation for robust and easy and maintainable games (Which can afford the extra latency) State synchronization when low bandwidth and low latency is required