[…]
The only problem is, I tried both Fixed Rate Pig and Kobo Deluxe,
and they do NOT run entirely smoothly on my system
They aren’t, and cannot (realistically) be on any hardware.
The reason is that the rendering isn’t sub-pixel accurate. You can
interpolate all you want, but as long as you truncate or round
positions to integer pixels, there’s no way to get perfectly smooth
animation, except in the special case that speeds happen to be exact
integer numbers of pixels per refresh.
The effect is most noticeable on Kobo, which gives an obvious jerk
every few seconds, both in SDL and OpenGL modes (with GL vblank
waiting enabled).
Sounds like your refresh rate is very close to a multiple of the
scrolling speed (3 pixels per 30 ms in 320x240). That’ll result in
very smooth scrolling - except that if the refresh rate doesn’t
exactly math the logic scrolling speed in integer pixels/frame,
there will be a step that’s one pixel bigger or smaller than normal
at regular intervals.
Pig
Pig isn’t scrolling, and objects move at different speeds, so the
effect might not be as obvious…
(and the smooth scrolling example) run much smoother, but when
paying attention, I still notice minor jerks (like single frame
skips perhaps) every few seconds.
Unless you’re just seeing the effect of some background process
stealing the CPU for too long every now and then (which invariably
happens without retrace sync, or when the driver implements retrace
sync by means of busy-waiting), that’s rather weird… (If you’re
talking about smoothscroll in OpenGL mode, that is. The SDL rendering
mode is not sub-pixel accurate, so that’s bound to have the same
issues as Pig and Kobo Deluxe.)
That said, due to the lack of a proper timing API for graphics
drivers, smoothscroll has to deal with scheduling latency jitter in
the timestamps that drive the “logic”. Later versions have a filter,
but unfortunately, while that improves the situation on the worst
systems, it seems to cause problems on systems that don’t really
need the filtering.
There is (currently) no way to reliably fix this without resorting to
driver hacks and/or real time kernels.
Well, there is one way that might work under certain conditions:
- Simply assume that the refresh rate is exactly what
the driver claims.
- Assume that there flips are retrace sync’ed.
- Assume that you’ll never drop a frame.
If you can rely on that, it’s as simple as dropping the SDL_GetTicks()
stuff and assuming that the delta between two frames is exactly one
display refresh period at all times. (It is, as long as the
reported refresh rate is correct and you don’t drop any frames.)
Now perhaps it’s just my system setup, but other games seem to run
fine, including my own, which as far as I can tell seems to run
absolutely smoothly, with OpenGL, but using the same framerate for
the game logic as I get with GL flips, i.e. 60Hz, and using simple
linear scaling for the game logic.
So does smoothscroll… (No fixed logic rate there, as all it does is
bounce around a map.)
Have you tried running it in GL mode with the filter disabled?
(-ntf option) If that doesn’t work, I must have screwed something up
in the maths.
[…]
which might be solved by converting to a fixed rate logic.
BTW, if you’re worried about changing acceleration causing trouble,
there’s always quadratic and cubic interpolation. However, since
those require 3 and 4 “old frames” respectively, you may have to
increase the logic frame rate to maintain an acceptable input->output
latency. (You might have noticed that Kobo Deluxe feels a bit lagged
when playing at high frame rates. That’s because the logic frame rate
is only 33 Hz…)
Either way, I suspect that going beyond linear interpolation is
overkill, especially with “sane” logic frame rates.
Note that Pig uses a logic frame rate of 20 Hz. I’ve tried much lower
frame rates than that, but then the response times and input
quantization would just be too obvious.
However, seriously; if you’re actually seeing any of the linear
segments that the interpolation generates between logic points, I
think I must have done something wrong in the maths, because I don’t
think it’s realistically possible under normal conditions -
especially not without sub-pixel accurate rendering.
Implementing sub-pixel accurate OpenGL rendering in Pig might be
interesting…
//David Olofson - Programmer, Composer, Open Source Advocate
.- Audiality -----------------------------------------------.
| Free/Open Source audio engine for games and multimedia. |
| MIDI, modular synthesis, real time effects, scripting,… |
`-----------------------------------> http://audiality.org -’
— http://olofson.net — http://www.reologica.se —On Friday 11 March 2005 19.12, Marian Schedenig wrote: