Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

VSync on or off?

Discussion in 'General Graphics' started by Koval331, Feb 26, 2019.

  1. Koval331

    Koval331

    Joined:
    Feb 3, 2019
    Posts:
    114
    So as I got it VSync makes a game wait for x milliseconds for the time when my monitor will be updating and then it will paint the next frame on the screen, right?

    In the Profiler, I see that VSync takes 9-12 ms every frame and I have 70-80 FPS with it turned on. When I turn it off I have 700 FPS and the most important it seems like my game runs more smoothly. (I can't say for sure because the human eye can not catch more than 60 frames per second... etc.)

    My target platforms are Android and iOS, so should I turn VSync off to see more smooth game rendering. (At least for Android. I know that iOS always turns VSync on). I am just worried to accidentaly break some internal Unity *thing* and get some phantom bugs later :)
     
  2. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,726
    No. Specially not on android unless you want to nuke the battery on faster phones. IOS will force vsync on anyway, so you should just explore other avenues.
     
    Koval331 likes this.
  3. Koval331

    Koval331

    Joined:
    Feb 3, 2019
    Posts:
    114
    Thanks! I knew there was something with it :)

    BTW I Profiled it on my phone (with VSync ON) and it does not spend any time on that WaitForSeconds function and I have a smooth movement.
     
  4. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    1,606
    You can't get rid of vsync on both iOS and Android.
    Also, 60 FPS is not required for all games. 30 might be enough for you, and having it set to 30 will decrease the battery consumption and, potentially, overheating.
     
    optimise, Bun_MS, Lightning_A and 2 others like this.
  5. Koval331

    Koval331

    Joined:
    Feb 3, 2019
    Posts:
    114
    Yeah. I found WaitForPresent function after that XD. Anyway thanks!
     
  6. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    26,726
    You should ensure your game runs correct pace at 30 and 60fps. With being forced on you will find issues with timing if you do not know what deltatiming is.
     
  7. Koval331

    Koval331

    Joined:
    Feb 3, 2019
    Posts:
    114
    Thanks, but how? Is there any ways to establish more or less stable fps among iOS and Android?
     
  8. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    1,606
    You can cap the framerate by setting the VSync count to every v blank of every second v blank. On a display with 60 FPS this will give you either 60 or 30 FPS.
     
    Koval331 likes this.
  9. glad

    glad

    Joined:
    May 10, 2014
    Posts:
    76
    30 FPS is enough ? Huh.. You must be joking.. 30 FPS its a laggy thing.. I wish to have over 80 FPS. But 60 in most cases is enough..

    Can you tell why is that needed ? Why can't I set up the 45 FPS, or say 65 FPS ? Is that a device OS restriction ?
     
    Eater_Games likes this.
  10. doarp

    doarp

    Joined:
    Sep 24, 2019
    Posts:
    138
    Not everyone is making FPS games. A puzzle games usually is fine with 30 FPS and it really helps with battery and overheating.
    On iOS at least, you can only have frames rates that are whole divisions of 60 (60, 30, 20, 15, 12, 10 etc) because all it does is skip an integer number of frames, while the screen is always at 60hz.
     
    MartinTilo and glad like this.
  11. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    1,606
    @doarp is correct, the same applies for Android.
    It really depends on the type of game you're making.
    It is. There is no way to turn VSync off.
     
    Kael-kael and glad like this.
  12. dragon_script

    dragon_script

    Joined:
    Nov 3, 2019
    Posts:
    21
    humans can perceive more than 60 fps. but your screen can't place them
     
    BrandyStarbrite and MartinTilo like this.
  13. BrandyStarbrite

    BrandyStarbrite

    Joined:
    Aug 4, 2013
    Posts:
    1,415
    That is not entirely true.
    However, similar to what dragon_script mentioned above, technology unfortunately, has it's limits.
     
  14. dragon_script

    dragon_script

    Joined:
    Nov 3, 2019
    Posts:
    21
    There are couple 60 fps+ screens. Theese are used in Proffesional Gaming.
     
    BrandyStarbrite likes this.
  15. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    591
    Is this typo? I thought set to higher to like 60 will decrease the battery consumption instead of lower 30?
     
  16. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    1,606
    @optimise rendering 30 frames per second is 2x less work than rendering 60 frames per second, so having 30 FPS will decrease the battery consumption compared to 60 FPS.
     
    optimise likes this.
  17. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    9,178
    To clarify, a game that can only run at 30 fps due to needing more CPU / GPU performance than the platform has available is just as bad or potentially much worse for the battery than a game that can run over 60 fps.

    What @aleksandrk is talking about is a game that can run over 60 fps but is being artificially limited to 30 fps via targetFrameRate or vSyncCount. In that case the CPU & GPU are able to either clock down significantly or potentially sleep (almost completely stop using power) for most of the time between updates, greatly reducing battery consumption.
     
    aleksandrk and optimise like this.
  18. GameHourStudio

    GameHourStudio

    Joined:
    Apr 17, 2020
    Posts:
    32
    This is a link explaining why we can have only 30 or 60 and not something in between.
    https://support.unity3d.com/hc/en-u...game-flips-between-running-at-30FPS-and-60FPS

    Also I have tried my mesh to optimize my game by reducing draw calls, by using low poly scripts, by using render cues, frustum culling, limiting frustum, by optimizing update and fixed update calls, but still I don't know why my game is running at 30 to 33 FPS all the time whenever I profile it on my target device. The vehicle selection scene shows nearly 60 FPS(This also includes 50% from WaitForPresent and its break down tells waitForTargetFPS). But when my game scene starts, it is less 30 to 33 FPS and my profiler shows the rest of the time in terms of waitForTargetFPS. This time again it is 50% or more. I am setting vSync to every blank through Quality Settings and I am not setting targetFPS or vSyncCount through script. I don't know what could be the case. I have even turned off the whole scene and just a vehicle running on plane. But still this behaviour. I don't know how it would be possible for me to achieve 60 FPS if waitForTargetFPS is taking this much time.
     
unityunity