I am trying to use a full-screen UMG widget in PSVR. I want a vignette effect that can hide the world in the player’s peripheral vision to prevent motion sickness. The viewport is one object being drawn across two lenses, but other than that it behaves like UMG normally does. The problem I’m having is that the viewport is slightly too short and allows a gap on the far right side of the right lens, which means that the world can still be seen beyond the vignette.
Is there a way to force the viewport to draw a little bit wider than it’s calculating that it needs to? Is there an object that is determining this size that I can modify? I’m adding the widget directly to the viewport.
Widgets are screen space elements. You can’t use “add to view port”, directly.
But you can use 3D widget components. Create that component in your player character or pawn, attach it to camera component, set your widget, calibrate its position.
Unity has a specific class for that and its name is “OVRVignette Class” but because our glorious Unreal Engine is a step child we don’t have it or I couldn’t see.
You are likely better off using a postprocess material for vignetting, rather than a UI layer, provided it is supported by the platform. There doesn’t seem to be any public documentation available for PSVR development.
If PSVR is different than PC and Android based VR, I don’t know but if it is same post process materials are not working with forward rendering and personally I use forward rendering.
I appreciate the alternative suggestions, but can anyone answer the question I asked about changing the draw size of the viewport? Is there a way to force it to draw bigger?
AddToViewport works fine for UMG widgets. The UMG solution I am using works very well, except for the viewport not drawing over the full width of the VR lens.
The problem with using a post process effect is that I am using in-world stereo layer components that draw after post processing that I also need to cover with this vignette. When I tried using a second stereo layer element as my vignette, it stuttered every few frames and showed the game world behind it. Does anyone know how to stop the stereo layer from stuttering like that? I could use that approach instead.
Post process materials should work fine with the forward rendering on PC. It’s just the mobile renderer that doesn’t have proper support.
I’m not sure, but the VR viewport size is tied to the field-of-view parameters received from the runtime. I don’t think Unreal comes with any way of adjusting it. You’d likely have to modify the PSVR plugin to extend the FoV. Then on submission either report the extended FoV to the runtime or adjust the submitted frame extents to match the original FoV, depending on what the API supports. This is provided that the source for the plugin is available. Otherwise you would have to ask Sony.
Stereo layers are composited onto the view by the runtime compositor. If a head locked layer is stuttering, it’s most likely an issue with the runtime, since the runtime should know not to reproject it.
By the way, a regular full-screen widget would be drawn behind the stereo layers anyway, the same as any post process material. If the PSVR is behaving differently, it could have some non-standard way of rendering things in its plugin. It might be worth asking Sony about it.
Post process materials with forward rendering on PC is okay but the problematic thing is VR. I can’t say it absolutely brokes everything. Some things work and some others not. I say this because I wanted to use them to create mesh outlines without depending on duplicated meshes.
Problematic ones was about transparency related stuffs.
Complex effects like outlines that needs additional data from the main pass are going to be trickier, but I think it should be possible to get working even in VR. A vignette is just a straightforward blend of the scene color though.
Thank you for your thorough response. If I have to redesign this to work as a stereo layer, that’s helpful to keep in mind. I can tell you that the screen space widget is being drawn over the in-world locked stereo layer.
After diving deeper into this behavior, it looks like the screen space render target starts off the same size as the rest of the world, but then gets cut off at some point during slate rendering. The full screen widget is sized like it takes the whole screen, but then the far right size is cut off. The final size matches a 4k TV (3840, 2160) where the rest of the game is rendering at (4032, 2048). So it’s not that I need to make the viewport bigger, but I need to find out why slate has decided to cut off part of the screen after starting at the right size.
Searching the source for the numbers returns two console variables for setting the max allowed widget component dimensions: WidgetComponent.MaximumRenderTargetWidth and WidgetComponent.MaximumRenderTargetHeight