You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tick delta is a term used quite often in the rendering pages, The Basic Rendering Concepts page refers to it as "which is the time that has passed since the last frame". Rendering in the Hud further elaborates on this by explaining it as "the time since the last frame, in seconds."
As obvious from the issue title, both of these explanations are wrong. Unfortunately, not everyone is aware of this. Browsing the mod-dev channels in the Fabricord, it is quite easy to find examples of people sharing this wrong explanation, and other people encountering issues in their code when they use it as explained in the docs or by others.
Let's look at the game code to determine what "tick delta" actually is:
This is Yarn mappings. Unfortunately, the lastFrameDuration field name is also incorrect, I'll PR a fix some time later.
Looking at this, we see that tickDelta gets incremented with lastFrameDuration (which is the time between frames, converted to game ticks, depending on the server's selected tick rate), and then i is subtracted from it. i is calculated by casting the tickDelta to an integer, which drops the decimal part. So converting 319.64 would result in 319, 59.03 would result in 59.
Two things are obvious here:
the calculation of tickDelta on the current frame is dependent on the value from the previous frame
tickDelta is never less than 0 or more than 1
With this mind, we can come to the conclusion that tickDelta is the "progress" between the last game tick and the next game tick. For example, if we assume the game runs at 60 FPS, this is what tickDelta would be on different frames:
Frame 1: game tick, tickDelta is 1.0
Frame 2: no game tick, tickDelta is 0.33
Frame 3: no game tick, tickDelta is 0.67
Frame 4: game tick, tickDelta is 1.0
We can prove this further by looking at usages of tickDelta. tickDelta is often used in combination with MathHelper#lerp, which would never work correctly if tickDelta was actually time since last frame.
I hope this is sufficient evidence that the explanation needs to be corrected. The implementation of RenderTickCounter#getTickDelta can be looked at if this is not enough proof
The text was updated successfully, but these errors were encountered:
its-miroma
changed the title
The explanation and usage of "tick delta" in the docs are completely incorrect
"Tick delta" explanation and usage are incorrect
Oct 28, 2024
Tick delta is a term used quite often in the rendering pages, The Basic Rendering Concepts page refers to it as "which is the time that has passed since the last frame". Rendering in the Hud further elaborates on this by explaining it as "the time since the last frame, in seconds."
As obvious from the issue title, both of these explanations are wrong. Unfortunately, not everyone is aware of this. Browsing the
mod-dev
channels in the Fabricord, it is quite easy to find examples of people sharing this wrong explanation, and other people encountering issues in their code when they use it as explained in the docs or by others.Let's look at the game code to determine what "tick delta" actually is:
This is Yarn mappings. Unfortunately, the
lastFrameDuration
field name is also incorrect, I'll PR a fix some time later.Looking at this, we see that
tickDelta
gets incremented withlastFrameDuration
(which is the time between frames, converted to game ticks, depending on the server's selected tick rate), and theni
is subtracted from it.i
is calculated by casting thetickDelta
to an integer, which drops the decimal part. So converting319.64
would result in319
,59.03
would result in59
.Two things are obvious here:
tickDelta
on the current frame is dependent on the value from the previous frametickDelta
is never less than 0 or more than 1With this mind, we can come to the conclusion that
tickDelta
is the "progress" between the last game tick and the next game tick. For example, if we assume the game runs at 60 FPS, this is whattickDelta
would be on different frames:We can prove this further by looking at usages of
tickDelta
.tickDelta
is often used in combination withMathHelper#lerp
, which would never work correctly iftickDelta
was actually time since last frame.I hope this is sufficient evidence that the explanation needs to be corrected. The implementation of
RenderTickCounter#getTickDelta
can be looked at if this is not enough proofThe text was updated successfully, but these errors were encountered: