Jump to content

  • Log In with Google      Sign In   
  • Create Account


Game Jerky with Vsync Off


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 Endemoniada   Members   -  Reputation: 307

Like
0Likes
Like

Posted 14 November 2012 - 08:00 PM

Hi guys,

I just noticed that my game is jerky when Vsync is off. Everything is silky smooth when it's on. I really don't know where to start.

Here is my loop:

while(msg.message != WM_QUIT){
if(PeekMessage(&msg,NULL,0,0,PM_REMOVE)){
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else{
QueryPerformanceCounter((LARGE_INTEGER*)&cur_time);
time_span=(cur_time-last_time)*time_factor;
last_time=cur_time;
game->heartbeat(timespan);
}

My objects are timespan based like so:

position.x+=velocity.x*timespan;
position.y+=velocity.y*timespan;

What do you think it could be ?

I'm using Win 8 Pro if that matters.

Please help, thanks.

Sponsor:

#2 yewbie   GDNet+   -  Reputation: 665

Like
0Likes
Like

Posted 15 November 2012 - 01:17 PM

Vsync has probably capped you to ~60 frames per second, turning it off who knows but its no longer as consistant.
I would probably change my object's so they move independantly of the time between frames.

edit: After reading Erik's reply, could you describe the jerkiness more?

Edited by yewbie, 15 November 2012 - 01:51 PM.


#3 Erik Rufelt   Crossbones+   -  Reputation: 3171

Like
1Likes
Like

Posted 15 November 2012 - 01:26 PM

You can't get perfect smoothness without vsync, that's what it's for. Your screen only updates at a certain rate (usually 60 Hz), so if your game updates at 120 FPS, you will actually have updated 2 frames between each frame you see on screen.
This is further complicated by the fact that the screen doesn't update instantaneously, so if you update too fast then the top half of the screen might display the image from one frame, while the bottom half of the screen displays the image from the next frame, which leads to tearing (you see a horizontal line where your image is offset).
In addition to that, and what probably makes your game feel jerky, is that you will rarely update at an exact multiple of the screen refresh rate, so if you update 2.5 times faster than your monitor, then between the frames you actually see you will sometimes have moved 2 frames and sometimes 3 frames.

#4 Postie   Members   -  Reputation: 883

Like
0Likes
Like

Posted 15 November 2012 - 03:51 PM

The jerkiness is probably a combination of factors, including screen tearing (where half the screen is showing the previous frame), as mentioned by Erik Rufelt.

Another often overlooked situation is that each frame doesn't take exactly the same amount of time to render. Depending on what's on screen, what the user is doing and what game logic is going on behind the scene, the time in milliseconds to render a given frame can vary quite a lot. The human brain is good at perceiving subtle differences in the timing of periodic events, which is what you're seeing as jerkiness.

If you turn on VSync, you're forcing each frame to take the same amount of time, so animation is perceived to be considerably smoother.
Currently working on an open world survival RPG - For info check out my Development blog: ByteWrangler




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS