[Oculus Go] OVROverlay with cubemap - HOWTO ? — Oculus
Welcome to the Oculus Developer Forums!

Your participation on the forum is subject to the Oculus Code of Conduct.

In general, please be respectful and kind. If you violate the Oculus Code of Conduct, your access to the developer forums may be revoked at the discretion of Oculus staff.

[Oculus Go] OVROverlay with cubemap - HOWTO ?

LabulleCreationLabulleCreation Posts: 19
NerveGear
edited May 2018 in Unity Development
I'm new to Unity and Oculus development and can't get OVROverlay to work, at all.
I'm developping for Oculus Go, everything is set up correctly, I guess (even if the documentation is really lacking IMHO), I can build and send my app to the Go and see whatever I put there (a cube, for instance !).
My goal for now is simple : render a high quality stereoscopic cubemap using overlay, as this seems to be the best option quality-wise.

Of course, I've carefuly read the official documentation : https://developer.oculus.com/documentation/unity/latest/concepts/unity-ovroverlay/ and tried to research all I could, but can't get it to display anything. BTW, why the doc is mentionning the OVRRTOverlayConnector script, which is nowhere to be found ?
I'm using latest everything (Unity 2018.1.0f2 and Oculus Utilities 1.25.2).

For now in my scene there is an OVRCameraRig, a gameobject (empty) with OVROverlay script as a component (I've also tried adding OVR Manager as seen in the screenshot in official docs, and Mesh filter quad, but I don't understand what it does) and a simple cube. I've also tried to clear the skybox, with no effect apart from removing the sky... As you can see, I'm really lost, and even with a solid experience with internet research, there is quite nothing clear about all of this :)

Could somebody point me in the right direction for using OVROverlay to display a cubemap ?

Thank you very much !


Comments

  • LabulleCreationLabulleCreation Posts: 19
    NerveGear
    Hi, thank you very much for your answer.

    Great for the OVRRTOverlayConnector script, it simplifies the process, I'm looking forward for your guidance on the implementation then!
  • LabulleCreationLabulleCreation Posts: 19
    NerveGear
    edited June 2018
    I've tried with Unity 2017.4.3f and the latest Oculus Utilities and managed to display a stereo cubemap as an Overlay ! That's great, however I'm now really stuck and spent some time trying to wrap my head around some C# programming in Unity with OVROverlay.

    My goal now is to swap my cubemap on button press.

    My first approach has been to activate and deactivate alternatively two GameObjects (each containing the OVROverlay with my cubemaps) with a parent GameObject containing my script. Apparently it does kinda work, but there's a huge glitch after the first switch (the glitch pattern is changing when the switch occurs) :


    My second approach was to have only one overlay per scene and switch them, but for some reason the scene does not change. However, I have the intuition that it's not the most elegant way to do it.

    My third and current attempt has been to research how to directly swap the textures, but it's way over my comprehension right now. How to load the new textures ? How to swap them on runtime ? It has to be possible, the doc seems to mention something about it :
    "\note If you need to change the texture on a per-frame basis, please use OverrideOverlayTextureInfo(..) to avoid caching issues."
    "Texture [] textures ( )
    Try to avoid setting texture frequently when app is running, texNativePtr updating is slow since rendering thread synchronization Please cache your nativeTexturePtr and use OverrideOverlayTextureInfo"

    I have some background in programming, but I'm really new to Unity scripting and C# language, so it's really difficult to put the puzzle together, any help would be really appreciated !

    Thanks

    EDIT :
    I have managed to assemble some things and get the OverrideOverlayTextureInfo() function to work ! I had to also check "Is Dynamic".
    However, the switch is not synchronized between the eyes and it's obviously a bit rough.
    I don't know if the second argument of the function (IntPtr nativePtr) refers to the NativeTexturePtr of the original texture, or the new texture ? It seems to work with the NativeTexturePtr of the new texture, but isn't it the reason of the switch slowness ?
    I'm using the function two times, for each eye, is there a way to switch textures in sync ? Right eye always blinks when the switch occurs (and on first load also - however with "Is Dynamic" switched off, the loading is smooth but the whole swap does not work at all).

    My code :
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class CC_OverlayTextureSwitch : MonoBehaviour {

    public Cubemap leftTex;
    public Cubemap rightTex;

    private IntPtr[] overlayTexturePtrs = new IntPtr[2];

    // Use this for initialization
    void Start () {

    leftTex = Resources.Load("LEFT") as Cubemap;
    rightTex = Resources.Load("RIGHT") as Cubemap;

    overlayTexturePtrs[0] = leftTex.GetNativeTexturePtr();
    overlayTexturePtrs[1] = rightTex.GetNativeTexturePtr();

    }

    // Update is called once per frame
    void Update () {

    if (OVRInput.Get(OVRInput.Button.PrimaryIndexTrigger))
    {

    this.GetComponent<OVROverlay>().OverrideOverlayTextureInfo(leftTex, overlayTexturePtrs[0], UnityEngine.XR.XRNode.LeftEye);
    this.GetComponent<OVROverlay>().OverrideOverlayTextureInfo(rightTex, overlayTexturePtrs[1], UnityEngine.XR.XRNode.RightEye);

    }

    }
    }

    To wrap things up :
    What is the best way to display high quality stereo cubemaps in unity in the form of a basic slideshow ? (with maybe later on some hotspots to navigate)


  • LabulleCreationLabulleCreation Posts: 19
    NerveGear
    edited June 2018
    I've reverted to the per scene approach, as I've managed to switch scenes, it works fine with an Overlay with "Overlay" type, but I have a problem with the "Underlay" type (as I ideally want to use the Overlay as a high resolution Skybox and display hotspots and maybe some text in front of it) : the exposure of the map is completly blown up !

    I have borrowed the map from the project shared in this thread, to eliminate the possibility that my maps have a problem (they managed to display it fine !).

    My scene is simple :
    - OvrCameraRig added
    - GameObject empty with the script OVROverlay as a component : in Textures, 2 slots with the same map in each
    - Skybox disabled (SkyBox Material None)

    Overlay type :


    Underlay type :


    Help ! I'm so close each time :smile:

    EDIT : there seems to be a blue tint each time, however I don't know why, as my ambient light is set to black (and I've tried different colours).
  • vrdavebvrdaveb Posts: 1,596 Oculus Staff
    > the documentation is really lacking

    Agreed. We will update it for the current behavior and try to make it a bit more instructive.

    > why the doc is mentionning the OVRRTOverlayConnector script, which is nowhere to be found ?

    Thanks for catching this. OVRRTOverlayConnector is no longer necessary - OVROverlay should "just work" with RenderTextures and other dynamically-changing textures.

    > I've also tried adding OVR Manager as seen in the screenshot in official docs, and Mesh filter quad, but I don't understand what it does

    OVRManager maintains the Oculus Utilities within your app. It communicates with the SDK and exposes tracking and rendering features not built into Unity. You don't need the mesh filter for a cubemap layer. It's there for convenience if you want a world-locked quad layer to fall back to regular eye buffer rendering some of the time (such as if there are too many for the compositor to render at once).

    > My first approach has been to activate and deactivate alternatively two GameObjects (each containing the OVROverlay with my cubemaps) with a parent GameObject containing my script.

    This should work, but you will need the latest Utilities (https://developer.oculus.com/downloads/package/oculus-utilities-for-unity-5), where we have fixed some bugs with re-activating OVROverlay instances. There were also some fixes for GameObjects that persist between scene loads.

    > hotspots to navigate

    If you mark the OVROverlay as an Underlay and set the skybox material to clear to alpha=0, then the content you render to the eye buffers will appear on top of the cubemap, allowing you to show a navigation UI.

    > the exposure of the map is completly blown up !

    This is probably a change in Unity's sRGB behavior, which we worked around in the new 1.26 Utilities I linked above.

  • LabulleCreationLabulleCreation Posts: 19
    NerveGear
    edited June 2018
    Thank you so much for your answer !

    This should work, but you will need the latest Utilities (https://developer.oculus.com/downloads/package/oculus-utilities-for-unity-5), where we have fixed some bugs with re-activating OVROverlay instances. There were also some fixes for GameObjects that persist between scene loads.
    Unfortunately, I already have the latest Oculus Utilities (my last two posts test results from June are already done with 1.26 and Unity 2017.4.3f - installed from scratch and imported in a new project), so the activation of OVROverlay instances may still be bugged ? Should I try with a different branch of Unity (2018) ?

    If you mark the OVROverlay as an Underlay and set the skybox material to clear to alpha=0, then the content you render to the eye buffers will appear on top of the cubemap, allowing you to show a navigation UI.
    So it got me thinking, as the ONLY thing I've been doing was to set my Skybox material to None (no other setting adjusted), being new to Unity I've found that the camera have some role to play here, and I've tried a bunch of things :

    - the blown up map you see on my screenshots, with a blue tint, was related to the color of the Background in CenterEyeAnchor, as my Skybox material was set to None, so the fallback of "Clear Flags : Skybox" was the background I guess (so the same as setting Clear Flags to Solid Color ?). However, when the alpha of this color is set to 0, nothing changes (the tint is here, following whatever color I set), but when I krank up the alpha value, it's more and more opaque, alpha=0 is not considered as the lowest value here I guess !

    - I've then tried to change the Skybox material in Lighting, trying all Skybox shaders, not populating them with maps but adjusting the color value and trying with the alpha of the colors with no success at all

    - finally, I've created a new material with the "Oculus/UnderlayImpostor" shader (I can't find any doc on that either) and... it worked ! However, I'm really not sure if it's because it's not a real skybox material and therefore it doesn't render the Skybox at all (wich is great, but I wonder about side effects ?), or because it's meant for something like this

    If I understand it correctly though, you say that I should set my Skybox material to alpha=0, and that is certainly a thing I have no clue how to do properly. Could you give some advice for a "clean" way to do it please ?

    Thanks again !

    EDIT : I've done a last test, I've made a Material with a Standard shader, Rendering mode set to Fade and an alpha 0 color in Albedo, and it's working when selected as the Skybox material. Is this the correct way to do it ?


  • sycxsycx Posts: 23
    Brain Burst
    To remove the blue tint with Underlay type. You should change your camera's background color. make sure the alpha is 0
  • LabulleCreationLabulleCreation Posts: 19
    NerveGear
    Thanks sycx, but as I said, my alpha is 0 in my camera background color and it is still affecting the cubemaps (but when I set, say, 128 for alpha, the background is more present, and with 255 the underlay isn't visible at all, as if the 0 value was never really considered as 0) :smile:

    So my only option was to create a transparent material for my skybox, as opposed to set my skybox to None and set the background color of the camera to alpha 0.

  • LabulleCreationLabulleCreation Posts: 19
    NerveGear
    edited June 2018
    I have another question : when I'm viewing my stero cubemaps in Oculus 360, the resolution of the images is much higher.
    Is there a way to match this quality or is it a limitation of Unity and only a native app could achieve this ?
  • LabulleCreationLabulleCreation Posts: 19
    NerveGear
    edited June 2018
    @imperativity any news on that topic ?

    As you certainly know, you have simply removed the possibility to display stereo cubemaps on the Go by removing the functionnality from Oculus 360 Photos and not replacing it in the Gallery, I've commented on several threads about the issue.
    So now, as Unity seems my only way out, is this even possible to match this (gone) quality in Unity ? Or is this technically impossible and the Go is now magically downgraded (regarding the high quality it can deliver) for many people in the archviz field ?

    I've also tried to alter the eyebuffer resolution, which doesn't affect the overlay at all.
  • vrdavebvrdaveb Posts: 1,596 Oculus Staff
    In Utils 1.26 and 1.27, OVROverlay's cubemap support should work as expected.

    I've created a new material with the "Oculus/UnderlayImpostor" shader (I can't find any doc on that either) and... it worked !
    Sorry, our docs should have mentioned this. I will get them updated. To render 3D geometry on top of the cubemap (or any other OVROverlay), you need to make it an underlay and "poke a hole" where it will appear by using our "Underlay Impostor" shader. Try assigning a Skybox Component to your Camera(s) with a material like this:
  • fuzzy3dfuzzy3d Posts: 1
    NerveGear
    edited August 16
    I am using "standart" Unity (2018.3.12f1) skybox with over/under stereoscopic texture 4096x4096 from V-Ray and I think quality is very very good.






  • Clifton88Clifton88 Posts: 1
    NerveGear
    edited August 24
    I have managed to assemble some things and get the OverrideOverlayTextureInfo() function to work ! I had to also check "Is Dynamic".
    However, the switch is not synchronized kodi between the eyes and it's obviously a bit rough.
    I don't know if the second argument of the function (IntPtr nativePtr) refers to the NativeTexturePtr of the original texture, or the new texture ? It seems to work with the NativeTexturePtr of the new texture, but isn't it the reason of the switch slowness ?
    I'm using the function two times, for each eye, is there a way to switch textures in sync ? Right eye always blinks when the switch occurs (and on first load also - however with "Is Dynamic" switched off, the loading is smooth but the whole swap does not work at all).
Sign In or Register to comment.