I’m experimenting with different approaches to UI design in VR. Currently I’m trying to use UMG to render some simple UI in 3D around the user. This works great, except when the UI clips behind an object in the level.
In the Couck Knights demo, the text that is displayed at the beginning (“Sit straight” etc) has no depth testing. When you turn your head around to look directly at the wall behind you, you can still see the text behind/through the wall. As far as I understand this is achieved by using a material for the text component that has Depth Testing disabled.
Is there a way to achieve something similar using UMG?
I managed to do this by slightly modifying WidgetComponent. I’ve added new material to Engine materials in "/Engine/EngineMaterials/
that is a copy of/Engine/EngineMaterials/Widget3DPassThrough`. Then, I ticked “Disable depth test” in this material properties.
Then, I added a a reference to this material in WidgetComponent:
Next, I loaded instance of this material in WidgetComponent constructor:
static ConstructorHelpers::FObjectFinder<UMaterialInterface> TranslucentMaterial_OneSided_NoDepth_Finder(TEXT("/Engine/EngineMaterials/Widget3DPassThrough_Translucent_OneSided_NoDepth"));
TranslucentMaterial_OneSided_NoDepth = TranslucentMaterial_OneSided_NoDepth_Finder.Object;
Next, I use the aforementioned boolean property (bHasTranslucentDepthTest) to change to this material in
Parent = bIsTwoSided ? TranslucentMaterial : (bHasTranslucentDepthTest ? TranslucentMaterial_OneSided : TranslucentMaterial_OneSided_NoDepth);
I needed only OneSided version, so I didn’t bother making it more robust. You can also expand
UWidgetComponent::PostEditChangeProperty to react on the changes of this variable in the editor.
Hopefully, after recent fanfare Epic makes about VR, maybe they’ll get to making Widgets and UMG more usable in VR setting.
I did as you said,the result is not very good.
When the 3D UMG is far under the ground,it begins to flash and then disappears.
Are you running it on PC or GearVR? Because my target platform was GearVR, and that’s where it works. I noticed that on PC it doesn’t work properly.
Why can’t Epic add this functionality to stock UE4?
There is a lot of work to do to catch up to unity in terms of VR usability from what i can see.
This is a great example of something that we absolutely need for pc. As an indie dev with no money i neeeeeed UMG. And its so close to being amazing, just a few things for VR
Does anyone know a way around this that might work on PC?
So I cannot use any material with 3D widgets? Do I need to modify source code of engine for this simple feature? I’ll check if this works in 4.12.4, though