Search Unity

Resolved Stereo quad buffer rendering(without HMD)

Discussion in 'SRP Dev Blitz Day 2022 - Q&A' started by peaj_metric, Sep 29, 2022.

  1. peaj_metric

    peaj_metric

    Joined:
    Sep 15, 2014
    Posts:
    146
    Is stereo quad buffer rendering still supported with the new SRPs?

    I have a big project that heavily relies on stereo quad buffer and custom projection matrices and would like to port it to URP in the near future.
    I could not find anthing about stereo rendering with URP or HDRP and I am a little concerned as it is an often overlooked feature that broke multiple times even during built in times.

    Is it even possible to customize it or create my own solution with SRP or is it to low level and ineccessible?
     
  2. ThomasZeng

    ThomasZeng

    Unity Technologies

    Joined:
    Jun 24, 2019
    Posts:
    86
    Hi
    We did not tested stereo quad buffer support in SRP and this will likely require pipeline customization. But I believe you could achieve it by modifying URP/SRP codebase.
    I would suggest to take a look at XRSystem
    https://github.com/Unity-Technologi...es/com.unity.render-pipelines.core/Runtime/XR

    The XRRenderPass is configured by querying Display here: https://github.com/Unity-Technologi...er-pipelines.core/Runtime/XR/XRSystem.cs#L279
    If you could inject projection matrices here, URP and HDRP should pick them up.
     
  3. peaj_metric

    peaj_metric

    Joined:
    Sep 15, 2014
    Posts:
    146
    Thanks, its a starting point. Although a bit overwhelming.
    I see how I could inject matrices and render passes there, but is there any API to activate quad buffer in directX or OpenGL in the first place?
     
  4. ThomasZeng

    ThomasZeng

    Unity Technologies

    Joined:
    Jun 24, 2019
    Posts:
    86
    I would check if Unity Scripting API supports that.

    Another possible way to achieve this is to write your own XRSDK provider. You could get it through here: https://create.unity.com/vsp-signup-form
    XRSDK provider works like a unity native plugin where you could have access to low level Graphics Device and manage the eye textures.
     
  5. peaj_metric

    peaj_metric

    Joined:
    Sep 15, 2014
    Posts:
    146
    The only thing I could find regarding Unitys Scripting API was this:
    Code (CSharp):
    1. PlayerSettings.virtualRealitySupported = true;
    2. UnityEditorInternal.VR.VREditor.SetVREnabledDevicesOnTargetGroup(BuildTargetGroup.Standalone, new string[] { "stereo" });
    Which is setting the legacy setting from code and seems to work up until Unity 2020.
    Seems like Stereo support is patched out completely afterwards.

    So I guess I will try to apply for the XRSDK access and see what I can do.
     
    Last edited: Nov 18, 2022
    ThomasZeng likes this.
  6. peaj_metric

    peaj_metric

    Joined:
    Sep 15, 2014
    Posts:
    146
    Hey @ThomasZeng,

    I finally got the time to actually try out implenting a custom XRSDK provider.
    Although the bee.exe included in the sample does not work (https://forum.unity.com/threads/missing-artifact-when-building-unity-xr-sdk.1499006/) I got it to build with Rider.

    So far I don't see how I would be able to implement quadbuffer support though.
    I need to set the PixelFormatDescription before window creation like glut or glfw do:

    Code (CSharp):
    1. glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_STEREO);
    Code (CSharp):
    1. glfwWindowHint(GLFW_STEREO, true);
    I guess I would have to do that in PreInit which I also got setup but I dont see a way to influence the creation of the main window and render targets.

    Is this even possible or would I have to create my own window with its own render targets and let Unity render into it.
    If so wouldnt that create problems with user input as the Unity window would not be the active one?

    I hope you can give me a hint where to go from here.
     
  7. ThomasZeng

    ThomasZeng

    Unity Technologies

    Joined:
    Jun 24, 2019
    Posts:
    86
    Hey @peaj_metric,

    Unfortunately I don't have an answer to your questions.

    XRSDK is good at proving you low level control about XR rendering and XR inputs. It usually handles it's own backbuffer(and eye textures). IIRC it doesn't influence main window render targets.
     
  8. lefevren

    lefevren

    Joined:
    Sep 18, 2014
    Posts:
    3
    Hi @peaj_metric This thread is noted as resolved, can you tell how you get it working ? I need this feature but whithout help, it will be very hard !

    Thanks !

    Nicolas