Graphics Enthusiast and Performance Devotee

Gunnar Sletta

Click here to edit subtitle

Blog

What is good enough?

Posted by gunnar@sletta.org on September 15, 2014 at 4:10 AM

I wanted to start this out with a definition of what is good enough and why. I already covered some of this some time ago here, but I wanted to tidy it up a bit and have it here for completeness, in a framework agnostic fashion.


In real life, objects will move, accelerate and decelerate, but very few things can teleport. So for our brain to perceive natural motion, objects on the screen need to follow the same rules. Their velocity, acceleration and deceleration needs to be steady. Say an object moves with 1 pixel per millisecond and our display refreshes at 60 Hz (meaning how fast the display is capable of updating the content on screen). For its motion to be steady, the object should move exactly 16.6 pixels per frame and the frames would have to be presented to the viewer at exactly 16.6 ms apart.


Both of these factors are important. If the object moves between 10-22 pixels per frame and is presented at 16.6 ms apart (with the help of vsync) it will look bad. If the objects are moving with 16.6 pixels per frame, but skips every ten frames, it will also look bad. When the application is producing 60 frames per second (fps), it will line up with the capacity of the display and it will be velvet.


- Ok, so my application runs at 50-something fps That is pretty good, isn’t it?

- Sorry, but no.. 


Assuming a 60 Hz display, if the application runs at 59 fps, this means that once per second, the velvet motion will stop. Some people see this, some don’t, but we all notice it. Put something that runs at 59 next to something that runs at 60 (assuming a refresh rate of 60) and anyone can tell you that 60 fps feels more right.


For almost a full second the application has been tricking your brain into thinking that it is observing objects moving about naturally. Then suddenly, they teleport. The illusion stops... Running close to the display’s frame rate is almost worse, because it is almost there so the shattering of the illusion is that much greater. If you cannot hit exactly 60, aim for a higher swap interval. It does mean that the observant and trained eye will be able to see discrete frames, but at least the motion will be steady. For a 60 Hz display, animations running at 30 fps will look better than animations running at 40 or 59 fps.


- Ok, but my application runs at 79 FPS, isn’t that awesome?

- Nope, equally bad..


Being able to run with a very high frame rate can serve a purpose. It gives an indication as to how much slack there is in the system before things turn sour and go below the display's frame rate. It also gives you an indication as to how high the CPU load will be and what the power consumption is once you fix it to run at the display's frame rate.


However, it does mean that it is not smooth. Either frames are being presented faster than the frame rate of the display, which leads to tearing. Or the frame is simply discarded, which means that the movement in pixels per visible frame is not steady.


Also, in most cases, this number is an average over time. A number of 79 could mean that most frames rendered in 12 ms, but there could be the odd frame rendering in 30 ms, leading to an overall high frame rate, but very uneven movement. Because animations anyway look crap at this frame rate, you don’t notice, so you are actually damaging the end result.


If you want to measure slack, disable the CPU and GPU scaling governors, run the application at exactly the display's frame rate and measure the CPU load and aim for as low as possible. This will let you catch bad single frames while measuring the live sustained performance of the application.


- So, is 60 fps the ultimate framerate?

- No, but it is good enough and often the best option available.


Though there exists higher frame rate devices, the majority of consumer devices, be it mobile phones, tablets, TV sets or laptops, tend to aim for either 50 Hz or 60 Hz, so these are the numbers to work with. When we, some time in the future, standardize on 100 Hz, 120 Hz or higher, the difference will be the animation and motion equivalent to retina displays. In the meantime, we'll have to make the best of what we have.


So, to sum it up:

Aim to run the application at exactly the frame rate of the target display. Not a single frame higher and not a single frame lower. If that is not possible after redesigning for performance and applying all micro optimizations, then aim for a higher swap interval. For instance, by halving the frame rate.


Categories: Performance, Graphics, Animations

Post a Comment

Oops!

Oops, you forgot something.

Oops!

The words you entered did not match the given text. Please try again.

Already a member? Sign In

5 Comments

Reply Janus
2:39 PM on September 16, 2014 
"For instance, by halving the frame rate." - would this conversely mean that a 120Hz update rate could work as well? Thanks for good article.
Reply gunnar@sletta.org
4:33 AM on September 17, 2014 
Janus: If the display refreshes at 60 Hz, then you would only see 60 frames per second, so running at 120 Hz would not give you anything. Also, since you wouldn't be vsync locked, the rendering would drift compared to the 60 Hz display, and you would probably get tearing as well.

If you have a 120 Hz display, then running at exactly 120Hz is the right thing and looks awesome, of course.
Reply Thorbjørn Lindeijer
4:15 PM on October 7, 2014 
I agree on all fronts, except for the mention that locking to 30 fps is better than running somewhere between 30 and 60 fps. To my eyes, 30 fps is consistently too low to enjoy, and I'd much rather have a little irregularity or even tearing than being permanently dropped to 30. This is why I very much enjoy NVIDIA's adaptive vsync option (which is then only doing vsync while the game can do 60 fps or higher), and I think I'm not the only one. :-)

Thanks for starting up this blog series, btw. These will be some good read!
Reply gunnar@sletta.org
2:30 AM on October 16, 2014 
@Thorbjørn: 30 fps is too low to maintain the illusion of motion, so you will see each individual frame. At least when looking at 2D graphics. For UIs, I still think steady motion is preferred over the content jerking a once or twice a second. For 3D gaming, the adaptive vsync can be a good option.
Reply tolstivan0748
9:33 PM on February 4, 2017 
Hello! I really like your blog! Continue to write more! Very interesting!