diff --git a/README.md b/README.md index a73fcc9..5cf9c45 100644 --- a/README.md +++ b/README.md @@ -17,8 +17,8 @@ Only Windows was tested. It may build on Linux, but there are other solutions on | `window_height` | `int` | The height of the application window. | `1080` | | `aspect_ratio` | `float` | The aspect ratio used to calculate vertical FoV | `1.77778` | | `fov` | `float` | The field of view (FoV) for the VR rendering. | `90.0` | -| `depth` | `float` | The max depth. Overrides VR's IPD field. | `0.065` | -| `convergence` | `float` | Where the left and right images converge. Adjusts frustum. | `0.0` | +| `depth` | `float` | The max depth. Overrides VR's IPD field. | `0.5` | +| `convergence` | `float` | Where the left and right images converge. Adjusts frustum. | `0.1` | | `tab_enable` | `bool` | Enable or disable top-and-bottom (TaB) 3D output (Side by Side is default) | `false` | | `half_enable` | `bool` | Enable or disable half SbS/TaB 3D output. | `true` | | `ss_enable` | `bool` | Enable or disable supersampling. | `false` | @@ -35,6 +35,8 @@ Only Windows was tested. It may build on Linux, but there are other solutions on - Edit the `Steam\steamapps\common\SteamVR\drivers\vrto3d\resources\settings\default.vrsettings` as needed - Run SteamVR - Try launching a VR game +- Adjust Depth with `Ctrl+F3` and `Ctrl+F4` +- Adjust Convergence with `Ctrl+F5` and `Ctrl+F6` ## Notes @@ -49,6 +51,7 @@ Only Windows was tested. It may build on Linux, but there are other solutions on - OpenXR games/mods seem to be more likely to work and be stable than OpenVR ones - HDR doesn't seem to work currently - Several mods/games may override your supersample and other settings +- Depth and Convergence are saved to your `Steam\config\steamvr.vrsettings` when SteamVR is closed. There are only global settings, no per-game ones. ## Building diff --git a/vrto3d/src/hmd_device_driver.cpp b/vrto3d/src/hmd_device_driver.cpp index 727f3a8..34d9594 100644 --- a/vrto3d/src/hmd_device_driver.cpp +++ b/vrto3d/src/hmd_device_driver.cpp @@ -215,7 +215,7 @@ void MockControllerDeviceDriver::DebugRequest( const char *pchRequest, char *pch //----------------------------------------------------------------------------- -// Purpose: Center position for Stereo 3D +// Purpose: Static Pose, Depth and Convergence Hotkeys //----------------------------------------------------------------------------- vr::DriverPose_t MockControllerDeviceDriver::GetPose() { @@ -256,11 +256,11 @@ void MockControllerDeviceDriver::PoseUpdateThread() } // Ctrl+F5 Decrease Convergence if ((GetAsyncKeyState(VK_CONTROL) & 0x8000) && (GetAsyncKeyState(VK_F5) & 0x8000)) { - stereo_display_component_->AdjustConvergence(-0.001f); + stereo_display_component_->AdjustConvergence(-0.001f, device_index_); } // Ctrl+F6 Increase Convergence if ((GetAsyncKeyState(VK_CONTROL) & 0x8000) && (GetAsyncKeyState(VK_F6) & 0x8000)) { - stereo_display_component_->AdjustConvergence(0.001f); + stereo_display_component_->AdjustConvergence(0.001f, device_index_); } // Update our pose every 30 milliseconds. @@ -458,11 +458,31 @@ void StereoDisplayComponent::AdjustDepth(float delta, uint32_t device_index) //----------------------------------------------------------------------------- // Purpose: To update the Convergence value //----------------------------------------------------------------------------- -void StereoDisplayComponent::AdjustConvergence(float delta) +void StereoDisplayComponent::AdjustConvergence(float delta, uint32_t device_index) { float cur_conv = GetConvergence(); float new_conv = cur_conv + delta; while (!convergence_.compare_exchange_weak(cur_conv, new_conv, std::memory_order_relaxed)); + + float left, right, top, bottom; + vr::HmdRect2_t eyeLeft, eyeRight; + + GetProjectionRaw(vr::Eye_Left, &left, &right, &top, &bottom); + eyeLeft.vTopLeft.v[0] = left; + eyeLeft.vTopLeft.v[1] = top; + eyeLeft.vBottomRight.v[0] = right; + eyeLeft.vBottomRight.v[1] = bottom; + + GetProjectionRaw(vr::Eye_Right, &left, &right, &top, &bottom); + eyeRight.vTopLeft.v[0] = left; + eyeRight.vTopLeft.v[1] = top; + eyeRight.vBottomRight.v[0] = right; + eyeRight.vBottomRight.v[1] = bottom; + + vr::VREvent_Data_t temp; + + vr::VRServerDriverHost()->SetDisplayProjectionRaw(device_index, eyeLeft, eyeRight); + vr::VRServerDriverHost()->VendorSpecificEvent(device_index, vr::VREvent_LensDistortionChanged, temp, 0.0f); } diff --git a/vrto3d/src/hmd_device_driver.h b/vrto3d/src/hmd_device_driver.h index a5a7ded..2cf02ec 100644 --- a/vrto3d/src/hmd_device_driver.h +++ b/vrto3d/src/hmd_device_driver.h @@ -58,7 +58,7 @@ class StereoDisplayComponent : public vr::IVRDisplayComponent void GetWindowBounds( int32_t *pnX, int32_t *pnY, uint32_t *pnWidth, uint32_t *pnHeight ) override; StereoDisplayDriverConfiguration GetConfig(); void AdjustDepth(float delta, uint32_t device_index); - void AdjustConvergence(float delta); + void AdjustConvergence(float delta, uint32_t device_index); float GetDepth(); float GetConvergence(); @@ -93,7 +93,6 @@ class MockControllerDeviceDriver : public vr::ITrackedDeviceServerDriver std::array< vr::VRInputComponentHandle_t, MyComponent_MAX > my_input_handles_{}; std::atomic< bool > is_active_; std::atomic< uint32_t > device_index_; - std::atomic< int > frame_number_; std::thread pose_update_thread_; }; diff --git a/vrto3d/vrto3d/resources/settings/default.vrsettings b/vrto3d/vrto3d/resources/settings/default.vrsettings index e00c918..ff26257 100644 --- a/vrto3d/vrto3d/resources/settings/default.vrsettings +++ b/vrto3d/vrto3d/resources/settings/default.vrsettings @@ -11,8 +11,8 @@ "window_height": 1080, "aspect_ratio": 1.77778, "fov": 90.0, - "depth": 0.065, - "convergence": 0.0, + "depth": 0.5, + "convergence": 0.1, "tab_enable": false, "half_enable": true, "ss_enable": false,