/// <summary> /// Get the distorted texture, frame index, time index from current buffer. /// </summary> /// <param name="imageLeft"></param> /// <param name="imageRight"></param> /// <param name="frameIndex"></param> /// <param name="timeIndex"></param> public static void GetDistortedTexture(out Texture2D imageLeft, out Texture2D imageRight, out int frameIndex, out int timeIndex, out Matrix4x4 poseLeft, out Matrix4x4 poseRight) { // native buffer ptr method 2: get gpu texture buffer ptr directly from native(cpp) #if USE_DISTORT_TEX_NATIVE_BUFFER if (TextureDistortedDeviceRaw == null) { TextureDistortedDeviceRaw = Texture2D.CreateExternalTexture(DistortedImageWidth, DistortedImageHeight * 2, TextureFormat.RGBA32, false, false, nativeTex); } else { ViveSR_Framework.GetParameterNativePtr(ViveSR_Framework.MODULE_ID_SEETHROUGH, (int)SeeThroughParam.VIDEO_RES_VIEW_NATIVE_PTR, ref nativeTex); TextureDistortedDeviceRaw.UpdateExternalTexture(nativeTex); } imageLeft = TextureDistortedDeviceRaw; imageRight = TextureDistortedDeviceRaw; #else if (DataInfoDistorted[(int)SeeThroughDataMask.DISTORTED_FRAME_LEFT].ptr != IntPtr.Zero && DataInfoDistorted[(int)SeeThroughDataMask.DISTORTED_FRAME_RIGHT].ptr != IntPtr.Zero) { TextureDistortedLeft.LoadRawTextureData(DataInfoDistorted[(int)SeeThroughDataMask.DISTORTED_FRAME_LEFT].ptr, DistortedImageWidth * DistortedImageHeight * DistortedImageChannel); TextureDistortedRight.LoadRawTextureData(DataInfoDistorted[(int)SeeThroughDataMask.DISTORTED_FRAME_RIGHT].ptr, DistortedImageWidth * DistortedImageHeight * DistortedImageChannel); TextureDistortedLeft.Apply(); TextureDistortedRight.Apply(); } imageLeft = TextureDistortedLeft; imageRight = TextureDistortedRight; #endif frameIndex = DistortedFrameIndex; timeIndex = DistortedTimeIndex; poseLeft = DistortedPoseLeft; poseRight = DistortedPoseRight; }