kb1
Junior Member
Posts: 167
Registered: 11-06 |
entryway said:
...First frame of every tic takes 80% of time and that's because prboom-plus isn't smooth...
Hmmm. 40000 for the first frame and somewhere between 4000 and 8000 or so for subsequent frames... If you half the number of monsters, does the first frame (~40000) get shorter, with the subsequent frames still taking about the same (4000 to 8000) amount of time?
EDIT: By your numbers, it looks to me like your AI+1 frame of rendering is taking more than 1/2 a tic to complete.
Doesn't that mean that the best you can get without choppiness is 1 frame/tic (35 fps)?
I've never tried to implement any interpolation, but it seems to me that, for it to be smooth, it needs to run at a multiple of the AI's speed (35 fps, 70 fps, 105 fps, etc).
Maybe this could be implemented:
code: frames_per_tic = (int)(65536/first_frame_frac)
So, if first_frame_frac = 8192, you can render 8 frames that tic.
Also:
code: next_interpolation_frac = currentfrac + 65536/frames_per_tic
Something like that would spread out the frames evenly across the tic.
EDIT 2: Come to think of it, this gets more tricky when you also consider tearing (vertical sync). For example, maybe you don't render the first frame of a tic at all, but rather, render the interpolated frac nearest to a vsync. In other words, it makes no sense to render more frames than your monitor's refresh rate, but, the frames you do render should be as evenly spaced as possible.
It is reasonable (I think) to assume that anyone's monitor will refresh at at least 35hz. Anticipating when a vertical sync will occur could help you decide which frame to render (and more importantly which frames not to render). And, the frame you render might not be the first frame in a tic, it might be the interpolated one.
I think the goal is to get all those timings you posted to be evenly spaced (even at the expense of dropping frames).
Let's consider a 60hz monitor. Considering a vertical refresh occurs at tic 0, frac 0, another one will occur at tic 0 frac 38229 (35/60)*65536. That number can be considered to be a constant goal to strive for (in this Doom session, for this monitor).
If 1 unit of AI time + render time + interpolation time < 38229, you can smoothly render at your monitor's refresh rate.
However, the posted example takes 42130 fracs to run (mostly AI time?), so you'll miss a frame, there's no way around that, unless you could somehow interpolate during an AI update (ouch - I wouldn't try it). About the only sensible thing to do at that point is decide to refresh every other frame, which, for a 60hz monitor, puts you back to 35hz. Lame? yes, but it would be smooth.
Last edited by kb1 on 08-04-11 at 20:49
|