Search Unity

Move portal no longer working 2017.4.11f1

Discussion in 'AR/VR (XR) Discussion' started by imagedrealityjake, Dec 21, 2018.

  1. imagedrealityjake

    imagedrealityjake

    Joined:
    May 8, 2018
    Posts:
    17
    Hi,

    We've just updated from 2017.4.10f1 to the Oculus recommended version 2017.4.11f1. Everything seems fine apart from our movement portal system.

    We are using this to generate a left and right eye texture that we then apply to a quad in front of the player:

    Code (CSharp):
    1. public void RenderIntoMaterial(Material mat)
    2.     {
    3.         if (Camera.current != _OverlayCamera)
    4.             return;
    5.  
    6.         // Left eye
    7.         _PortalCameraTransform.localPosition = UnityEngine.XR.InputTracking.GetLocalPosition(UnityEngine.XR.XRNode.LeftEye);
    8.         _PortalCameraTransform.localRotation = UnityEngine.XR.InputTracking.GetLocalRotation(UnityEngine.XR.XRNode.LeftEye);
    9.  
    10.         // Set Render texture
    11.         PortalCamera.targetTexture = _LeftEyeRenderTexture;
    12.         PortalCamera.Render();
    13.  
    14.         // Right eye
    15.         _PortalCameraTransform.localPosition = UnityEngine.XR.InputTracking.GetLocalPosition(UnityEngine.XR.XRNode.RightEye);
    16.         _PortalCameraTransform.localRotation = UnityEngine.XR.InputTracking.GetLocalRotation(UnityEngine.XR.XRNode.RightEye);
    17.  
    18.         // Set Render Texture
    19.         PortalCamera.targetTexture = _RightEyeRenderTexture;
    20.         PortalCamera.Render();
    21.  
    22.         // Update textures
    23.         mat.SetTexture("_LeftEyeTexture", _LeftEyeRenderTexture);
    24.         mat.SetTexture("_RightEyeTexture", _RightEyeRenderTexture);
    25.     }
    Then in our quad shader:

    Code (CSharp):
    1. void surf(Input IN, inout SurfaceOutput o) {
    2.  
    3.             o.Alpha = tex2D(_AlphaMap, IN.uv_AlphaMap).a * IN.color.a * _Color.a;
    4.             float2 screenUV = IN.screenPos.xy / IN.screenPos.w;
    5.            
    6. #if UNITY_SINGLE_PASS_STEREO
    7.             // If Single-Pass Stereo mode is active, transform the
    8.             // coordinates to get the correct output UV for the current eye.
    9.             float4 scaleOffset = unity_StereoScaleOffset[unity_StereoEyeIndex];
    10.             screenUV = (screenUV - scaleOffset.zw) / scaleOffset.xy;
    11. #endif
    12.             if (unity_StereoEyeIndex == 0) {
    13.                 o.Emission = tex2D(_LeftEyeTexture, UnityStereoScreenSpaceUVAdjust(screenUV, _LeftEyeTexture_ST)).rgb * _Color.rgb;
    14.             } else {
    15.                 o.Emission = tex2D(_RightEyeTexture, UnityStereoScreenSpaceUVAdjust(screenUV, _RightEyeTexture_ST)).rgb * _Color.rgb;
    16.             }
    17.         }
    This was working totally fine before the upgrade so something must have changed. Now it looks like there is an offset to each render, almost like the local position isn't being set correctly but I've debuged the values and they look good.

    Anyone know if there was any update to single-pass rendering between these Unity versions?

    Thanks! Jake
     
  2. imagedrealityjake

    imagedrealityjake

    Joined:
    May 8, 2018
    Posts:
    17
    Little bump on this. I rolled back to 2017.4.10f1 and this code works perfectly well.