Skip to content

elliotttate/OpenXR-Simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

OpenXR Simulator

License: MIT Platform OpenXR

A lightweight OpenXR runtime that enables VR applications to run in a desktop window for development and testing without requiring a physical VR headset.

KAJUqBgmzewBPq9YkMDsm5AwsucqBaUY6gw2eMLX

๐ŸŽฏ Features

  • Desktop VR Preview - Run VR applications in a resizable desktop window with side-by-side stereo view
  • Mouse & Keyboard Controls - Navigate the virtual space using standard input devices
  • Proper sRGB Handling - Automatic gamma correction for accurate color reproduction
  • Unity Compatible - Fully tested with Unity's OpenXR plugin
  • Minimal Dependencies - Only requires Windows and DirectX 11
  • Easy Setup - Simple PowerShell scripts for registration/unregistration

๐Ÿš€ Quick Start

Prerequisites

  • Windows 10/11 (64-bit)
  • DirectX 11 compatible GPU
  • Visual Studio 2022 (for building from source)
  • CMake 3.20 or later (for building from source)

Installation

  1. Download the latest release from the Releases page
  2. Extract the archive to your preferred location
  3. Run PowerShell as Administrator
  4. Navigate to the scripts folder
  5. Run .\register-runtime.ps1 to set as active OpenXR runtime
cd C:\Path\To\OpenXR-Simulator\scripts
.\register-runtime.ps1

Usage

Once registered, any OpenXR application will automatically use the simulator:

  1. Launch your VR application (e.g., Unity project with OpenXR)
  2. A desktop window will appear showing left/right eye views
  3. Use the following controls:
    • Mouse: Look around (hold right-click)
    • WASD: Move forward/backward/strafe
    • Q/E: Move up/down
    • Shift: Move faster
    • ESC: Release mouse capture

Uninstallation

To restore your previous OpenXR runtime:

cd C:\Path\To\OpenXR-Simulator\scripts
.\unregister-runtime.ps1

๐Ÿ› ๏ธ Building from Source

Clone the Repository

git clone https://github.com/yourusername/OpenXR-Simulator.git
cd OpenXR-Simulator

Build with CMake

mkdir build
cd build
cmake .. -G "Visual Studio 17 2022" -A x64
cmake --build . --config Release

The built runtime will be in build/bin/Release/openxr_simulator.dll

๐Ÿ“– Technical Details

Architecture

The simulator implements the OpenXR runtime interface, intercepting all OpenXR calls from applications:

  • Instance & Session Management - Handles OpenXR instance creation and session lifecycle
  • Swapchain Rendering - Creates D3D11 swapchains that applications render into
  • View Composition - Blits stereo views to a desktop window using optimized shaders
  • Input Simulation - Converts mouse/keyboard input to head pose and controller data

Supported Features

  • โœ… Core OpenXR 1.0 specification
  • โœ… D3D11 graphics binding (XR_KHR_D3D11_enable)
  • โœ… Win32 time conversion (XR_KHR_win32_convert_performance_counter_time)
  • โœ… Multiple swapchain formats (sRGB, UNORM, HDR)
  • โœ… Stereo rendering with configurable FOV
  • โœ… Reference space tracking (LOCAL, STAGE, VIEW)
  • โœ… Basic action system for input

Limitations

  • โŒ No hand tracking
  • โŒ No haptic feedback
  • โŒ No foveated rendering
  • โŒ Limited to seated/standing experiences
  • โŒ No OpenGL/Vulkan support (D3D11 only)

๐ŸŽฎ Configuration

Field of View

The default FOV is set to 70ยฐ for comfortable desktop viewing. To modify, edit the FOV value in src/runtime.cpp:

// In xrLocateViews_runtime function
views[i].fov = { -0.7f, 0.7f, 0.7f, -0.7f }; // tan(35ยฐ) โ‰ˆ 0.7

Window Size

Default preview window is 1920x540 (960x540 per eye). Modify in runtime.cpp:

static UINT g_persistentWidth = 1920;  // Total width
static UINT g_persistentHeight = 540;  // Height

Background Color

The preview window background can be customized:

const float clearColor[4] = {0.1f, 0.1f, 0.2f, 1.0f}; // Dark blue

๐Ÿ› Troubleshooting

Application doesn't use the simulator

  1. Verify registration:
Get-Content "$env:LOCALAPPDATA\openxr\1\active_runtime.json"
  1. Check for conflicting API layers:
reg query "HKLM\SOFTWARE\Khronos\OpenXR\1\ApiLayers\Implicit"
  1. Ensure no other VR runtime is running (SteamVR, Oculus, etc.)

Colors appear washed out

  • Disable any OpenXR API layers that modify rendering
  • Ensure your application uses sRGB swapchain formats
  • Check that no post-processing is double-applying gamma

Preview window doesn't appear

  • Check the log file: %LOCALAPPDATA%\OpenXR-Simulator\openxr_simulator.log
  • Verify D3D11 support on your system
  • Try running the application as administrator

Performance issues

  • Reduce swapchain resolution in your application
  • Disable MSAA if enabled
  • Close other GPU-intensive applications

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

Development Setup

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • Khronos Group for the OpenXR specification
  • OpenXR SDK for headers and loader interfaces
  • Unity OpenXR Plugin team for compatibility testing
  • Community contributors and testers

๐Ÿ“ž Support

๐Ÿ—บ๏ธ Roadmap

  • Linux support via Vulkan
  • Configurable controller emulation
  • Multi-monitor support
  • Recording and playback functionality
  • OpenXR validation layer integration
  • GUI configuration tool

Note: This is a development tool and not intended for end-user VR experiences. For production VR applications, use a proper VR headset and runtime.

About

A lightweight OpenXR runtime for desktop VR preview without physical headset

Resources

License

Stars

Watchers

Forks

Packages

No packages published