Friday, 3 May 2013

Smoother FEZ

UPDATE 2:

New 1.04 patch for FEZ includes a new value for time step and a new command line parameter to use variable time steps as a beta test. With 1.04, you can see FRAPS shows now 60 fps instead of 58, but the game has judder anyway. So, for me, this is not the final fix and if you want real smooth, it's better that you  use modified DLL or custom refreshrate discussed below.



UPDATE 1:

CruelToot user in steam community has created a modified DLL that link FEZ framerate to refreshrate. This is his message in steam:

I made a modified MonoGame.Framework.dll that makes the game much smoother for me. It basicaly locks the game logic updates to the the screen updates. I uploaded the modified file here http://pastelink.me/dl/9bc3a2. Just replace the one in your FEZ folder. I have one tested the first few minutes of the game, so I don't know if it breaks any puzzles or anything like that. Vsync needs to be enabled or the game will in way to fast. And if your machine is too slow to do a solid 60 fps I think what will happen is that the game will run in slow motion. Hopefully this will help at least some of you. 

Link of message: FEZ steam discussion
Link of DLL file: CruelToot DLL fix for judder

NOTE: Replace DLL file (make a copy of the original file first) into steam FEZ folder. Some users have detected a higher CPU use with this DLL. In my case the CPU use is 35%. Remember to force Vsync ON for perfect and smooth gameplay. If you don't want to replace the file, you can use the first fix detailed below.


****************************************************



Finally I decided to enter some info about games beyond Crysis series.

I preordered FEZ in steam weeks ago and downloaded few minutes after realease. Inmediatly I notice an annoying judder. Every second the game miss one or two frames producing constant and periodic pauses.

Using FRAPS you can see FEZ is limited to something near 58 fps and you can't fix that.


My first suspicion was that the FixedTimeStep plus an incorrect TimeStep period value into the game are creating this problem (set_IsFixedTimeStep and set_TimeStep are the related variables into FEZ source). I created a program to modify windows timer resolution but I find it's impossible to rise timer period if any other program has set a lower value. This is a normal behaviour for windows timer resolution to avoid a new launched program can set a lower resolution (higher value) that interfere with the proper operation of an application previously launched and still running.

Then I tested ArtMoney to modify variables values into FEZ process while runing, but the blind test was useless. Too many variables with similar values.

Finally I used MSI Afterburner to identify a more precise value of FEZ framerate and then create a custom resolution with that refreshrate. This is my actual solution and provides a perfect smooth framerate.

Maybe you need to use MSI Afterburner to identify the exact FEZ framerate in your computer if it's not the same than in my case.

FEZ framerate in my computer is 57.7 fps. FRAPS shows 58 fps.

Steps to create a custom resolution (this is a step list for nvidia users):

- Open Nvidia control panel
- Go to Screen -> Adjust size and position
- Select Aspect Ratio mode
- Scaling in GPU
- Go to Screen -> Change resolution
- Click in Customize.. button
- Click in New custom resolution button
- Resolution showed must be your native resolution. Don't touch Horizontal pixels
- Reduce vertical lines in 2 units (1200 to 1198, 1080 to 1078, etc depends of your native resolution)
- Set Refreshrate to 57
- Click in Sync/standard -> Manual
- Change the vertical refresh rate in the bottom right to 57.750
- Click "Test"
- After monitor test the new resolution, if all is ok, click Yes button to save the resolution.
- Don't bother is Control Panel shows your custom resolution refreshrate as exact 58 hz, internally will be different because the representation is a rounded integer.


Start FEZ and look the judder during zooming to FEZ letters. Enter into the options menu and select the new resolution (1920x1198, 1920x1078, or whatever). Restart the game and if everything is perfectly fluid, it went well. Good luck and enjoy that awesome game as must be.


10 comments:

  1. I'm Nuninho.

    I tried to apply 58.600 Hz at manual in NVCP but 58.000 due to integer only. :(

    ReplyDelete
    Replies
    1. Don't worry, the number showed is always rounded but internally works with decimals you put.

      Delete
  2. Hey there, developer here :)

    What did you do on the MonoGame DLL code-wise? I'd like to change the code itself because I'm probably going to keep working on changes on MonoGame and can't use a fixed binary like this.

    It's pretty amazing that you got it fixed without the source!

    ReplyDelete
  3. It's just a hack and not a fix.
    It changes the line
    this._accumulatedElapsedTime += this._gameTimer.Elapsed;
    into
    this._accumulatedElapsedTime += this._targetElapsedTime;
    in Tick()

    Which basically simplifies the entire function down to:
    DoUpdate(targetElapsedTime);
    DoDraw();
    With no sleep or anything.

    So the game always runs perfectly in sync with the screen.
    But if the machine is too slow to do a solid 60fps or vsync is off the game will run at the wrong speed.

    ReplyDelete
  4. Some thoughts for a more general solution
    Perhaps one could keep some of the logic and just check if the last frame was longer than 16.6 ms and do an extra DoUpdate() to catch up for slower machines.
    Unfortunately I don't have any machine that can't do 60 fps so I have no way to test it.

    This would still break if the screen is not 60HZ or vsync is off.

    ReplyDelete
  5. Hi, thanks for the response.

    I'll add a CLI flag to do what you hack did, at least people that had success with your hack will be able to use it without replacing the DLL.

    MonoGame already does some of the logic you describe, and it's pretty sensitive stuff, so I'll leave it at that for now. Once the larger issues are resolved I can test with a beta branch on Steam and see what works.

    ReplyDelete
  6. I feel honored for this conversation. Thank you both.

    ReplyDelete
  7. File is missing , please put it somewhere more sensible than a file dump.

    Usenet , torrent etc are options with acceptable longevity without a single point of fuck-it-upitude .

    Thnx in advance for placing it somewhere else.

    Or , if aforementioned command line parameter is already implemented , please specify it.
    (for me starting fez.exe has it complaining I haven't got steam running in the background , which I have.)

    Thnx.

    ReplyDelete
  8. Could you rehost CruelToots dll. The link does not work anymore. :-(

    ReplyDelete