# Same image in both eyes of VR HMD results in wrong 3D effect

I am trying to mod in VR support for a game without VR support via OpenVR as it proved to be the easiest one to implement with the least amount of issues, i don't think my issue is related to OpenVR but i am just asking for help.

The code i use for rendering the images to the HMD can be found below, i use ReShade for now as a base that has all DirectX functions hooked already so i can test things more easily.

_backbuffer variable is just a regular ID3D11Texture2D buffer received from the swap chain by using _swapchain->GetBuffer function.

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;
}


So does anyone have any ideas on how do i solve this problem, some things i can think of are settings custom texture bounds with vr::VRTextureBounds_t in vr::VRCompositor()->Submit or/and settings vr::EVRSubmitFlags in the same function.

Normally you would just create two cameras, set their respective render targets, get their textures and use vr::VRCompositor()->Submit to render each frame independently, but i can't figure a way to do it in my case so i just submit same back buffer to both eyes.

Also, i have concerns that if i keep doing it that way and somehow fix the double-image effect the depth effect won't work properly (Although i hope i can fix that by applying some ReShade effects as i am using it as a framework)

And before someone will offer Depth3D effect for ReShade, i obviously tried that before, all it does in my case is just renders image 4 times instead of 2 (I tried tweaking parameters for that shader but with no success), it almost works without any effects in ReShade so i think i just have to tweak it on DirectX/OpenVR level, not with a custom shader.

• Without being able to render the scene from two different cameras, I don't think it is possible to replicate the stereoscopic 3d effect which vr hmd use. You might be able to get closer to the effect if you crop out a small amount from the right edge of the left image and crop out a small amount from the left side of the right image. You reduce the effective fov of each eye and don't get the different perspective, but the faux separation of the images may help with the effect. Sep 11 '20 at 18:23
• Do you have access to the depth buffer from the game's rendering? If so, you may be able to use a shader to distort the back buffer image according to the depth buffer values, to reconstruct some of the parallax. The downside is anything occluded from the main camera's viewpoint won't be visible from your shifted eye viewpoints, so you'll see something like stretched pixels or other artifacts in those areas. Sep 11 '20 at 20:56
• I got around by tweaking VRTextureBounds_t as i assumed originally, here's the code for anyone interested  const vr::VRTextureBounds_t vrTextureBounds[2] = { { 0.0f, 0.0f, 0.5f, 1.0f }, { 0.5f, 0.0f, 1.0f, 1.0f } };  Sep 12 '20 at 16:33