Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug Oculus - Single-Pass Render to Texture (Array) - 2nd slice is always empty

Discussion in 'VR' started by Sanyol, Apr 4, 2022.

  1. Sanyol

    Sanyol

    Joined:
    Jan 28, 2013
    Posts:
    24
    Hello,

    After 2 days I tried all possible solutions and engine versions and I just can't get it to work - the 2nd slice is always empty.

    In VR SinglePass Stereo rendering the output is made to TextureArray with 2 slices. The main camera has 2 slices rendered correctly (I can see the RT in OnRenderImage), but the camera with custom RenderTexture always renders to 1st or 2nd slice.

    What I tried:

    Texture is based on eyeTextDesc:

    Code (CSharp):
    1. RenderTextureDescriptor descript = UnityEngine.XR.XRSettings.eyeTextureDesc;
    2. descript.vrUsage = VRTextureUsage.TwoEyes;
    3. descript.volumeDepth = 2;
    Rendering is made in the 'OnPreRender' call from MainCamera (this makes the output with distortion mesh, but still only one slice)

    I am setting buffers for camera:
    Code (CSharp):
    1.  
    2. renderCamera.SetTargetBuffers(rtColor.colorBuffer, rtDepth.depthBuffer);;
    and also trying to tell Graphics to bind 2 slices (by the last parameter -1) but it still won't do that ( it detects if I pass 0 or 1 as an argument to render to 1st or 2nd slice but never both for -1)
    Code (CSharp):
    1. Graphics.SetRenderTarget(rtColor,  0, CubemapFace.Unknown, -1);;
    Render Camera is configured to render both eyes

    I really don't want to make 2 separate passes for left/right eye so any help will be truly appreciated.

    There is thread for using command buffers:
    https://forum.unity.com/threads/com...s-instanced-renders-only-to-left-eye.1026310/

    but I need to render the whole scene to target texture (not just copy the orginal one, because I need to render custom objects with this pass)
     
    Last edited: Apr 4, 2022
  2. jacobian

    jacobian

    Joined:
    Jul 20, 2015
    Posts:
    17
    any luck
     
  3. Sanyol

    Sanyol

    Joined:
    Jan 28, 2013
    Posts:
    24
    I don't think it is supported in any way (I tried every possibility)
     
  4. jacobian

    jacobian

    Joined:
    Jul 20, 2015
    Posts:
    17
    Ahh thanks, yeah I found some other stuff saying similar. If I remember correct.
     
  5. weiner_monkey

    weiner_monkey

    Joined:
    Aug 1, 2022
    Posts:
    49
    I was able to render single passed instanced to both eyes using the CommandBuffer API, maybe you could try that
     
    jacobian likes this.
  6. jacobian

    jacobian

    Joined:
    Jul 20, 2015
    Posts:
    17
    ooh interesting, thanks, not sure when i will get ack to that though