How recent Unity games do stuff, and a new GeDoSaTo version

Dreamfall Chapters: Book 1 was just released (go buy it), and it’s another game using the Unity engine. Like with another recent Unity title, Wasteland 2, it refused to work with GeDoSaTo. Now, since I like both of these games a lot I invested some time to find out what’s happening, and hopefully fix it.

Without further ado, here are my findings. This is what recent Unity engine games do on Windows if you select “fullscreen” mode. Note that all of this is based on deduction from the behaviour of Dreamfall and Wasteland 2, someone with access to the Unity source probably has a more exact understanding:

  1. Check the desktop resolution and create a fullscreen window as well as a DirectX device with that size.
  2. Check the native monitor resolution (using GetMonitorInfo), and reset the device/window to that size.
  3. Render at whatever resolution you specify in the game settings, to an off-screen surface.
  4. Stretch that surface to the window.

So, no real fullscreen mode in sight. Why would you do this? Well, it has multiple advantages: you don’t lose your resources switching to another rendering resolution, alt-tab behaviour is much faster and more stable, and you get free, correctly implemented triple buffering if the user is using Aero.

Obviously, this majorly messed up the way GeDoSaTo works — and the same goes for traditional downsampling methods. In the latest version, it’s now possible to downsample Unity games following this scheme, provided you add this magic formula to their configuration file:

It works by “pretending” that both the desktop and monitor are the given renderResolution in size, forcing that to always be reported, and modifying the mouse cursor position used by the game (so that clicks register correctly). GeDoSaTo takes care of actually constraining the fullscreen window to the correct size, and of course performs a high-quality downsampling of the rendering result as always.

Since the resolution you want to downsample from needs to be known before the game requests any, only a single rendering resolution can be provided.

Cursor Sidenote

Already in earlier versions, a problem in games using windowed modes was that custom cursors would be lost outside of the rectangular region corresponding to portion of the screen that would be taken up by a window downscaled by the downsampling factor. I figured out why this happens: To make games work, the cursor positions reported to them need to be adjusted (modifyGetCursorPos). This works for any processing within the game, as it thinks it is operating within a larger rendering area.

However, an issue occurs for cursors: I found out that many/most games use the Windows API WindowFromPoint function to check if the mouse is within their window before setting the cursor, passing the modified coordinates. Now obviously, Windows knows what the real window sizes are, and the modified virtual coordinates fall out of them. So I had to apply the reverse transformation in that function.

Release

Anyway, the new version is called “Tokikagura”. Other than the stuff discussed above it also includes some GeDoSaToTool fixes.

As always, grab the installer here or simply update, and if you want to you can donate here.

By the way, Nvidia’s DSR can’t downsample in these games (for now). Take that big boy corporate version!

14 thoughts on “How recent Unity games do stuff, and a new GeDoSaTo version

  1. It doesn’t seem to be working for me. Or it’s not showing the usual “game downsampled from X resolution” thingy when it loads up.

    Maybe the patch broke it?

  2. “By the way, Nvidia’s DSR can’t downsample in these games (for now).”

    DSR isn’t available on Vista either, so all we have is GeDoSaTo.. for DX9 at least.

    • In the latest version, they are already there.
      (For future reference, you can quickly navigate to a settings file by clicking “Edit Settings” and writing e.g. “dream” in the filter box.)

  3. I just tried Risen 3 with “Tokikagura” and it still shows the problem of the mouse pointer leaving the main screen when using 2 monitors…

    Still, thanks for all your work!

  4. This also turned out to be the fix for some GameMaker games that don’t let you change the resolution.

  5. For those of us who detest aero (desktop composition is sadly forced off without it), is there any chance you could make it possible to force true fullscreen at all?

     

    Stuck between a rock and a hardplace at the moment, can’t stand the tearing, can’t stand the big rounded edges UI. :(

  6. Bro, this tool is so freaking awesome.  I just can’t imagine playing Dishonored, NFS HP and more without it.

  7. Glad to see you’ve picked up Dreamfall Chapters. I am also a fan.

     

    I won’t be using Gedosato for this until they fix some of the performance issues, I’m getting ~20FPS in most areas despite the fact that my machine can run Alien Isolation on max settings, and Rome 2 on pretty decent settings, both while maintaining higher frame rates. I think Unity has some inherent optimisation issues. Anyway, I won’t be trying to downscale higher resolutions until they’ve sorted this out.

     

    Really happy to hear you are supporting it, though.

    • Yeah, the game currently has performance issues. Still, it’s a lot more beautiful than I expected, considering the budget.

Leave a Reply to EmpiresBane Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">