Interpolation analysis#24
Open
gimploo wants to merge 1 commit into
Open
Conversation
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.
No Render Interpolation (analysis — not implemented)
Even with 1ms timer precision, on a display with refresh rate ≠ 60Hz, the render loop produces duplicate frames. The alpha value at
application.h:175-179is already calculated but unused:The Alpha Formula (Gaffer on Games "Fix Your Timestep"):
alpha ≈ 0(just after update): renders previous state (1-frame lag, imperceptible at 60Hz)alpha ≈ 0.5(midway): smooth blend between statesalpha ≈ 1(before next update): renders current stateWhy the render queue architecture complicates this:
Currently, render commands are generated inside
ecs_update(), which runs during the fixed update loop (while(accumulator >= FIXED_DT)). Butalphaexists only during the render phase (between update ticks). This means:Proposed Architecture Change:
Move render command generation from the update loop to the render phase:
Implementation Plan (6 files):
A)
ecs/component/types.h— Store previous transform state:B)
ecs/systems/transform.h— Save current→previous before updating:C)
ecs/common.h— Pass alpha through system context:D)
ecs/systems/model.handmesh.h— Lerp transforms for render:E)
src/scenes/collision-scene.h— Separate render systems from update:ecs_system_render_modelandecs_system_render_meshfrom main system listF)
src/main.c— Restructure update/render calls:And in
application.h:179, uncomment and pass alpha:Additional: Camera Interpolation
The camera system (
ecs/systems/camera.h) also needs previous state for smooth view matrix:positionandeuler_angleglcamera_set(lerped_position, lerped_angles)Additional: Animation Bone Interpolation
Bone transforms in
model->transformsare advanced at fixed 60Hz by the animation system. Without interpolation, skeletal animation would stutter. This requires:Summary
timeBeginPeriod(1)at startup