Google cardboard for unity disables AA on android device

扶醉桌前 提交于 2019-12-11 11:52:31

问题


I'm developing simple VR app for android using google cardboard SDK for unity. I'm using unity 5(free), and latest version cardboard package for unity(0.4.9), i am testing on sony xperia z3 compact(lolipop) and on samsung galaxy note 3(kitkat)

The issue i'm having is, that i can't turn on anti-aliasing, or rather google sdk package, seems to disable it. I dont mind a little jagged corners, but the thing is that those corners are flickering when they are far away enough. I tried moving textures apart(since the flickering could be result of overlapping), but issue still persists.

It can't be the issue with the unity exporting for android, since if i build same project(test example provided inside google cardboard unity package) using stock camera provided by unity, insted of Cardboard main gameobject), AA is working. It cant get simpler than that, once cube and one camera... I have tried turning on and off the 32-bit display buffer option in player settings, tried forcing open GL ES 2.0 and various other tick/untick checkbox inside unity tips found across web, with no success.

So my question is, is anyone else having this same issue. And how to fix it?

I hope my question and description of the problem are detailed enough.

Cheers


回答1:


The Cardboard.cs class holds a RenderTexture which is what the cameras render to, and then it is rerendered to the phone screen with distortion correction for the lenses. This bypasses Unity's normal rendering to the screen, so the AA settings for the project won't have any effect.

To see what effect AA settings in Unity will have, you can do a couple of different things:

  1. Turn off Cardboard.SDK.nativeDistortionCorrection, so that Unity is drawing directly to the screen, or
  2. Edit Cardboard.CreateStereoScreen() and change the settings on the RenderTexture that is allocated there.

However, the native code rerender for distortion does not use anti-aliasing in the framebuffer, so I'm not sure how much effect you'll see in #2. And there will certainly be a performance penalty either way.




回答2:


Turning off distortion correction fixed this issue. Then you can set the Unity project anti alias settings up to 4x or 8x. Looks great now - no more jaggies while viewing on an iPhone 6+.

Unity 5 running Google Cardboard SDK v0.5 --

To turn off Distortion Correction: Go to Hierarchy | CardboardMain | in Inspector uncheck Distortion Correction

To enable 4x or 8x Anti Aliasing in Unity: Go to Edit | Project Settings | Quality | in Inspector set Anti Aliasing to 4x or 8x Multi Sampling.




回答3:


If you don't want to turn off distortion correction you need to change the depth of the texture from 16 to 32 bits and the format of the texture to ARGB32. To do that go to file BaseVRDevice.cs, then find CreateStereoScreen function and change it to

public virtual RenderTexture CreateStereoScreen() {
    Debug.Log("Creating new default cardboard screen texture.");
    return new RenderTexture(Screen.width, Screen.height,32, RenderTextureFormat.ARGB32);
  }



回答4:


I followed serg hov's suggestion, however AA is not working with distortion on even after applying that fix.

It doesn't make sense to turn off distortion, so I am wondering what would be the solution to have both distortion and AA working. It works for Gear VR, so there gotta be a way to get it working for Cardboard VR.



来源:https://stackoverflow.com/questions/29633049/google-cardboard-for-unity-disables-aa-on-android-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!