[VR] Camera Target Eye RenderTexture

Hi,

I am trying to build a simple HeadUp Display for a vehicle in VR (Oculus).

My plan was to use three cameras. One normal main camera, which renders everything except HUDContent layer and two HUDCamera that are identical but render only HUD Content to two RenderTextures, one for left eye and one for right eye. Next I have got a HUD plane mesh in the vehicle windshield with a simple shader that reads the render textures and overlays the HUDContent.

The problem is that changing the target eye in the camera does not affect the rendertextures. It always renders left eye image no matter what is set there.

Some time ago I used a simple trick to “hijack” the main camera settings and manually render to texture.
AFAIK, it worked fine for HoloLens but doesn’t work anymore

public class RenderToTexture : MonoBehaviour
{

    public Camera cam;
    public Camera cam2;

    public RenderTexture tex;

    public LayerMask mask;
    public Camera.StereoscopicEye eye2;
    public StereoTargetEyeMask eye;

    // private void OnPreRender()
    private void OnPreRender()
    {

        cam2.CopyFrom(cam);
        //cam2.SetStereoProjectionMatrix(eye, cam.GetStereoProjectionMatrix(eye));
        cam2.targetTexture = tex;
        cam2.projectionMatrix = cam.GetStereoProjectionMatrix(eye2);
        cam2.stereoTargetEye = eye;
        cam2.backgroundColor = Color.clear;
        cam2.clearFlags = CameraClearFlags.Color;
        cam2.cullingMask = mask;
        cam2.Render();
    }


}

Any ideas

Thanks

1 Like

Any luck with this? Trying to make a stereoscopic camera…