Timing / Animation / High FPS - wobbling and jerking

Hi,

I’m developing a simple JOGL application. I’m having a bit of trouble getting the animation to look perfectly smooth. I’m trying a variety of different approches, but they all look slightly jerky. For instance displaying a textured rectangle and letting the user control it by pressing the keyboard.

Problem 1> The rectangle seems to “wobble” as it moves across the screen. I am simply doing a glTranslate to move it. I have also tried using mipmaps, but although it looks better, it doesn’t get rid of the wobble. Is this an aliasing or interpolation issue and does anyone have any ideas?

Problem 2> I can’t seem to get an even frame rate. If I automate the glTranslate (rather than have it being controlled by keyboard, etc) then it seems really jerky. I’ve had it set up so that it if, for instance, it needs to go from point A to point B in 3000 milliseconds, then I figure out how much time as elapsed and then calculate where it should be (ie at the midpoint of AB after 1500ms). This in principle should make sure everything is timed properly, but as I said, it looks a bit jerky. If I have it simply move a certain amount at each loop of the display loop, it still seems uneven.

I’ve read on this forum of people getting hundreds of FPS. I seem to be bouncing between 30 and 60 FPS depending on how much I have on the screen. I am using FPSAnimator set to 100 (I’ve tried different intervals) and also have tried the regular Animator set to runFastAsPossible.

Any help with the wobbling and jerking would be greatly appreciated!

-spiraljetty

Hi,

timing:
what timing method are you using? to get accurate time values you should use System.nanoTime(), wihich is available since java 5. i dont understand how and why mipmaps improved the situation…

low fps:
maybe you have vsync enabled and your fps are limited by your monitors refresh rate, 60Hz -> 60Fps. see GL.setSwapInterval(…) for disabling it… but 30-60 fps should be enough to get an smooth animation.

give us some more information/code if you need further help :slight_smile:

Hi, thanks for the response. I had no idea about setSwapInterval and had never gotten around to trying out system.nanoTime()… I can now get up to 500fps at even intervals with no problem.

I still have this issue though, I’ll try to explain it better:

  1. generate a texture from a photo/bufferedImage and map it to a rectangle in 3D space.

  2. create a loop whereby the rectangle is translated from say, -2f to 2f on the x-axis over the space of 10 seconds.
    2a) or set up a keylistener where pressing the arrows increments/decrements the x-position by .00125f at a time.

  3. you will notice that there is a kind of “shimmering” as the rectangle moves slowly across the screen.

  4. the shimmering seems more pronounced the further away it is from the camera on the z-axis.

My question about mipmapping/filtering was because I wondered if the shimmering was happening because of filter calculations. My question about timing was because I was wondering if I was doing something stupid in updating the glTranslate parameter.

has anybody else noticed this type of behavior? It’s a bit subtle, but definitely noticeable!

Thanks, spiraljetty

Instead of updating the position a fixed amount each frame, either compute the position each frame from scratch based on knowledge of the starting point, ending point, starting time, and current time; or consider a velocity and use System.nanoTime() to multiply the velocity by the time difference since the last frame. The first approach is more robust.

The shimmering may well be caused by aliasing. If you aren’t using the TextureIO classes to load your textures, try doing so and enabling mipmapping during loading.