I want to have 3D widget (UMG) near crosshair. I used the same technique I used for my fade screen plane - parented 3D widget to the camera and placed it right about at the same distance a my view fading plane. Here is my setup (3D widget is scaled up to be clearly visible for demonstration purposes):
Here is how it looks in the Editor:
While view fading plane renders properly in VR, this is how 3D widget looks like in VR:
I am using 4.11.2
What am I doing wrong ? Is it a bug ?
After messing around a bit, I found out that parenting 3D widget to camera’s anchor puts it at the center (but of course it doesn’t follow camera any longer), but since it’s too close to the camera, it makes me cross-eyed
I guess as a hack (if you fix 3D widgets rendering when parented directly the the camera or to anything parented to the camera), I could place it farther away and make it translucent additive instead of masked, and disable sorting, but unfortunately I can’t because there are no such options for 3D widget
It works in the PIE but not on the device. I’ll PM download link for my actual project to you on the forum (after I get off work).
Would you be able to post a simple project here where this is reproduced? I tried a couple of different ways and everything I attach to the camera, widgets, text actors, any meshes, etc all follow the camera as I would expect in GearVR and in the PIE Editor view as well.
Looking at the project I’m seeing widget follow the camera as intended with it attached. It’s scale is a little low which causes it to be in the masked area, but I’m not seeing the specific issue you’ve described above with it not following the camera. If I scale up the widget it’s clear that it’s following on my end in GearVR launched on the device, in PIE, and in Standalone Game Mode while using -emulateStereo view.
Just to add though, I’m not a VR expert but something doesn’t seem 100% right to me, I’ll have to check look at this just a bit more though.
Oh, it follows the cam. It’s just rendered incorrectly - on the device it’s at the edge of the view, not near by the crosshair as you can see in the Editor.
If I look around and up/down, it follows. Just stays at the edge of the view, on both left and right side. As if stereo rendering is broken for 3D widget
Thanks. Although it was helpful, it’s not related to the bug I am describing here.
Here is a new development. When I disable depth on 3D Widget engine material and moved 3D widget away from the camera to test if it gets occluded or not, 3D widget parented to camera renders closer to where it should be (centered), but stereo separation is still all screwed up: Locomotion in VR (wip#2) - YouTube (that’s only one eye view captured using Oculus’s utils in Gear VR)
So I am thinking if the issue is that when 3D widget is too close to the camera, stereo separation is totally off, which makes it render wrong in VR.
I can try moving it farther away from the camera to find that sweet spot where it renders correctly, but I wonder if moving it too far away is a bad idea.
I’ve submitted UE-32053 for this one to be investigated. Sorry for the delay.
I set this up and it all appears to be working correctly.
The first screenshot shows the widget attached very close to the camera.
The third screenshot shows that rendering with a pretty extreme stereo effect, just as if you look straight ahead and put your finger in front of your nose and close one eye without shifting your gaze. The finger will appear way off to the edge of your view, toward the center.
This will cause cross-eye or split-image.
I think another approach is needed. Perhaps the text should be attached to the blue in world reticule, but scaled so that it remains readable? Then the stereo depth of the text will match the scene that the user is looking at. Web search “VR HUD Rendering”. A tricky problem.
View fading may work because it is a constant effect across the entire field of view, so the stereo is invisible.
It’s not an issue with Unity as it has overlays from Oculus SDK that allow rendering HUD elements properly.
I sure could move 3D widget far far away from the cam to reach a point where left and right eye image converge, but then 3D widget has to be made huge to be readable and since there is no way to disable depth for just that 3D widget, it will be either occluded by level’s geometry or all 3D widgets will have depth test disabled.
Also, like I mentioned already, if I don’t parent 3D widget directly to the cam, it renders perfectly fine, except that it no longer follows camera (without resorting to BP scripting).
I see you accepted Jeffrey’s answer. So, if it’s not going to be fixed, could Epic provide example scene where 3D widget patented to the camera looks correctly in VR and doesn’t get occluded by level’s geometry or actors, please?
A method involving several work-arounds. Tested on oculus rift and gearvr.
- Parent the Widget to the fp mesh (step 4 explains that), move it away so it is stereo converged (10000cm worked). Make it big enough to see.
At this point you have a stero converged HUD element of the proper size, but it is still rendered behind the world geometry.
Disable Depth Test on the material used for the widget. Most easily: change Engine/Content/EngineMaterials/Widget3DPassThrough.uasset. This setting will apply to all 3d widgets, however it only has an affect on those with blend mode set to transparency, so there is some specificity. To make it more specific one would need to change the widget material in code by modifying or subclassing UWidgetComponent. Perhaps add the ability to simply set a material for the widget, overriding the hard coded option based materials. Be sure to examine the existing materials when making a new one to ensure it works correctly.
Set Widget Component blend mode to transparent.
At this point your HUD element will render in front of world geometry it is close to, but will vanish once it gets entirely behind because of occlusion culling. You won’t see it intersect with the world geo as normal, it will be fully drawn and then become fully invisible when culled.
- Set rendering advanced setting ‘Use Attached Parent Bound’ (the parent being Mesh1P, or some other mesh which is never occlusion culled). This will work around occlusion culling, which would otherwise cause the widget to disappear when it is sufficently behind anything.
At this point you will have an always on screen stereo converged HUD element. When the world geometry is close the player’s eyes will focus on either the hud element or the world, with the other being split.
I understand all that, but the truth is that it simply needs to be fixed to work out of the box, just like it does in Unity.
This issue is also in my project. Whenever I deploy it to my GearVR it only renders in one eye. It’s probably very impractical if I should recompute every position that the player is facing since it would be hard and it would take a lot of computation. Plus you still need to make it in world space and clipping would be necessary. It’s probably better if we set it to screen space.