Search Unity

Single Pass Stereo rendering from script with custom stereo matrices

Discussion in 'AR/VR (XR) Discussion' started by Frooxius, Mar 28, 2019.

  1. Frooxius

    Frooxius

    Joined:
    Aug 15, 2012
    Posts:
    57
    Hello,

    I am trying to optimize mirror rendering for my VR project, which is using single pass rendering (double wide). Currently mirrors use multi pass rendering, with two separate Camera.Render() calls.

    I'd like to utilize the single pass stereo rendering that's used for the main view for this as well. I have tried setting custom view/projection matrices via camera.SetStereoViewMatrix(...) and set the target render texture as VRTextureUsage.TwoEyes, but the camera still performs monoscopic rendering.

    Is there a way to use the single pass stereo rendering from scripts in Unity? And if not, is it possible to add this feature in the future?

    Any help is greatly appreciated!
     
  2. Jamy4000_Absolute

    Jamy4000_Absolute

    Joined:
    Oct 18, 2017
    Posts:
    5
    Hi there,
    Did you succeed to create this effect ? I'm a bit struggling with this issue as well and would love to have your input ... Thanks !
     
  3. Frooxius

    Frooxius

    Joined:
    Aug 15, 2012
    Posts:
    57
    Hello!

    Yes, you have to add a CommandBuffer to the camera passes with the SetSinglePassStereo command: https://docs.unity3d.com/ScriptReference/Rendering.CommandBuffer.SetSinglePassStereo.html

    However when I tried this with custom matrices I encountered another bug, where it doesn't work for the Opaque queue no matter what I do (adding the command to the Opaque queue actually changes the Transparent instead). I have reported this to Unity and they managed to replicate it, but I'm not sure if it's been fixed yet or not.
     
    holo-krzysztof likes this.
  4. avandenberg

    avandenberg

    Joined:
    Nov 22, 2018
    Posts:
    23
    Would it be possible for you to share the code on how to set this up?
     
  5. avandenberg

    avandenberg

    Joined:
    Nov 22, 2018
    Posts:
    23
    please? :p