[android-developers] Re: How to achieve ultra smooth OpenGL/ES animation
I also had to fight this problem for a racing game. As Robert suggested, average your delta times, it's the only way you can smooth things out. I use a window of 5 frames per second for which i sum up the delta times and divide by the number of frames. An example 15ms, 15ms, 33ms, 15ms, 15ms will give you an average delta time of 18.6ms for frame 6. The 33ms will also influence the delta time of the next 4 frames after it. To avoid that effect you could use weighted averaging: frame delta times that are newer receive a higher weight (just an example, haven't boughtered using it) On 2 Feb., 06:55, tomei.ninge...@gmail.com tomei.ninge...@gmail.com wrote: I am already doing the animation in a time-based fashion. However, when I scroll the texture at a constant speed across the screen, I can see stuttering when the frame rate changes between 60fps and 30fps. Apparently the human eye is very good at detecting this kind of anomaly. On Feb 1, 4:35 pm, Robert Green rbgrn@gmail.com wrote: What MrChaz said. Use time-based animation and then if you want to smooth out the rough spots, you can tick using a running average. On Feb 1, 1:02 pm, MrChaz mrchazmob...@googlemail.com wrote: The easiest way to achieve a smooth rotation is to multiply the rotation amount by the time difference between the current frame and the last frame - that way the amount moved is constant over time. On Feb 1, 5:18 pm, tomei.ninge...@gmail.com tomei.ninge...@gmail.com wrote: Hello Android OpenGL/real-time gurus, I am drawing a pretty simple scene, with one large texture the about size of the screen (two triangles). I notice that the frame-rate is irregular: in most of cases, a frame finishes in 17 ms. However, in about 1 of 10 times, the frame finishes in 33ms. My guess is probably some background services need to run. However, the Linux scheduler is biased towards my FG app, so the BG services are usually starved, until they can't take it anymore and they grab the CPU from my app I am seeing stuttering in the animation. Is this due to the irregular frame rate? Should I delay each frame so that all frames are rendered with 33ms frame time? If so, what's the best technique of achieving this? Is there an API that I can call to guarantee CPU resources for the render thread I really hope Android runs on some sort of real time kernel ... Thanks! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to achieve ultra smooth OpenGL/ES animation
I am drawing a pretty simple scene, with one large texture the about size of the screen (two triangles). I notice that the frame-rate is irregular: in most of cases, a frame finishes in 17 ms. However, in about 1 of 10 times, the frame finishes in 33ms. This could be the garbage collector. Whenever the garbage collector is called, you can see a message in the logcat, under the tag dalvikvm, using log level debug. If it is the GC, the way to fix it is to avoid allocating memory: every time you allocate memory, the GC wakes up to check if there is something to collect; just pre- allocate all the objects you need, and that´s it. You can also call the GC manually, when the timing is good for you, using the System.gc() call. Fulanito. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to achieve ultra smooth OpenGL/ES animation
Thanks for the suggestion. I forced GC before starting the animation and I can verify that no GC log comes in logcat, but still I am seeing stuttering in the animation. On Feb 1, 10:24 am, fulanito fulanito...@gmail.com wrote: I am drawing a pretty simple scene, with one large texture the about size of the screen (two triangles). I notice that the frame-rate is irregular: in most of cases, a frame finishes in 17 ms. However, in about 1 of 10 times, the frame finishes in 33ms. This could be the garbage collector. Whenever the garbage collector is called, you can see a message in the logcat, under the tag dalvikvm, using log level debug. If it is the GC, the way to fix it is to avoid allocating memory: every time you allocate memory, the GC wakes up to check if there is something to collect; just pre- allocate all the objects you need, and that´s it. You can also call the GC manually, when the timing is good for you, using the System.gc() call. Fulanito. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to achieve ultra smooth OpenGL/ES animation
The easiest way to achieve a smooth rotation is to multiply the rotation amount by the time difference between the current frame and the last frame - that way the amount moved is constant over time. On Feb 1, 5:18 pm, tomei.ninge...@gmail.com tomei.ninge...@gmail.com wrote: Hello Android OpenGL/real-time gurus, I am drawing a pretty simple scene, with one large texture the about size of the screen (two triangles). I notice that the frame-rate is irregular: in most of cases, a frame finishes in 17 ms. However, in about 1 of 10 times, the frame finishes in 33ms. My guess is probably some background services need to run. However, the Linux scheduler is biased towards my FG app, so the BG services are usually starved, until they can't take it anymore and they grab the CPU from my app I am seeing stuttering in the animation. Is this due to the irregular frame rate? Should I delay each frame so that all frames are rendered with 33ms frame time? If so, what's the best technique of achieving this? Is there an API that I can call to guarantee CPU resources for the render thread I really hope Android runs on some sort of real time kernel ... Thanks! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to achieve ultra smooth OpenGL/ES animation
What MrChaz said. Use time-based animation and then if you want to smooth out the rough spots, you can tick using a running average. On Feb 1, 1:02 pm, MrChaz mrchazmob...@googlemail.com wrote: The easiest way to achieve a smooth rotation is to multiply the rotation amount by the time difference between the current frame and the last frame - that way the amount moved is constant over time. On Feb 1, 5:18 pm, tomei.ninge...@gmail.com tomei.ninge...@gmail.com wrote: Hello Android OpenGL/real-time gurus, I am drawing a pretty simple scene, with one large texture the about size of the screen (two triangles). I notice that the frame-rate is irregular: in most of cases, a frame finishes in 17 ms. However, in about 1 of 10 times, the frame finishes in 33ms. My guess is probably some background services need to run. However, the Linux scheduler is biased towards my FG app, so the BG services are usually starved, until they can't take it anymore and they grab the CPU from my app I am seeing stuttering in the animation. Is this due to the irregular frame rate? Should I delay each frame so that all frames are rendered with 33ms frame time? If so, what's the best technique of achieving this? Is there an API that I can call to guarantee CPU resources for the render thread I really hope Android runs on some sort of real time kernel ... Thanks! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to achieve ultra smooth OpenGL/ES animation
I am already doing the animation in a time-based fashion. However, when I scroll the texture at a constant speed across the screen, I can see stuttering when the frame rate changes between 60fps and 30fps. Apparently the human eye is very good at detecting this kind of anomaly. On Feb 1, 4:35 pm, Robert Green rbgrn@gmail.com wrote: What MrChaz said. Use time-based animation and then if you want to smooth out the rough spots, you can tick using a running average. On Feb 1, 1:02 pm, MrChaz mrchazmob...@googlemail.com wrote: The easiest way to achieve a smooth rotation is to multiply the rotation amount by the time difference between the current frame and the last frame - that way the amount moved is constant over time. On Feb 1, 5:18 pm, tomei.ninge...@gmail.com tomei.ninge...@gmail.com wrote: Hello Android OpenGL/real-time gurus, I am drawing a pretty simple scene, with one large texture the about size of the screen (two triangles). I notice that the frame-rate is irregular: in most of cases, a frame finishes in 17 ms. However, in about 1 of 10 times, the frame finishes in 33ms. My guess is probably some background services need to run. However, the Linux scheduler is biased towards my FG app, so the BG services are usually starved, until they can't take it anymore and they grab the CPU from my app I am seeing stuttering in the animation. Is this due to the irregular frame rate? Should I delay each frame so that all frames are rendered with 33ms frame time? If so, what's the best technique of achieving this? Is there an API that I can call to guarantee CPU resources for the render thread I really hope Android runs on some sort of real time kernel ... Thanks! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en