Search Unity

Render Texture effect works on Oculus Go but not on Quest

Discussion in 'VR' started by Abby23, Aug 30, 2019.

  1. Abby23

    Abby23

    Joined:
    Aug 30, 2019
    Posts:
    4
    Hi all,

    I have a standard portal effect (achieved by two rendertextures, two cameras per eye, ect) for a VR app in Unity 2019.1.1f1. Everything works fine in the editor, but the effect looks incorrect and distorted when building to the Quest.

    I found out by accident that the effect does work correctly on the Quest when building as if it were a Go application, via removing the following line in the androidManifest:

    <uses-feature android:name="android.hardware.vr.headtracking" android:version="1" android:required="true" />

    This line, as far as I understand, distinguishes the app as a 6dof Quest application and so when removed it behaves as if it were a Go app (although 6dof still works fine). The FOV is visibly more narrow, and the portal effect works exactly as it should.

    After much research my strongest guess for the cause of this difference is Oculus's Asymmetric Field of View (which became default sometime in Unity 2017) which is enabled on the Quest - but perhaps wouldn't be on the Go? I can't think of any other reason why the effect would work on the same device when removing that one line of the manifest.

    Anyways, I at least know that my code is correct in some sense, since it works for the "Go" build on the Quest, but information on Oculus's Asymmetric FOV is sparse. I am not sure how to make the effect work for a normal Quest build - whether I have to change a shader, or adjust a projection somewhere in my C# script, ect. Any suggestions would be much appreciated!

    Additional Info:
    When built to the Quest normally (ie not as a Go app), the render textures of the portal look off positionally on each eye, giving a sort of cross-eyed view - with either eye closed the render texture looks as if it points too far in a direction (left eye texture seems to point too far right, right eye texture seems to point too far left). Also the rotation is incorrect, upon turning your head the textures seems to zoom/stretch. But again everything works fine on the Quest when removing that line from the androidManifest.

    Thanks!
     
  2. Corysia

    Corysia

    Joined:
    Mar 14, 2018
    Posts:
    108
    Wow, that's interesting. This may be completely anecdotal, but I saw in Oculus Integration 1.40, they've removed that line once again from the AndroidManifest.xml. Instead, there's now a comment saying it will determine the 3DOF/6DOF within the headset.

    I haven't done anything yet with 1.40 except find that change. But it might be worth trying out. Backup your project first, of course! =)
     
    Abby23 and JoeStrout like this.
  3. Abby23

    Abby23

    Joined:
    Aug 30, 2019
    Posts:
    4
    Yeah unfortunately after testing this I have found that it doesn’t really change much. Setting the OVRManager to "Gear Vr/ Go" makes the effect work correctly (as it did before the upgrade), while setting it to Quest still doesn't work. It was worth a try though, thanks for the suggestion.
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    Are you using single pass instanced rendering in the XR settings, and using two separate cameras & render textures for the portal view? I suspect that miss-match is part of the problem. Depending on how you’re getting the screen space UVs when displaying the portal textures they may be getting stretched as the default UVs assume they cover both eyes.
     
  5. Abby23

    Abby23

    Joined:
    Aug 30, 2019
    Posts:
    4
    I am using multi pass, and using two separate camera and render textures for the portal view. I am using a modified VR version of youtuber Brackey's "Smooth Portals" code/technique, mostly from the code provided at the bottom of this thread:

    https://forum.unity.com/threads/sol...ereoscopic-rendertexture-on-oculus-go.655045/

    That being said, I am using the regular portal shader provided in the original tutorial (the non VR version).
     
  6. LiminalTeam

    LiminalTeam

    Joined:
    Sep 17, 2019
    Posts:
    6
    Did you find a solution to this? I'm running into the exact issue but with a mirror shader.
     
  7. Abby23

    Abby23

    Joined:
    Aug 30, 2019
    Posts:
    4
    Not yet, I still think Oculus's Asymmetric Field of View is the root cause though.
     
  8. gametr4x

    gametr4x

    Joined:
    Apr 22, 2009
    Posts:
    86
    Just adding to this, since it was helpful in getting towards the right solution.

    I'm building a VR portal with passthrough system, and was having a similar distorted FOV issue in the render textures specifically. In general multi-pass was extremely broken for me with v56 of the integration package (the solution to which was to set the left & right camera positions to the center position/rotation, just as if it were MonoScopic, mirroring the "if (!hmdPresent || monoscopic)" clause at line 278 in OVRCameraRig... essentially just delete the whole if/else, and use the if-case 100% of the time)

    The way it ended up working for me was using MultiView, whilst setting "Use Per Eye Cameras" to true. Replacing the original rig with the OVR cameras. Since multiview only culls the scene once, both cameras need to see both portal surfaces, and you can alter the Portal shader to discard pixels from the wrong portal. I did this by having two portal materials, giving them a simple Integer property I manually set to 0 or 1 (for left / right), and then discarding pixels as follows:

    if (unity_StereoEyeIndex != _Eye) discard;

    Full shader below:


    Code (CSharp):
    1. Shader "PortalsVR/Portal"
    2. {
    3.     Properties
    4.     {
    5.         _InactiveColour("Inactive Colour", Color) = (1, 1, 1, 1)
    6.         _Eye ("Active For Eye", Integer) = 0
    7.     }
    8.     SubShader
    9.     {
    10.         Tags { "RenderType"="Opaque" }
    11.         LOD 100
    12.         Cull Off
    13.  
    14.         Pass
    15.         {
    16.             CGPROGRAM
    17.             #pragma vertex vert
    18.             #pragma fragment frag
    19.             #include "UnityCG.cginc"
    20.  
    21.             struct appdata
    22.             {
    23.                 float4 vertex : POSITION;
    24.                 UNITY_VERTEX_INPUT_INSTANCE_ID
    25.             };
    26.  
    27.             struct v2f
    28.             {
    29.                 float4 vertex : SV_POSITION;
    30.                 float4 screenPos : TEXCOORD0;
    31.                 UNITY_VERTEX_OUTPUT_STEREO
    32.             };
    33.  
    34.             sampler2D _MainTex;
    35.             float4 _InactiveColour;
    36.             int displayMask; // set to 1 to display texture, otherwise will draw test colour
    37.             int _Eye;
    38.  
    39.             v2f vert (appdata v)
    40.             {
    41.                 v2f o;
    42.              
    43.                 UNITY_SETUP_INSTANCE_ID(v);
    44.                 UNITY_INITIALIZE_OUTPUT(v2f, o);
    45.                 UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
    46.              
    47.                 o.vertex = UnityObjectToClipPos(v.vertex);
    48.                 o.screenPos = ComputeScreenPos(o.vertex);
    49.                 return o;
    50.             }
    51.  
    52.             fixed4 frag(v2f i) : SV_Target
    53.             {
    54.                 UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(i); //Insert
    55.              
    56.                 if (unity_StereoEyeIndex != _Eye) discard;
    57.  
    58.                 float2 uv = i.screenPos.xy / i.screenPos.w;
    59.                 fixed4 portalCol = tex2D(_MainTex, uv);
    60.  
    61.                 return portalCol * displayMask + _InactiveColour * (1-displayMask);
    62.             }
    63.             ENDCG
    64.         }
    65.     }
    66.     Fallback "Standard" // for shadows
    67. }