Skip to content

Repository files navigation

Second version of the GTA 5 machinima VR tracked camera mod. Supports both Legacy and Enhanced GTA 5. Lots of bugs present. Requires Script Hook V .Net by Chiheb-Bacha Put OpenXrCameraController.3.cs in the scripts folder

Requires an OpenXR compatible VR headset (or SteamVR)

OpenXR Camera Controller

This project contains a ScriptHookVDotNet camera controller plus a control panel that hosts the OpenXR bridge in-process. The current setup is monitor-only: the headset drives the in-game scripted camera, but the project does not submit rendered frames to the HMD yet.

Files

  • OpenXrCameraController.3.cs
    • Main ScriptHookVDotNet v3 script.
    • Toggles XR camera mode in game.
    • Reads live settings from Local\GTA5OpenXrControl and headset pose from Local\GTA5OpenXrPose.
  • OpenXrCameraController.ini
    • Persistent settings file used by the control panel.
  • OpenXrControlPanel\
    • External WinForms control panel.
    • Edits OpenXrCameraController.ini.
    • Pushes live setting changes and commands into the Local\GTA5OpenXrControl shared-memory block.
    • Hosts the OpenXR bridge in-process and publishes headset/controller data into Local\GTA5OpenXrPose.

Default Controls

  • F10 enables or disables OpenXR camera mode once the control panel has published settings.
  • F11 faces the in-game camera north while keeping the current device pitch and roll.
  • PageUp zooms in.
  • PageDown zooms out.
  • Home resets zoom.
  • While XR mode is active, left grip nudges FarDepthOfField down and right grip nudges it up.

Current Behavior

  • Uses headset tracking for camera orientation.
  • When tracking first activates, the in-game camera starts at your current real-world rotation instead of inheriting the previous gameplay camera heading.
  • Positional tracking follows the active headset/controller forward direction, so moving forward physically moves forward in-game for the current tracking source.
  • Supports positional tracking when EnablePositionTracking=true.
  • Can track the headset or a simplified LeftController / RightController source.
  • Uses a scripted render camera instead of the normal gameplay camera.
  • Supports manual zoom by adjusting the scripted camera field of view.
  • Supports scripted-camera depth of field tuning for cinematic shots.
  • Supports camera-position nudging from VR thumbsticks while XR mode is active.
  • Can stay active in vehicles when AutoSuspendOffFoot=false.
  • Supports anchor targets for vehicles, standing vehicles, and the player character instead of only freezing in world space.
  • Accepts live config updates and runtime commands from the external control panel.
  • Automatically suspends when the game is paused, a cutscene is active, or the player is not on foot and AutoSuspendOffFoot=true.
  • Automatically resumes when conditions are valid again and XR mode is still enabled.

Configuration

The control panel persists settings in OpenXrCameraController.ini, then publishes them to Local\GTA5OpenXrControl for the script to read.

[Input]
ToggleKey=F10
RecenterKey=F11
ZoomInKey=PageUp
ZoomOutKey=PageDown
ResetZoomKey=Home

[Tracking]
EnablePositionTracking=true
TrackingSource=Headset
TranslationScale=1.0

[Behavior]
AutoSuspendOffFoot=false
HideHud=false
EnablePlayerAnchor=false
EnablePlayerAnchorYaw=false

[Vehicle]
EnableVehicleAnchor=true
EnableStandingVehicleAnchor=false

[Zoom]
ZoomStep=1.0
MinFieldOfView=25.0
MaxFieldOfView=90.0

[Smoothing]
RotationSmoothingSeconds=0.04
PositionSmoothingSeconds=0.06
ZoomSmoothingSeconds=0.08

[DepthOfField]
DepthOfFieldStrength=0.0
NearDepthOfField=0.0
FarDepthOfField=0.0
  • ToggleKey and RecenterKey use System.Windows.Forms.Keys names. RecenterKey remains the config name for the Face North action for backward compatibility.
  • TranslationScale=1.0 keeps headset translation at full scale.
  • Set EnablePositionTracking=false if you only want rotational tracking.
  • TrackingSource=Headset uses the HMD. LeftController and RightController use the selected hand's controller pose.
  • Set AutoSuspendOffFoot=false if you want XR camera mode to keep running while driving or riding in a vehicle.
  • Set HideHud=true if you want the HUD and radar hidden while XR camera mode is enabled.
  • Set EnablePlayerAnchor=true to make the anchor follow the player character's position while on foot.
  • Set EnablePlayerAnchorYaw=true to also rotate the player anchor with the character's facing yaw. This only applies when EnablePlayerAnchor=true.
  • Set EnableVehicleAnchor=true to make the camera ride with the current vehicle while seated in it, while keeping the anchor orientation stable.
  • Set EnableStandingVehicleAnchor=true to anchor to the vehicle under the player when standing on top of it.
  • If multiple anchor options are enabled at once, priority is EnableVehicleAnchor, then EnableStandingVehicleAnchor, then EnablePlayerAnchor, then world-space anchoring.
  • Zoom Speed changes how quickly the right-stick zoom adjusts the field of view.
  • Disable Roll removes camera bank so you do not get a Dutch angle.
  • MinFieldOfView and MaxFieldOfView clamp the zoom range.
  • The smoothing values are in seconds. 0 means instant, and larger values add more easing/lag.
  • RotationSmoothingSeconds, PositionSmoothingSeconds, and ZoomSmoothingSeconds are independent, so you can keep rotation snappy while softening movement or zoom.
  • DepthOfFieldStrength=0 disables the effect. Increase it and tune NearDepthOfField / FarDepthOfField to shape focus falloff.
  • The Far DOF slider in the control panel uses a standard linear 0 to 10 range.

Startup Flow

When you press F10, the script waits for live OpenXR pose data on Local\GTA5OpenXrPose. That data is provided by OpenXrControlPanel while it is running.

The embedded OpenXR host follows a capability-first initialization flow:

  1. Resolve the active OpenXR runtime registration and locate openxr_loader.dll.
  2. Enumerate available API layers and instance extensions.
  3. Enable required and optional extensions.
  4. Create the OpenXR instance and log the runtime name/version.
  5. Resolve the OpenXR system id.
  6. Enumerate supported view configurations and choose PrimaryStereo first, then PrimaryMono.
  7. Create a headless session.
  8. Enumerate supported reference spaces and choose Local as the tracking space.
  9. Create Local and View reference spaces.
  10. Enter the steady-state event and pose loop.

Log Output

OpenXrControlPanel.OpenXr.log records richer startup diagnostics, including:

  • active runtime registration and runtime library
  • available API layers
  • available extensions
  • enabled extensions
  • runtime name/version
  • system id
  • supported and chosen view configuration
  • supported and chosen tracking space
  • timing fallback availability and usage

Requirements

  • ScriptHookV.dll
  • ScriptHookVDotNet.asi
  • ScriptHookVDotNet3.dll
  • A working 64-bit OpenXR runtime

This setup has been tested primarily against SteamVR-style runtimes, but it is designed to negotiate capabilities instead of assuming one exact runtime layout.

Building

The project has two compile paths:

  • OpenXrControlPanel is the WinForms app and embedded OpenXR host, built with dotnet.
  • OpenXrCameraController.3.cs is compiled by ScriptHookVDotNet when GTA loads scripts.

Build the control panel from OpenXrControlPanel\:

dotnet build

Or publish it:

dotnet publish -c Release -o publish

The camera script does not need a separate manual compile step. Place these in GTA V's scripts folder:

  • OpenXrCameraController.3.cs
  • OpenXrCameraController.ini

The control panel can run outside GTA. Point it at OpenXrCameraController.ini, then use:

  • Apply Live to push current settings into the shared control map
  • Reset Defaults to restore the built-in factory camera values without reloading from disk
  • Save .ini to persist them for future sessions
  • Toggle XR, Face North, Reset Zoom, Start Record, Stop + Save, and Stop + Discard for runtime commands
  • Tracking Source to swap between the headset and the left/right controller live
  • Left Thumbstick nudges the camera anchor left/right and forward/back, while Right Thumbstick Y nudges it up/down

Then launch OpenXrControlPanel, launch GTA V, or press Insert to reload scripts and let ScriptHookVDotNet compile the script. The script waits for the control panel to publish settings before it becomes usable.

Troubleshooting

  • If the script does not compile, check ScriptHookVDotNet.log in the GTA V root folder.
  • If the script loads but tracking does not start, make sure OpenXrControlPanel is running and that a 64-bit OpenXR runtime is installed and registered.
  • If the control panel starts but pose data is not available, check OpenXrControlPanel.OpenXr.log.
  • If the camera feels wrong, use F11 to face north while keeping your current device pitch and roll, then tune TranslationScale, Zoom Speed, the smoothing values, or the zoom FOV limits in the .ini.
  • If you are using the control panel, you can adjust the same values live without restarting scripts.
  • If startup fails, the bridge log should now show which stage failed: loader resolution, extension negotiation, system discovery, view-configuration selection, reference-space selection, or timing fallback.

Notes

  • This is not full VR rendering.
  • Headset mirroring and swapchain submission are intentionally not part of the current build.
  • It is head-tracked flatscreen camera control.
  • Older test files like RotateCameraOnL.cs are separate from this OpenXR setup.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages