Commit 2ea75a3
authored
fix: Lerp smoothing frame rate dependence and freeze at maximum interpolation time (#4130)
* fix: Lerp smoothing frame rate dependence and freeze at maximum interpolation time
The lerp smoothing pass used by the Lerp and SmoothDampening interpolation
types applied a fixed factor of 1.0 minus the maximum interpolation time once
per frame, with no delta time. The wall clock smoothing rate therefore scaled
with the frame rate, so the same setting smoothed by different amounts on
different hardware. The factor is now raised to the number of 60fps reference
frames elapsed, which makes the rate a function of elapsed time. Results at
60fps are unchanged for every legal setting.
Separately, a maximum interpolation time of 1.0 (the upper bound of the
inspector range) produced a factor of exactly 0, so the interpolated value
never advanced and the transform stopped moving entirely on all three axes.
The retained portion is now clamped just below 1.0. This is an independent
defect, as raising 1.0 to any power is still 1.0.
The LegacyLerp path was already frame rate correct and is unchanged. The
documentation on the lerp smoothing fields described the LegacyLerp formula
for all interpolation types and has been corrected.
* update
updating the PR number.
* fix: Only substitute the retention limit at a maximum interpolation time of 1.0
Clamping to k_MaximumLerpSmoothRetention flattened everything above it, so
0.995 smoothed at the same rate as 0.99 and stopped honoring "higher is
smoother". Clamp to the legal range first and substitute only at the
freezing endpoint.
Also corrects the lerp smoothing remarks: LegacyLerp still applies
deltaTime / MaximumInterpolationTime per frame, so the frame rate
independence claim only holds for Lerp and SmoothDampening.1 parent 11f5776 commit 2ea75a3
4 files changed
Lines changed: 153 additions & 10 deletions
File tree
- com.unity.netcode.gameobjects
- Runtime/Components
- Interpolator
- Tests/Editor
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
| 26 | + | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| |||
Lines changed: 36 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
212 | | - | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
213 | 224 | | |
214 | 225 | | |
215 | | - | |
216 | | - | |
217 | | - | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
218 | 229 | | |
219 | 230 | | |
220 | 231 | | |
| |||
420 | 431 | | |
421 | 432 | | |
422 | 433 | | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
423 | 454 | | |
424 | 455 | | |
425 | 456 | | |
| |||
459 | 490 | | |
460 | 491 | | |
461 | 492 | | |
462 | | - | |
| 493 | + | |
463 | 494 | | |
464 | 495 | | |
465 | 496 | | |
| |||
Lines changed: 17 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1136 | 1136 | | |
1137 | 1137 | | |
1138 | 1138 | | |
1139 | | - | |
| 1139 | + | |
1140 | 1140 | | |
1141 | 1141 | | |
1142 | 1142 | | |
| |||
1156 | 1156 | | |
1157 | 1157 | | |
1158 | 1158 | | |
1159 | | - | |
| 1159 | + | |
1160 | 1160 | | |
1161 | 1161 | | |
1162 | 1162 | | |
| |||
1236 | 1236 | | |
1237 | 1237 | | |
1238 | 1238 | | |
1239 | | - | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
1240 | 1244 | | |
1241 | 1245 | | |
1242 | 1246 | | |
| |||
1257 | 1261 | | |
1258 | 1262 | | |
1259 | 1263 | | |
1260 | | - | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
1261 | 1269 | | |
1262 | 1270 | | |
1263 | 1271 | | |
| |||
1278 | 1286 | | |
1279 | 1287 | | |
1280 | 1288 | | |
1281 | | - | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
1282 | 1294 | | |
1283 | 1295 | | |
1284 | 1296 | | |
| |||
Lines changed: 98 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
304 | 402 | | |
305 | 403 | | |
0 commit comments