Skip to main content
Inspiring
October 19, 2016

[Gear VR] Rendering UMG widget in StereoLayer component - how? (BP only)

I am failing to display anything in StereoLayer component, not even a simple texture is being rendered. Ultimately I'd like to have UMG widget there so that I could put various messages in front of player when needed.

Is it even possible? Can someone please show me how ?

Thanks

P.S. I hope it's not more "expensive" than having conventional 3D widget in front of the camera
    This topic has been closed for replies.

    22 replies

    motorsepAuthor
    Inspiring
    October 20, 2016

    rpalandri said:

    Then, instead of rendering the 3D widget into the world as they do in the tutorial, use the generated texture as input for your StereoLayer.

    I should do a sample of that. 


    Yes please, sounds pretty confusing :blush:
    Participant
    November 14, 2016

    rpalandri said:

    StereoLayer is most definitively a way better option to clarify the text, it's 100% the right tool to use. It does need a texture as input though, and the current best way (I think) to render a UMG to a texture is the 3D widget. Then, instead of rendering the 3D widget into the world as they do in the tutorial, use the generated texture as input for your StereoLayer.

    I should do a sample of that. 


    Have you succeeded in this?
    Participant
    November 18, 2016
    Hello, sorry about the wait

    Enclosed is a test project that renders a very simple UMG Widget-based UI to a texture, then uses that texture as a quad layer. I was mistaken in my belief that the 3D widget was the best way to do this. There is actually a  simpler way, which is to use Epic's WidgetRenderer class. It's only in C++, so I wrapped it in a blueprint function library, that you can copy into your project.

    In my sample, in Blueprints, you'll find NewUserWidget, which is the UMG widget, and Menu, the actor containing the widget (of class NewUserWidget). In Menu, you'll notice that in the Event Graph, I have an event tick that every frame renders the widget to a TextureRenderTarget2D I defined in the Content section (as shown on the screenshot). That "Widget to Texture" blueprint function is the one that I defined in the C++ function library.  The TextureRenderTarget2D is then used as input for a stereo layer :) 

    This works on both Rift and GearVR. The input should be pretty straightforward if using buttons like the GearVR touchpad and others, but a bit more involved if using the head gaze as input. We would need to raytrace the head gaze / touch gaze against the quad to figure out where the user is aiming, but that's for another day!


    motorsepAuthor
    Inspiring
    November 18, 2016
    Sounds cool, but if I understand correctly it won't work with stock UE4 (from launcher), correct ?
    Participant
    November 18, 2016
    It works perfectly with stock UE4 :)
    November 19, 2016

    motorsep said:

    Sounds cool, but if I understand correctly it won't work with stock UE4 (from launcher), correct ?


    It's a C++ project which still works fine with all your existing blueprints ;)

    Thanks for sharing @rpalandri looking forward to checking this out soon!
    motorsepAuthor
    Inspiring
    November 19, 2016



    motorsep said:

    Sounds cool, but if I understand correctly it won't work with stock UE4 (from launcher), correct ?


    It's a C++ project which still works fine with all your existing blueprints ;)


    Ouch :/ But my project is BP-only. How would I add this functionality to my BP-only project?

    @rpalandri Is it possible for you to submit this to Epic for 4.15 release?

    Participant
    November 22, 2016
    Alrighty so there is actually a way to make this work with only blueprints, it seems. Enclosed is the modified version of the LayerUI project that is now Blueprint-only. Basically, the Widget Component has an optional Material parameter. If that parameter is not null, the Widget Component will create a Dynamic Material Instance, and create a texture parameter in that instance whose name is "SlateUI", and render the widget to that texture. 

    In blueprints, if we get that material instance, get the texture named "SlateUI", and set the stereo layer's texture to it, it works. The blueprint below shows this (we need to grab both the StereoLayer, the WidgetComponent, and link them together. We also need to only do this once, after the first render of the widget, due the boolean in the blueprint). One of the issues is that this will only work if the actor containing the UI is visible, otherwise the UI won't render to the texture. In that project, I set that actor in the field of view, but looking backwards, so that we don't see its UI and only see the StereoLayer.

    I'd like to add that no project is Blueprint-only though, you can still add C++ classes to extend UE4's functionality. There are plenty of function libraries out there (like the one I sent) that can really help you, especially on a new medium like VR :)


    motorsepAuthor
    Inspiring
    November 22, 2016
    Thanks a bunch @rpalandri

    C++ isn't my thing (formally I am not a programmer) and I'd rather focus on art/design, which is my thing :) That's why I avoid messing with C++ as much as possible  :o
    motorsepAuthor
    Inspiring
    December 17, 2016
    @rpalandri

    Apparently Stereo Layers are too heavy for Gear VR to handle :/ Performance drop is massive when StereoLayer with 1 image is in the view with the rest of the level.

    Btw, turning visibility off for BP actor with Stereo Layer component hides actor, but not the component. So it renders all the time and I am not even sure how to disable it on demand :(

    Actually it has nothing to do with StereoLayers. Turned out that ES3.1 + ASTC performs worse on Gear VR than ES2 + ETC2, and by worse I mean ~20 fps worse.

    https://www.youtube.com/watch?v=2n5fLpbHWjU

    Simple StereoLayer :) Too bad that async level streaming is so hitchy in UE4 :(