fix: Lerp smoothing frame rate dependence and freeze at maximum interpolation time - #4130
Open
NoelStephensUnity wants to merge 3 commits into
Open
fix: Lerp smoothing frame rate dependence and freeze at maximum interpolation time#4130NoelStephensUnity wants to merge 3 commits into
NoelStephensUnity wants to merge 3 commits into
Conversation
…polation 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.
NoelStephensUnity
marked this pull request as ready for review
August 19, 2026 01:33
Codecov ReportAll modified and coverable lines are covered by tests ✅ @@ Coverage Diff @@
## develop-2.0.0 #4130 +/- ##
=================================================
+ Coverage 73.86% 73.96% +0.09%
=================================================
Files 172 172
Lines 28099 28103 +4
=================================================
+ Hits 20756 20786 +30
+ Misses 7343 7317 -26
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 2 files with indirect coverage changes
|
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose of this PR
Fixes two pre-existing defects in the lerp smoothing pass used by the
LerpandSmoothDampeninginterpolation types.1. Smoothing was frame rate dependent. The factor was
1.0f - MaximumInterpolationTimeapplied once per frame with no delta time, so the wall clock smoothing rate scaled with the frame rate. It is now raised to the number of 60fps reference frames elapsed, making the rate a function of elapsed time.2. A maximum interpolation time of
1.0froze the transform. That is the upper bound of the inspector[Range], and it produced a factor of exactly0, so the value never advanced. Affects all three axes and both interpolation types. The retained portion is now clamped just below1.0.Three things worth knowing that aren't obvious from the diff:
1.0. Verified across0.1 / 0.5 / 0.9 / 0.99. Only1.0changes, and it was a hard freeze, so nothing could have been relying on it. Other frame rates now match the 60fps curve rather than diverging from it.InterpolationTypes.LegacyLerpis enum value0with no field initializer, noReset(), and no editor default, so a freshly addedNetworkTransformuses the legacy path — which was already frame rate correct and is untouched here. Only projects that explicitly opted intoLerporSmoothDampeningwere exposed.pow(1.0, x) == 1, so the delta time fix alone still yields a factor of0at1.0.For scale: settle time at
MaxInterpolationTime = 0.9was 2.13s @30fps vs 0.275s @240FPS; it is now a flat ~1.02s at 30/60/120/240. At the0.1default the effect was invisible, which is why this went unnoticed.The doc comments on the lerp smoothing fields described the
LegacyLerpformula for all interpolation types and have been corrected.Jira ticket
TODO: add ticket
Changelog
com.unity.netcode.gameobjectsLerpandSmoothDampeninginterpolation types to smooth by different amounts at different frame rates. Results at 60fps are unchanged.NetworkTransformfrom interpolating at all when using theLerporSmoothDampeninginterpolation types.Documentation
The
remarksonPositionLerpSmoothing,RotationLerpSmoothing,ScaleLerpSmoothing,MaximumInterpolationTime, and theInterpolationTypes.Lerp/SmoothDampeningenum entries all described theLegacyLerpformula regardless of the selected type. They now state that smoothing is frame rate independent and note that the same value does not produce the same result underLegacyLerpas under the other types.Testing & QA (How your changes can be verified during release Playtest)
Both regression tests were written first and confirmed red against unfixed code, failing on the intended assertions rather than on timeouts:
Interpolated value only advanced 0 from 3.17 over 2.11s(once forLerp, once forSmoothDampening)produced 6.626402 at 30fps but 6.688997 at 240fpsAfter the fix, all 13 tests in
InterpolatorTestspass, including the 10 pre-existing ones.For release playtest, the highest value check is an object using
LerporSmoothDampeningwith a maximum interpolation time above ~0.5, observed at a non-60fps frame rate — that is where the old and new behaviour differ. At the0.1default there should be no perceptible change at any frame rate.Functional Testing
Manual testing :
Manual testing doneAutomated tests:
Covered by existing automated testsCovered by new automated testsDoes the change require QA team to:
Review automated tests?Execute manual tests?Provide feedback about the PR?Up-port
#4132 is the up-port.
Required. Will be up-ported to
develop-3.x.xonce this PR lands.Backports
Not needed.