Advertisement

Delta Compression Precision

Started by December 30, 2022 03:47 AM
1 comment, last by frob 1 year, 11 months ago

So I'm writing a delta compression mechanism for my game, and I had a few questions.

1.) Suppose we're compressing floating points and doing the usual thing. Rounding to nth decimal place, quantizing to that decimal place, bit packing, and sending to client. So our normal 32 bit float (example: 1.4839284) becomes 1.48 and then 148 when quantized. All good here. HOWEVER, if our float starts incrementing very slowly for whatever reason, suppose in increments of +- 0.0003, that's far beyond our 2 decimal precision limit and the client isn't going to be receiving those updates. Is there a way to counter this other than raising the precision?

2.) Not related to the previous question. This is just an “in general delta compression" question. Since we're losing some precision no matter what, should the server always resend the full state to each client periodically every few minutes? To prevent values from drifting?

Edit: Or rather the server should probably accumulate the compressed values somewhere for each player, so that it knows exactly what values the client has, and can calculate the drift and the need for full state updates?

Unreal does similar to what you described.

You can mark a member variable as getting replicated or not. Two decimal digits by default, and you can configure it for any object with a custom encoder. You can use existing NetQuantize10() and NetQuantize100() to save one or two digits, or other functions you provide for different encoding however you need.

It also tracks the difference between servers and clients to help prioritize update frequency. By default priority is based on visibility and distance along with how stale data has become. Priority is adjustable. Since each client has its own view the server has a little overhead, but it works well for bandwidth management and also to reduce client cheats.

Advertisement

2) There's an easy way to make sure there's no drift over time. The server should keep track of the reconstructed value as seen from the client, and always generate deltas from that value.

If this is not clear enough, ask and I'll clarify.

@alvaro Thanks for the reply ?

Yesterday I wrote an edit under #2 and I think that's what I said.

This website is pretty slow for me, so maybe the edit isn't showing up for other people.

This topic is closed to new replies.

Advertisement