{"id":14961565,"url":"https://github.com/godotvr/godot_openvr","last_synced_at":"2025-05-16T17:10:01.738Z","repository":{"id":25831354,"uuid":"106561541","full_name":"GodotVR/godot_openvr","owner":"GodotVR","description":"GDExtension-based OpenVR (SteamVR) module","archived":false,"fork":false,"pushed_at":"2025-01-09T20:24:15.000Z","size":87974,"stargazers_count":236,"open_issues_count":54,"forks_count":35,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-04-03T17:11:59.006Z","etag":null,"topics":["godot","godotengine","openvr"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/GodotVR.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-11T13:59:38.000Z","updated_at":"2025-03-09T16:13:07.000Z","dependencies_parsed_at":"2025-01-01T14:02:12.437Z","dependency_job_id":"8c46f03e-2c21-4bd3-8e2c-2097180a5899","html_url":"https://github.com/GodotVR/godot_openvr","commit_stats":{"total_commits":110,"total_committers":9,"mean_commits":"12.222222222222221","dds":0.2545454545454545,"last_synced_commit":"8d4783b73fc713675085a0af43b7854a326ac6f6"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GodotVR%2Fgodot_openvr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GodotVR%2Fgodot_openvr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GodotVR%2Fgodot_openvr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/GodotVR%2Fgodot_openvr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/GodotVR","download_url":"https://codeload.github.com/GodotVR/godot_openvr/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248597924,"owners_count":21130980,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["godot","godotengine","openvr"],"created_at":"2024-09-24T13:25:42.645Z","updated_at":"2025-04-12T16:38:52.324Z","avatar_url":"https://github.com/GodotVR.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GDExtension based OpenVR plugin for Godot\n\n![GitHub forks](https://img.shields.io/github/forks/godotvr/godot_openxr?style=plastic)\n![GitHub Repo stars](https://img.shields.io/github/stars/godotvr/godot_openxr?style=plastic)\n![GitHub contributors](https://img.shields.io/github/contributors/godotvr/godot_openxr?style=plastic)\n![GitHub](https://img.shields.io/github/license/godotvr/godot_openxr?style=plastic)\n\nThis is a GDExtension based plugin that adds OpenVR support to Godot.\n\nThe leading version of this repository now lives at:\nhttps://github.com/GodotVR/godot_openvr\n\n\u003e\u003e **Important** this version of the OpenVR plugin now uses the OpenVR actions system.\n\u003e\u003e While we have taken care to try and keep a measure of backwards compatibility there are structural differences in how OpenVR handles actions and once enabled the old method of button and axis handling is deactivated.\n\u003e\u003e Please read the [OpenVR Actions documentation](https://github.com/GodotVR/godot-openvr-asset/wiki/OpenVR-actions) for more information!\n\n# Branches\nThis repo currently maintains the following branches:\n- `master` is our main development in which the latest version of this plugin resides. This version works with Godot 4.x.\n- `Godot-3.x` is our legacy branch in which we maintain our `1.x` version of this plugin. This version works with Godot 3.x.\n\n# Building\n\n## Submodules\nAfter cloning this repo, you should run:\n\n\tgit submodule update --init --recursive\n\nWe use the following submodules:\n\n* [godot-cpp](https://github.com/godotengine/godot-cpp): C++ bindings to Godot's internal classes. This has a submodule of its own, godot-headers.\n* [OpenVR](https://github.com/ValveSoftware/openvr): the repository maintained by Valve that contains the OpenVR SDK used to interact with the OpenVR/SteamVR platform.\n\nThe godot-cpp module is pointed at the branch corresponding to the specific release of Godot that we're currently supporting. 2.x of this extension has only been tested with OpenVR 2.0+.\n\nOpenVR can also be stored elsewhere using the `openvr_path=` build argument, or discovered automatically from the system if you're using a mingw/linux build environment. See Build variables below.\n\n## Compiling\nSCons is used for compiling this module. This is also the build mechanism for Godot and information on installing it on various platforms can be found in [the Godot documentation](https://docs.godotengine.org/en/stable/contributing/development/compiling/introduction_to_the_buildsystem.html).\n\nYou must compile the `godot-cpp` submodule first by executing:\n\n\tcd godot-cpp\n\tscons platform=windows target=template_release generate_bindings=yes arch=x86_64\n\tscons platform=windows target=template_debug arch=x86_64\n\tcd ..\n\nYou can then compile this extension by executing:\n\n\tscons target=release\n\tscons target=debug\n\nThe results will be placed within the extension's addon hierarchy in the included demo. This entire hierarchy (demo/addons/godot-openvr on downward) is then distributable.\n\n### Build variables\nThere are many CLI flags that can be given to scons to manipulate how the extension is created:\n\n* `target`: `release` or `debug`. Controls whether debug symbols are built into the extension and also sets appropriate compiler optimization flags.\n* `platform`: `windows` or `linux`. Controls whether we build a DLL or shared library.\n* `target_path`: The path where the native library for the extension is placed after building, defaults to `demo/addons/godot-openvr/bin/`.\n* `target_name`: Name of the native library, defaults to `libgodot_openvr`,\n* `use_mingw`: Use the Mingw compiler, even if the Visual Studio compiler is available (mostly useful on Windows).\n* `use_llvm`: Use the LLVM compiler (clang).\n* `use_static_cpp`: Link MinGW/MSVC C++ runtime libraries statically. Defaults to `yes` to simplify distribution and match godot-cpp.\n* `bits`: `32` or `64`. Target CPU architecture, defaults to 64.\n* `builtin_openvr`: Use the OpenVR library from our submodule. Defaults to `yes`, see below for how to use a system OpenVR.\n* `openvr_path`: The path where the OpenVR repo is located, if `builtin_openvr` is used. Defaults to `openvr/`.\n\nSetting `builtin_openvr=no` will cause pkg-config to be invoked to search for a `libopenvr_api` installed on your system. pkg-config normally only exists on Linux systems, but can be installed on Windows using the mingw toolchain.\n\nWhen overriding any of these flags, care should be taken to build godot-cpp with the same flags where they exist. We have attempted to make them match in most cases, though the targets are different and `bits` is instead `arch={x86_64,x86_32}`.\n\n**In particular, when building for use in the editor you should compile godot-cpp with `target=template_debug` and this extension with `target=debug`.**\n\nSee the Windows platform-specific notes below for further info about mingw and potential pitfalls.\n\n## Deploying\nThe finished GDExtension must be shipped with Valve's `openvr_api.dll` (Windows) or `libopenvr_api.so` (Linux). This is handled automatically by the build system whenever possible. The expected res:// paths of the library can be found in godot\\_openvr.gdextension.\n\n## Running the demo\nTo use the demo you will additionally need to install the godot-xr-tools addon, which is available in the asset library within the editor. For alternative installation methods, see [the documentation](https://godotvr.github.io/godot-xr-tools/docs/installation/).\nAfter installing, you will need to make sure it is enabled and then restart the editor.\n\nIf you are building yourself, the demo should now be runnable. If you want to test it out without building, you can download the package from the latest Github actions build, unzip it, and replace the addons/godot-openvr directory with the one from the zip. Note that the debug build is not currently included in the package.\n\n# Platform-specific notes\n\n## Linux\nOn Linux, Steam will not automatically add the SteamVR libraries to your `$LD_LIBRARY_PATH` variable. As such, when starting Godot (for development) or your game outside of Steam, it will fail to load the required libraries.\n\nThere are a couple of ways to fix this:\n\n1) Launch Godot or your game from within Steam\n\n2) Run Godot or your game through the steam runtime manually (change the path to suit your Steam installation):\n\n\t/home/$USER/.steam/steam/ubuntu12_32/steam-runtime/run.sh \u003cyour command\u003e\n\n3) Adjust your `$LD_LIBRARY_PATH` variable accordingly:\n\n\texport LD_LIBRARY_PATH=\"${LD_LIBRARY_PATH}:/path/to/libgodot_openvr.so/dir/:/home/$USER/.steam/steam/steamapps/common/SteamVR/bin/\"\n\n## Windows\nWindows generally works without any special needs. This has been compiled with MSVC 2019, and in the past has worked with 2017 and 2015. With 2017 and above be aware Microsoft now lets you pick and choose which components you install and by default it may not install the SDK you need. Make sure to install both the Windows SDK and build tools. To build using the MSVC compiler without needing to install the entire IDE, the build tools can be installed using winget:\n\n\twinget install Microsoft.VisualStudio.2019.BuildTools --override \"--quiet --add Microsoft.VisualStudio.Workload.NativeDesktop\"\n\nBuilding with scons should then work within the Developer Powershell it creates.\n\nAlso, depending on what version of Visual Studio that was used to compile the dlls, you will need to install the `Microsoft Visual C++ Redistributable for Visual Studio` on any machine that you deploy your dll on. Godot already needs one of these but if you compile with a newer version of Visual Studio you also need to install that version. It's dumb, I know. If you build statically (`use_static_cpp`), this is not necessary as the library is compiled into the extension. Note that mixing a statically included libc++ with other versions may cause unintended side effects.\nhttps://support.microsoft.com/en-au/help/2977003/the-latest-supported-visual-c-downloads\n\n### mingw\n\nBuilding on Windows under mingw means using the gcc c++ compiler. Because C++ does not have a stable ABI, the resulting binary cannot actually communicate successfully with SteamVR using the OpenVR C++ bindings. The fix for this is a header patch using [a script written by tunabrain](https://gist.github.com/tunabrain/1fc7a4964914d61b5ae751d0c84f2382). This script rewrites the C++ header to call the OpenVR C bindings internally, sidestepping the ABI mismatch. We do not currently attempt to run this script as part of our build, it is up to you to produce a patched header if using the submoduled libopenvr_api.\n\nWhen `use_mingw` is set, `USE_OPENVR_MINGW_HEADER` is exported during the build which will cause `openvr_mingw.hpp` to be included where `openvr.h` would be normally. You may place this file anywhere you like in the header search path.\n\nAs an alternative to manually providing `openvr_mingw.hpp`, the [msys2](https://www.msys2.org/) distribution which can provide mingw-w64 also packages OpenVR along with the patched header. Setting up your mingw toolchain using msys2 (only the UCRT64 environment has been tested) and setting `builtin_openvr=no` will allow the packaged library to be discovered during the build. Setting up an msys2 environment is out of scope for this README, but once it is installed the following command will get the environment ready to build this extension:\n\n\tpacman -S mingw-w64-ucrt-x86_64-toolchain mingw-w64-ucrt-x86_64-scons mingw-w64-ucrt-x86_64-openvr\n\nmsys2 also packages Godot and godot-cpp, but as of this writing they are still on the 3.x train and thus we must continue to build our own godot-cpp.\n\nAs an aside, it would seem necessary to also build Godot itself for the mingw-compiled C++ bindings to work, but I've had no issues running the extension in the official build of Godot 4.2.\n\n## MacOS\nMacOS support in OpenVR was dropped by Valve for a long time. While it appears it has recently made a return without much fanfare in OpenVR 2.0, support has not yet been returned to our build.\n\n# Shader hickup\nThere are a few moment where OpenVR has a hickup.\n\nOne is around the teleporter function which can be solved by adding the `VR_Common_Shader_Cache.tscn` as a child scene to our XRCamera3D. `ovr_first_person.tscn` does this.\n\nFor the controllers they use a standard material. Adding a mesh instance with a standard material will ensure the shader is pre-compiled. Again we do this in `ovr_first_person.tscn`.\n\nHowever there is still an issue with loading the texture. We need to redo loading of the controller mesh by handing it off to a separate thread.\n\n# Rendering\n\n## Using the main viewport\nThe XR server module requires a viewport to be configured as the XR viewport. If you chose to use the main viewport an aspect ratio corrected copy of the left eye will be rendered to the viewport automatically.\n\nYou will need to add the following code to a script on your root node:\n\n```\nvar interface = XRServer.find_interface(\"OpenVR\")\nif interface and interface.initialize():\n\tget_viewport().use_xr = true\n\n\t# make sure vsync is disabled or we'll be limited to 60fps\n\tDisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_DISABLED)\n\n\t# up our physics to 90fps to get in sync with our rendering (you may want to query the real headset value here instead)\n\tEngine.iterations_per_second = 90\n```\n\n## Using a separate viewport\nIf you want control over the output on screen so you can show something independent on the desktop you can add a SubViewport to your scene and enable \"Use XR\" on it.\n\nAlso make sure that both the Clear Mode and Update Mode are set to Always, or nothing will be rendered.\n\nYou can add a normal camera to your scene to render a spectator view or turn the main viewport into a 2D viewport and save some rendering overhead.\n\nThe initialization code on the root node will now look like this:\n\n```\nvar interface = XRServer.find_interface(\"OpenVR\")\nif interface and interface.initialize():\n\tDisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_DISABLED)\n\tEngine.iterations_per_second = 90\n```\n\n# License\nNote that the source in this repository is licensed by the MIT license model.\nThis covers only the source code in this repository.\n\nBoth Godot and OpenVR have their own license requirements.\nSee their respective git repositories for more details.\n\nThe subfolder `assets` contains third party assets.\nSee license files in those subfolders for additional license details\n\n# About this repository\nThis repository was created by and is maintained by Bastiaan Olij a.k.a. Mux213\n\nYou can follow me on twitter for regular updates here:\nhttps://twitter.com/mux213\n\nVideos about my work with Godot including tutorials on working with VR in Godot can by found on my youtube page:\nhttps://www.youtube.com/BastiaanOlij\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgodotvr%2Fgodot_openvr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgodotvr%2Fgodot_openvr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgodotvr%2Fgodot_openvr/lists"}