Skip to content

lyckantropen/moonlight_hdr_launcher

Repository files navigation

Moonlight HDR Launcher

Warning

GameStream has been discontinued and therefore using Moonlight HDR Launcher no longer makes sense. Go check out Sunshine which supports HDR streaming out of the box!

This is a launcher for GameStream that mocks Mass Effect Andromeda to launch any executable from a Shield device or Moonlight with HDR support. For example, it can be used in conjunction with gamestream_launchpad to launch GOG Galaxy 2.0 in HDR mode.

It is loosely based on a solution by tmac666 on NVIDIA forums.

The installer puts the files in C:\Program Files\moonlight_hdr_launcher and modifies the GeForce Experience entry for Mass Effect Andromeda to launch the mock executable.

Installing

Download latest release here.

Unzip and launch the installer. At some point there will be a dialog window asking you to rescan for games in GeForce Experience. Only then the last part of the script can succeed. The installer will try restarting GeForce Experience. Now in Shield or Moonlight you should see the new entry. If you're not seeing it, try rebooting your PC.

Note: I haven't been able to get the cover art to work for me. If you know how to do it, please reach out.

Description

GeForce Experience recognizes Mass Effect Andromeda as a game that supports HDR and will initiate a GameStream session with HDR support if it is launched.

This software provides a mock MassEffectAndromeda.exe and patches the NvBackend cache to launch it instead of the game.

The installation does the following:

  • Creates C:\Program Files\moonlight_hdr_launcher and puts MassEffectAndromeda.exe there along with an initial configuration file.
  • Sets write permissions for all users on C:\Program Files\moonlight_hdr_launcher.
  • Caches the location C:\Program Files\moonlight_hdr_launcher in registry (HKCU/lyckantropen/moonlight_hdr_launcher).
  • Searches <user folder>\AppData\Local\NVIDIA\NvBackend\StreamingAssetsData\ for the mass_effect_andromeda folder and patches StreamingSettings.json and metadata.json (the latter only for file checksums).

The MassEffectAndromeda.exe launcher does the following:

  • Queries the registry for the install location (C:\Program Files\moonlight_hdr_launcher by default.).
  • Forces setting the current directory to the install location.
  • Creates the moonlight_hdr_launcher_log.txt log file.
  • Looks for the moonlight_hdr_launcher.ini configuration file.
  • Creates a dummy window to please GameStream when ending the session.
  • Optionally attempts to enable HDR on all connected monitors with HDR support if both options.toggle_hdr and options.wait_on_process are set to non-zero (doing so when not waiting for the process to finish would disable HDR immenently because of NVAPI unloading).
  • Launches the options.launcher_exe command as a subprocess and optionally waits for it to terminate if options.wait_on_process is set to non-zero.

Configuration

The installer will offer a basic choice of launchers and resolutions to use as an initial configuration. Later on you can edit the file moonlight_hdr_launcher.ini file in C:\Program Files\moonlight_hdr_launcher and modify it to your needs. These are the options:

  • launcher_exe - the command to launch
  • wait_on_process - set to 1 to wait until the launcher_exe command completes
  • toggle_hdr - set to 1 to turn on HDR on all supported monitors for the time when launcher_exe is running (set this to 1 only when a HDR supported display is connected to the gamestream host)
  • compatibility_window - create a dummy window that will get detected by GameStream and allow for ending the session gracefully
  • remote_desktop - instead of launcher_exe, simply show the desktop; you need to close the dummy window in order to leave the session
  • res_x, res_y, refresh_rate - optionally you can set the desired display resolution, will be reset to the original display mode when done
  • refresh_rate_use_max - when setting a custom display mode, set this to 1 if you prefer to always set the maximum refresh rate instead of specifying it by hand

I highly recommend the setup using gamestream_launchpad. Simply put gamestream_gog_galaxy.ini and gamestream_launchpad.exe in C:\Program Files\moonlight_hdr_launcher and uncomment the relevant lines in moonlinght_hdr_launcher.ini. Note: As of 1.1.2 the installer will download gamestream_launchpad automatically.

Additional notes regarding macOS.

  • As of Moonlight version 2.2.0 the HDR stream is not rendered correctly, images appear very bright, there is significantly less contrast, not more. This is a known issue moonlight-stream/moonlight-qt#61
  • To enable HDR streams users need to edit the moonlight plist file located at ~/Library/Preferences/com.moonlight-stream.Moonlight.plist and set videocfg property to 3
    • Note, this property will periodically reset to 0, so if having trouble starting a HDR stream verify videocfg is set to 3.
  • You will know when a HDR stream is being delivered as in the debug overlay, you will see (Codec: HVEC Main 10) and HDR options can be enabled in-game.

Example configurations

HDTV & HDR monitor owners

If you have an HDR monitor connected to your PC or a DisplayPort dongle that supports HDR, you can rely on the toggle_hdr option.

This example will use gamestream_launchpad to launch GOG Galaxy. First step is to put gamestream_gog_galaxy.ini and gamestream_launchpad.exe in C:\Program Files\moonlight_hdr_launcher.

moonlight_hdr_launcher.ini:

[options]
launcher_exe = gamestream_launchpad.exe 2560 1440 gamestream_gog_galaxy.ini
toggle_hdr = 1
wait_on_process = 1

gamestream_gog_galaxy.ini:

[LAUNCHER]
launcher_path = %%programfiles(x86)%%\GOG Galaxy\GalaxyClient.exe
launcher_window_name = GOG Galaxy 2

[BACKGROUND]

[SETTINGS]
debug = 0
sleep_on_exit = 0
close_watch_method = window

Variant with compatibility_window=1:

This configuration allows for avoiding the "Connection terminated" message after quitting gamestream_launchpad. Requires gamestream_launchpad 0.8 for the --no-nv-kill option.

moonlight_hdr_launcher.ini:

[options]
launcher_exe = gamestream_launchpad.exe 2560 1440 gamestream_gog_galaxy.ini --no-nv-kill
toggle_hdr = 1
wait_on_process = 1
compatibility_window = 1

HDTV owners without HDR monitor

Update: For a while GameStream has been adding the entry for Steam Big Picture on its own as a separate cover and it does support HDR. The solution below is redundant. OS-level HDR games still won't work though.

Note: This will not make OS-level HDR games (e.g. Cyberpunk 2077) work. Buy a DisplayPort dongle with HDR support.

The only way (allegedly) to achieve HDR support is to launch Steam Big Picture through the launcher. Bear in mind that this solution creates sessions that need to be force-quit from Moonlight. This example does not use gamestream_launchpad. After starting the launcher, it is imperative that your game is in true fullscreen mode. "Windowed fullscreen" will not work.

Your mileage may vary.

moonlight_hdr_launcher.ini:

[options]
launcher_exe = C:\Program Files (x86)\Steam\steam.exe steam://open/bigpicture
wait_on_process = 0
# no HDR toggle because there are no HDR monitors and wait_on_process=0
toggle_hdr = 0

HDTV owners withouth HDR monitor (gamestream_launchpad version)

This is the same as the previous example, but using gamestream_launchpad.

moonlight_hdr_launcher.ini:

[options]
# launch Steam Big Picture using gamestream_launchpad
# please adjust resolution
launcher_exe = gamestream_launchpad.exe 2560 1440 gamestream_steam_bp.ini
wait_on_process = 1
toggle_hdr = 1

gamestream_steam_bp.ini:

[LAUNCHER]
launcher_path = %%programfiles(x86)%%\Steam\steam.exe steam://open/bigpicture Fullscreen
# set it to something other than Steam because gamestream_launchpad can detect multiple windows and will close prematurely
launcher_window_name = NotSteam

[BACKGROUND]

[SETTINGS]
debug = 0
sleep_on_exit = 0
close_watch_method = window

FAQ & Troubleshooting

  • I want to be able to play Mass Effect Andromeda while using this launcher.

    GameStream will add two separate entries and you will see two covers for Mass Effect Andromeda in Moonlight, but one will have the proper artwork and it's the one with the real game. In any case you are still able to launch Mass Effect Andromeda through the launcher you're running, be it GOG Galaxy 2 or Steam.

  • The installer keeps saying that it can't find the entry for Mass Effect Andromeda.

    • Force-quit GeForce Experience.
    • Remove C:\Program Files\moonlight_hdr_launcher or rename MassEffectAndromeda.exe to something else.
    • Restart GeForce Experience and scan for games.
    • Force-quit GeForce Experience or restart your PC.
    • Re-instate MassEffectAndromeda.exe or re-run the installer.
    • Scan for games in GeForce Experience.
  • I don't have an HDR monitor and I want to play Cyberpunk 2077 in HDR.

    You can't. Cyberpunk 2077 is an OS-level HDR game. You need at least a DisplayPort dongle that supports HDR.

  • Nothing happens when I run the "Mass Effect Andromeda" entry in Moonlight/Shield.

    Go to C:\Program Files\moonlight_hdr_launcher and try running the MassEffectAndromeda.exe file directly. See if the moonlight_hdr_launcher_log.txt file is being created. If reporting an issue, describe what happened and attach the log file.

    Go to <user folder>\AppData\Local\NVIDIA\NvBackend\StreamingAssetsData\ and see if the mass_effect_andromeda\<number>\ folder exists and contains StreamingSettings.json. If either do not exist, see the answer to The installer keeps saying that it can't find the entry for Mass Effect Andromeda..

    Check the write permissions on C:\Program Files\moonlight_hdr_launcher (should be write for all users).

  • I'd like to report an error.

    Create an issue in GitHub and attach:

    • moonlight_hdr_launcher_install.log (found alongside install.exe);
    • moonlight_hdr_launcher_log.txt (from C:\Program Files\moonlight_hdr_launcher);
    • all *.ini files from C:\Program Files\moonlight_hdr_launcher;
    • <user folder>\AppData\Local\NVIDIA\NvBackend\StreamingAssetsData\mass_effect_andromeda\<number>\StreamingSettings.json;

Building the launcher executable

  • Obtain NVAPI.
  • Install vcpkg.
  • Build with CMake, setting NVAPI_DL_PATH to the location of the NVAPI zip file and CMAKE_TOOLCHAIN_FILE to the location of your vcpkg toolchain file (e.g. C:\vcpkg\scripts\buildsystems\vcpkg.cmake).

If you don't know how to build projects with CMake, better not attempt it.

Building the installer

First, install Python 3. Then:

pip install -r requirements.txt
pyinstaller install.spec

install.exe will be put in dist.

Attribution

This code uses parts of hdr-switch by Brad Gearon under the following license:

MIT License

Copyright (c) 2020 Brad Gearon

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

This code uses the WinReg library by Giovanni Dicanio under the following license:

MIT License

Copyright (c) 2017-2020 by Giovanni Dicanio

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.