Skip to content

Decouple rendering from game tics - #771

Open
klaussilveira wants to merge 2 commits into
dhewm:masterfrom
klaussilveira:feat/interp
Open

klaussilveira wants to merge 2 commits into
dhewm:masterfrom
klaussilveira:feat/interp

Conversation

@klaussilveira

Copy link
Copy Markdown
Contributor

This is inspired by the PR made by Yamagi here: #310

I've been testing this locally on my own game for a while, but I think it's stable enough for a PR. It also pools input so you are not missing input at higher framerates and interpolates the view, similar to how Source does it. This adds 4 new cvars:

  • com_interpolate: enable or disable interpolation
  • com_maxFps: when interpolation is enabled, how much to cap the FPS
  • com_extrapolateMax: max extra miliseconds of extrapolation after a late game tic
  • net_clientSmoothViewTime: miliseconds over which prediction errors are blended out of the first person view
interp.mp4

Comment thread neo/d3xp/Entity.cpp
idVec3 m1 = curOrigin - renderOriginPrev;
float t2 = frac * frac;
float t3 = t2 * frac;
origin = renderOriginPrev * ( 2.0f * t3 - 3.0f * t2 + 1.0f )

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is cubic hermite interpolation. Linear looks ugly.

}
else {
g.frac = (float)( gameLocal.time - smoke->privateStartTime ) / (stage->particleLife * 1000);
g.frac = (float)( renderView->time - smoke->privateStartTime ) / (stage->particleLife * 1000);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this, smoke particles go haywire.

return cmd;
}

void idUsercmdGenLocal::GetPendingViewAngleDelta( float &yaw, float &pitch ) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is here to avoid camera movement lag.

Inkub0 added a commit to Inkub0/dude that referenced this pull request Aug 19, 2026
…ation; MP frame-timing mitigation

Fold the genuinely-better parts of dhewm3 PR dhewm#771 ("decouple rendering from
game tics") into our own com_interpolate, plus the dhewm3 PR dhewm#773 multiplayer
frame-timing mitigation. Both touch the same frame-timing files, so they land
together.

com_interpolate refinements (all archived cvars, default 1, no-op unless
com_interpolate is set; applied to both neo/game/ and neo/d3xp/):

- com_interpolateAim: low-latency mouselook. Overlays the pending, not-yet-
  simulated mouse-look delta onto the rendered view each frame so aiming tracks
  the mouse 1:1 instead of rendering ~16.7ms (one tic) behind. Exposed ABI-
  stably via a new idCommon::GetPendingViewAngleDelta() appended to the vtable
  (forwarding to idUsercmdGenLocal), not by changing idGame::Draw's signature
  the way dhewm#771 does. The mouse buffer is read non-destructively (only the tic
  clears it) and the sign/scale/invert + strafe/mlook gating mirror MouseMove()
  exactly, so it never steals input and doesn't hitch when a tic lands. The view
  weapon recomposes onto the produced renderView eye so the gun stays locked to
  the real-time aim. Shooting still resolves at the tic (no gameplay change).

- com_interpolateAnim: sample animated entities' skeletal animation at the sub-
  tic instant (in UpdateRenderEntity), so monster limbs move smoothly above
  60fps rather than stepping at the tic rate. Skips the view weapon, which owns
  renderAnimTimeOffset, to avoid double-applying.

- com_interpolateCubic: cubic Hermite (Catmull-Rom) entity position instead of
  linear lerp, smoother through accelerations. Adds a second history sample
  (renderInterpOriginPrev2/AxisPrev2/HistCount). Stays strictly interpolation
  between the last two tics -- no extrapolation, no overshoot.

Deliberately not ported from dhewm#771: extrapolation, com_maxFps (we already have
com_maxFPS), and the MP async / renderView->time decoupling that PR dhewm#773 had to
fix. Our approach keeps the game-DLL ABI stable, stays single-player-scoped,
and preserves the eye-relative view-model + gui-glow-light interpolation.

MP frame-timing mitigation (dhewm3 PR dhewm#773): use fixed USERCMD_MSEC timing in
multiplayer (single-player still recalculates each frame), and skip the full-
frame tic-sync sleep on an active server (clients keep it) to avoid the phantom
localhost ping and client/server desync from earlier frame-pacing changes.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@klaussilveira klaussilveira mentioned this pull request Aug 20, 2026
11 of 19 tasks
@vlad54rus

Copy link
Copy Markdown

Crashes during the invasion scene
Снимок экрана (127) — копия

@klaussilveira

Copy link
Copy Markdown
Contributor Author

Thanks for the help and the report, @vlad54rus! I'll check this over the weekend.

@klaussilveira

Copy link
Copy Markdown
Contributor Author

@vlad54rus does this happen at the same spot with com_interpolate 0?

@vlad54rus

Copy link
Copy Markdown

With com_interpolate 0 it crashes a bit later. All this on a testbuild from Actions.

@BurningFishNL

Copy link
Copy Markdown

Exactly the same findings here during the invasion scene.

com_interpolate 1 (crash on base.dll)
1
https://www.youtube.com/watch?v=DreF-u4tNzw

com_interpolate 0 (crash on Doom3.exe - Dhewm3.exe renamed)
0
https://www.youtube.com/watch?v=aCDaHrnqMX4

@klaussilveira

Copy link
Copy Markdown
Contributor Author

Thanks for the help testing this! Any chance you could test with these binaries: https://github.com/klaussilveira/dhewm3/actions/runs/33328137188

This is a minimal change, without interpolation, but still unlocking the renderer. I want to know if those crashes can be related to more frames being rendered before I add more debugging output. Haven't been able to reproduce this on Linux.

@vlad54rus

Copy link
Copy Markdown

Played through Mars City - no crashes so far.

@skarekrow

skarekrow commented Sep 2, 2026 •

Copy link
Copy Markdown

@klaussilveira I had the same crash as the others did on linux before that commit disabling interpolation. Any chance you could enable building linux binaries on that branch too? It's not a huge pita to do it locally, but it would make testing this easier.

EDIT: I see them now, thank you!

@Blackgrowl

Copy link
Copy Markdown

Just wanted to say, I tried this (On Windows 10 64-bit, 33328137188) and it went all slomo, but the reason why is because I had com_fixedtic set to 1

However, even at 75 FPS (I limited it to 75 and the com_showfps indicates between 72.80 and 73.30), the game feels sluggish.

Another problem, it seems that some effects are, I suppose interpolated, and badly so, or not interpolated at all? I'm using "Weapons of Mars Destruction", this gives all weapons a white smoke when you fire, at an extreme FPS of 2000, they start to flicker like crazy, anything above 60 is already a problem either way.

@klaussilveira

Copy link
Copy Markdown
Contributor Author

33328137188 has no interpolation, only an unlocked framerate. I still haven't had the time to pinpoint the crash of the interpolated build, but I have a suspicion of where it is.

@klaussilveira

Copy link
Copy Markdown
Contributor Author

@vlad54rus @BurningFishNL @skarekrow @Blackgrowl could you guys kindly try the newest build? Keep an eye on particle behavior at high FPS (> 300).

@Blackgrowl

Copy link
Copy Markdown

Strange, I got mentioned but I got no notification at all?

Either way, I tried it, it's still a bit sluggish but it may be due to no Frame Limit and having VSync on, I have a 75hz monitor so if I limit my FPS (using "com_maxFps") to 72, it's fine, but the "com_showfps" shows 68 FPS.

Regarding particles...I still have issues with it when using "Weapons of Mars Destruction", but the vanilla particles, in this case the ones in game/mars_city2, with the white smoke pipe blowing and the orange smoke at the bottom panels, it's fine at 60, 75 and 300 FPS.

At above 300+ FPS, the particle effects for "Weapons of Mars Destruction" get completely broken.

@klaussilveira

Copy link
Copy Markdown
Contributor Author

Ball is on my court on this one, just didn't have the time to make some adjustments to the original PR, as well as testing the game fully with particles to try and get to the bottom of it. I did the original changes based on my game, which doesnt have all the features that D3 has, so I need to review all D3 SP levels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

5 participants