cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to turn on anti aliasing MSAA for GearVR in Unreal Engine 4.14?

saldavonschwart
Explorer
I'm working with Unreal 4.14 which supposedly even has a new forward rendering path for VR, though not sure if it is meant just for desktop vr or for mobile too.

I'm attempting to get antialiasing working on a Galaxy S6 with GearVR, but I've spent the past 2 days trying out all sorts of things and nothing makes a difference.

Basically, I start with a blank project set to mobile + scalable graphics quality. Then I've tried the following. Always packing to Android ETC2:

. default project settings (theoretically deferred path by default).
. With the new forward rendering option.
. Setting any combinations of the following console variables:
  . r.MSAACount
  . r.MSAACompositingSampleCount
  . r.DefaultFeature.Antialiasing
  . r.MobileOnChipMSAA
  . r.MobileMSAA
  . r.MobileContentScaleFactor
  . gearvr.EnableMSAA

Nothing seems to enable anti aliasing. I also posted this on SO, gamedev SE, Unreal AnwerHub and the Unreal forums. and no one has replied anything other than "MSAA should be on by default for GearVR."

Has anyone experienced this? Does anyone have any thoughts?

29 REPLIES 29

motorsep
Rising Star
Afaik MSAA antialiases only edges of geometry. Since UMG widgets aren't geometry per se, the images and text on them won't be AA'ed. You should probably use stereo layers instead (render your UMG into stereo layers).

saldavonschwart
Explorer
@motorsep


I'm still in the process of making sure that multisample targets are set in the fbo (how @rpalandri pointed out), just to be safe. But if we are correct that this is not an msaa issue, shouldn't the UMG edges be antialiased anyway? While the content inside the widget might be rendered in a different way, I'd expect the quad itself to be a a quad in the usual vertex attribute way.


About stereo layers, not sure what those are. Is it an Unreal thing?


Thanks

motorsep
Rising Star
If you make solid color UMG widget, you'd see that edges of that widget (since it'd be a rectangular shape anyway) are AA'ed. Anything inside the widget won't be, since MSAA doesn't AA textures/text, afaik.

https://docs.unrealengine.com/latest/INT/BlueprintAPI/Components/StereoLayer/index.html
and the whole thread about how to use it: https://forums.oculus.com/developer/discussion/44130/gear-vr-rendering-umg-widget-in-stereolayer-component-how-bp-only

motorsep
Rising Star
@saldavonschwartz Are you using Multiview option by chance? It seems that AA isn't working when using Multiview (and performance is horrible too). I posted about that here https://forums.oculus.com/developer/discussion/46725/gear-vr-multiview-is-buggy-in-4-14-1

rpalandri
Expert Protege
Hey,
@motorsep is right on the money there. Although I feel UMG should probably be MSAAd, due to the fact that UMG renders after all the normal rendering is done (and therefore after the original MSAA resolve, due to how MSAA works on mobile chipsets), I can definitively see why there would be issues with it. As good practice, try to have alpha dithering on the sides of your quad content anyway to avoid that. 

Layers are a VR compositor feature that enable high-quality quads, cylinders and cubemaps to be displayed on the headset. We are exposing this compositor feature to users via the UE4 StereoLayer blueprint component, whose links motorsep gave you 🙂 For a quick explanation, if you're interested, how it works is that the quad isn't rendered in UE4 at all. We give the VR compositor the quad's texture and position, and the compositor doesn't distort the pre-rendered quad but raytraces the quad's geometry through the lenses. That enables per-display-pixel sampling (much higher than the 1024x1024 rendertarget that we use for game rendering), and avoids dual sampling the texture (once in the game, once in the compositor). 

Outside of layers, which can only be used for a couple quads in the whole game, VR introduces a lot of issues in rendering high frequency textures like text. Devs have to be extremely conscious of the choices they make in textures, filtering, and mipmapping. John Carmack has excellent public talks on the subject 🙂




saldavonschwart
Explorer
@rpalandri
@motorsep


Hi again. Still haven't been able to make much progress on this.
I'd like to do a recap of what I have so far, just in case.

The situation is that I am using UMG widgets in world space and I see a lot of aliasing (more than I'd expect with MSAA x4) in images, text and the widget borders themselves.

Here you can see a screenshot:

h3oyxm6grmxh.png

When actually using the GearVR headset of course the artifacts are further amplified.
While text and image aliasing might have fixes that are unrelated to MSAA, you can see the orange rect which is a bare minimum UMG widget displayed in world space. The edges are pretty jagged. And this is what makes me think MSAA could be off.

BTW @motorsep I am not using multi view. At least not that I know of: it is not checked under project settings.

Another interesting thing is that in Project Settings, I do not have GLES3 checked but according to the adb logs which I posted on a previous comment, the still seems to be running on GLES3 instead of 2. 

Now on to the current hypotheses:

1. Is MSAA on? Or why are the rect edges so jagged?

I don't know. We did confirm that:

a. The adb log spits out: "LogRHI:   GL_EXT_multisampled_render_to_texture"
This seems to imply that multisampling is supported.

b. The adb log spits out: "LogHMD: Enabling r.MobileOnChipMSAA, previous value 0"
This seems to imply that MSAA is being turned on when running on GearVR mode. Though it does not tell what level of MSAA (2,4,8?).

I was not able confirm that:

glFramebufferTexture2DMultisampleEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + RenderTargetIndex, RenderTarget->Target, RenderTarget->Resource, MipmapLevels[RenderTargetIndex], 2);

is being called however. I tried downloading the source for UE, adding log statements around the above and compiling the engine. The engine compiles, the editor starts up and I am able to open my project. But when I try to package for Android it errs out saying there are a lot of missing files (related to all sorts of subsystems in the engine, like physics). So not sure what I'm doing wrong since I followed the instructions on Epics site to run from source.

2. Does mipmapping and filtering make a difference for the images?

Again, not sure... I'd expect it should but it is not clear to me if changing parameters from the Texture editor should be visible immediately even inside the general editor. For instance, if I change Mip Gen Settings, Texture Group or Filtering, I see no difference in the image. I also hit Save just in case (since I don't know if changing the settings takes effect before hitting save) and nothing seems different.

3. Would Stereo Layers help?
I'm actually gonna give this a try, since I tried the sample project in the thread @motorsep
linked to and it definitely looks good. Also I was under the false impression that stereo layers required the surface tracking the headset but from the example project it is clearly not the case :).

Again, not sure. The doc link @motorsep provided is of little use: like many areas in the UE docs, it appears to simply be the generated doc from the source code, which merely lists method names without any context on how to use.

From the second link @motorsep sent, what I gathered so far is that stereo layers are meant to place HUD-like elements that track with the headset. But this would not serve my use case since the cards I show in the image are to stay put in their world positions. The player can stare around in the world and stare at the cards and activate them with their gaze, but the cards themselves should not follow the camera or headset.

Last, another thing I notice when running on the device (the Galaxy S6), is that the black eye vignettes stutter a lot as I move the phone around. But I'm not sure this might have anything to do with the aliasing.

motorsep
Rising Star
MSAA x4 only available when enabled through Developer's Options on the phone, afaik. And as I recall turning that on disabled AA completely in my Gear VR app.

If you set your StereoLayer tracking to "world", it will stay in one place and won't follow your camera.

I am not sure what you are doing and what debug options you have on through phone's developer menu, but I am using 4.14.1, ES2 renderer, no HDR, ETC2 textures and no experimental features, and MSAA x2 works extremely well.

saldavonschwart
Explorer
@motorsep


I might upload a stripped down version of my project soon, in case you want to take a look. But I've been running into a lot of issues as you can see: UE from source does not package the app, MSAA seems off to me (as you can see in the image with the orange quad) even though I have no experimental features on... I don't know.

Before I upload a sample project, I am trying to implement the stereo layer approach. I am looking at the sample @rpalandri posted in https://forums.oculus.com/developer/discussion/44130/gear-vr-rendering-umg-widget-in-stereolayer-com... but I don't see where the stereo layer is at all.

Like, I tested it on my phone and works great. Then I started looking around and I see he has a widget same as me, then he does a RTT (render to texture) thru the static C++ function he exposes to BP. All that is fine. But where is any mention of stereo layers in the project?

motorsep
Rising Star
StereoLayer is a component you add to BP actor or to your player's actor.

saldavonschwart
Explorer
Ok I found the stereo layer on the ground actor for some reason. I'll report back once I have a sample project.

@motorsep
But in the example from the thread you linked to there is no such component neither on the CameraActor nor DefaultPawn which are the 2 classes involved in the concept of "the player". As a matter of fact, the only 2 non standard entities in the project are:

. the menu BP.
. the cat UMG widget.
. the C++ static function.
. The level blueprint which just executs the same logic the menu executes on tick, but instead once on start.

@rpalandri I believe you created the sample. Would yo mind pointing me to where the stereo layer is being created / set up? Also, does this work only for Oculus hardware or does it also work for Google Cardboard, Daydream and HTC Vive?