How to get depth buffer from different camera prespective

2 weeks 5 days ago - 2 weeks 5 days ago #1 by CAMINOonPC
Hello, i am trying to mod in VR support to a game that doesn't have VR support, i have chosen OpenVR as my primary API for that purpose, but the question here has nothing to do with the OpenVR for the most part, i use ReShade as a base for my mod since it has all DirectX hooks set up and ready.

vr::Texture_t leftEyeTexture = { _backbuffer.get(), vr::TextureType_DirectX, vr::ColorSpace_Auto };
vr::EVRCompositorError error1 = vr::VRCompositor()->Submit(vr::Eye_Left, &leftEyeTexture);

vr::Texture_t rightEyeTexture = { _backbuffer.get(), vr::TextureType_DirectX, vr::ColorSpace_Auto };
vr::EVRCompositorError error2 = vr::VRCompositor()->Submit(vr::Eye_Right, &rightEyeTexture);

if (error1)
std::cout << "[TF2VR] [ERROR] IInterfaces::IVR texture error: " << error1 << std::endl;

if (error2)
std::cout << "[TF2VR] [ERROR] IInterfaces::IVR texture error: " << error2 << std::endl;

This code is rendering image to the left and the right eye in the HMD via OpenVR API, it takes ID3D11Texture2D texture for each eye, for this test i have set it to use regular back buffer, the problem with this is that since that back buffer is taken from the same perspective, it makes that flat image appears in both eyes, and since the image is the same and not taken from different perspectives, it makes for a weird effect that looks like two images overlapping each other (Basically messing around with brains depth perception) so for example, when i load in-game i see two guns, one in the left eye and one in the right eye while obviously character is holding only one gun, pretty much same example for the main menu, i see the game title, options and everything else twice.

Screenshots describing my problem can be found bellow.

That's how the game supposed to looks like:

And that's how the game looks like in my VR headset, i have recreated the image in photoshop since its impossible to capture:

Ideally, if i somehow could take back buffer values from any shader, such as Depth3D directly in C++, that would do the job just fine, but i am really not that familiar with shaders and everything that's related to them yet, so if someone can help me out with this issue please do, this is really the last major issue that im having with making this mod, once its done it will be open-source, obviosly, and potentially game-changing for VR as a whole as since headsets aren't just external displays anymore you can't just launch the game and apply effects as you could in DK2 days so this will allow any game to be launched in full VR via OpenVR (SteamVR) and it will have full 6DOF movement support (At least initially for the game that i am working with right now but it should be easy to scale it up for other games as long as you can get a way to control camera movement and rotation) and full input mapping without need to map controllers via different software. <3
Last edit: 2 weeks 5 days ago by CAMINOonPC.

Please Log in or Create an account to join the conversation.