/************************************ IEnumerator *************************************/ IEnumerator EndOfFrame() { while (true) { yield return(new WaitForEndOfFrame()); if (isfirst && framenum == 3) { Pvr_UnitySDKAPI.System.UPvr_RemovePlatformLogo(); Pvr_UnitySDKAPI.System.UPvr_StartVRModel(); isfirst = false; } else if (isfirst && framenum < 3) { Debug.Log("+++++++++++++++++++++++++++++++" + framenum); framenum++; } #if UNITY_5_6 #else Pvr_UnitySDKPluginEvent.IssueWithData(RenderEventType.TimeWarp, Pvr_UnitySDKManager.SDK.RenderviewNumber); Pvr_UnitySDKManager.SDK.currEyeTextureIdx = Pvr_UnitySDKManager.SDK.nextEyeTextureIdx; Pvr_UnitySDKManager.SDK.nextEyeTextureIdx = (Pvr_UnitySDKManager.SDK.nextEyeTextureIdx + 1) % 3; #endif } }
void OnPostRender() { //DrawVignetteLine(); screenFade(); int eyeTextureId = Pvr_UnitySDKManager.SDK.eyeTextureIds[IDIndex]; // SaveImage(Pvr_UnitySDKManager.SDK.eyeTextures[IDIndex], eye.ToString()); Pvr_UnitySDKPluginEvent.IssueWithData(eventType, eyeTextureId); if (Input.GetKeyDown(KeyCode.JoystickButton0)) { cube.transform.Rotate(0, 0, 360 * Time.deltaTime); SaveImages.SaveImage(Pvr_UnitySDKManager.SDK.eyeTextures[Pvr_UnitySDKManager.SDK.currEyeTextureIdx + (int)eye * 3], eye.ToString()); } #if !UNITY_EDITOR && UNITY_ANDROID if (eye == Eye.LeftEye && !setLevel && Pvr_UnitySDKManager.SDK.IsViewerLogicFlow) { AndroidJavaClass AvrAPI = new UnityEngine.AndroidJavaClass("com.unity3d.player.AvrAPI"); Pvr_UnitySDKAPI.System.UPvr_CallStaticMethod(AvrAPI, "setVrThread"); setLevel = true; Debug.Log("Viewer setVrThread"); } else { return; } #endif }
void OnPostRender() { //DrawVignetteLine(); screenFade(); // if not find Overlay then Open eyebuffer only if (Pvr_UnitySDKEyeOverlay.Instances.Count <= 0) { int eyeTextureId = Pvr_UnitySDKManager.SDK.eyeTextureIds[IDIndex]; Pvr_UnitySDKPluginEvent.IssueWithData(eventType, eyeTextureId); } #if !UNITY_EDITOR && UNITY_ANDROID if (eyeSide == Eye.LeftEye && !setLevel && Pvr_UnitySDKManager.SDK.IsViewerLogicFlow) { AndroidJavaClass AvrAPI = new UnityEngine.AndroidJavaClass("com.unity3d.player.AvrAPI"); Pvr_UnitySDKAPI.System.UPvr_CallStaticMethod(AvrAPI, "setVrThread"); setLevel = true; Debug.Log("Viewer setVrThread"); } else { return; } #endif }
void OnPostRender() { //DrawVignetteLine(); screenFade(); // eyebuffer int eyeTextureId = Pvr_UnitySDKManager.SDK.eyeTextureIds[IDIndex]; Pvr_UnitySDKPluginEvent.IssueWithData(eventType, eyeTextureId); // boundary if (!Pvr_UnitySDKManager.SDK.HmdOnlyrot) { Pvr_UnitySDKPluginEvent.IssueWithData(boundaryEventType, Pvr_UnitySDKManager.SDK.RenderviewNumber); } #if !UNITY_EDITOR && UNITY_ANDROID Pvr_UnitySDKPluginEvent.Issue(RenderEventType.EndEye); if (eyeSide == Eye.LeftEye && !setLevel && Pvr_UnitySDKManager.SDK.IsViewerLogicFlow) { AndroidJavaClass AvrAPI = new UnityEngine.AndroidJavaClass("com.unity3d.player.AvrAPI"); Pvr_UnitySDKAPI.System.UPvr_CallStaticMethod(AvrAPI, "setVrThread"); setLevel = true; Debug.Log("Viewer setVrThread"); } else { return; } #endif }
private void OnPostRender() { int eyeTextureID = Pvr_UnitySDKManager.SDK.eyeTextureIds[Pvr_UnitySDKManager.SDK.currEyeTextureIdx]; Pvr_UnitySDKPluginEvent.IssueWithData(RenderEventType.LeftEyeEndFrame, eyeTextureID); Pvr_UnitySDKPluginEvent.IssueWithData(RenderEventType.RightEyeEndFrame, eyeTextureID); }
void OnPostRender() { DrawVignetteLine(); int eyeTextureId = Pvr_UnitySDKManager.SDK.eyeTextureIds[IDIndex]; // SaveImage(Pvr_UnitySDKManager.SDK.eyeTextures[IDIndex], eye.ToString()); Pvr_UnitySDKPluginEvent.IssueWithData(eventType, eyeTextureId); }
void OnRenderObject() { if (Camera.current != cam) { return; } //Debug.Log("LLLL Pvr_UnitySDKPostRender OnRenderObject TimeWarp"); Pvr_UnitySDKPluginEvent.IssueWithData(RenderEventType.TimeWarp, Pvr_UnitySDKManager.SDK.RenderviewNumber); Pvr_UnitySDKManager.SDK.currEyeTextureIdx = Pvr_UnitySDKManager.SDK.nextEyeTextureIdx; Pvr_UnitySDKManager.SDK.nextEyeTextureIdx = (Pvr_UnitySDKManager.SDK.nextEyeTextureIdx + 1) % 3; }
private void OnPostRender() { int eyeTextureID = Pvr_UnitySDKManager.SDK.eyeTextureIds[Pvr_UnitySDKManager.SDK.currEyeTextureIdx]; // eyebuffer Pvr_UnitySDKPluginEvent.IssueWithData(RenderEventType.LeftEyeEndFrame, eyeTextureID); Pvr_UnitySDKPluginEvent.IssueWithData(RenderEventType.RightEyeEndFrame, eyeTextureID); // boundary if (!Pvr_UnitySDKManager.SDK.HmdOnlyrot) { Pvr_UnitySDKPluginEvent.IssueWithData(RenderEventType.BoundaryRenderLeft, Pvr_UnitySDKManager.SDK.RenderviewNumber); Pvr_UnitySDKPluginEvent.IssueWithData(RenderEventType.BoundaryRenderRight, Pvr_UnitySDKManager.SDK.RenderviewNumber); } }
void OnPostRender() { //DrawVignetteLine(); screenFade(); int eyeTextureId = Pvr_UnitySDKManager.SDK.eyeTextureIds[IDIndex]; // SaveImage(Pvr_UnitySDKManager.SDK.eyeTextures[IDIndex], eye.ToString()); Pvr_UnitySDKPluginEvent.IssueWithData(eventType, eyeTextureId); #if !UNITY_EDITOR && UNITY_ANDROID if (eye == Eye.LeftEye && !setLevel && Pvr_UnitySDKManager.SDK.IsViewerLogicFlow) { AndroidJavaClass AvrAPI = new UnityEngine.AndroidJavaClass("com.unity3d.player.AvrAPI"); Pvr_UnitySDKAPI.System.UPvr_CallStaticMethod(AvrAPI, "setVrThread"); setLevel = true; } else { return; } #endif }
/************************************ End Of Per Frame *************************************/ IEnumerator EndOfFrame() { float[] lowerLeft = new float[6]; float[] upperLeft = new float[6]; float[] upperRight = new float[6]; float[] lowerRight = new float[6]; List <int> leftEyeEnableLayers = new List <int>(); List <int> rightEyeEnableLayers = new List <int>(); while (true) { yield return(new WaitForEndOfFrame()); if (isfirst && framenum == 3) { Pvr_UnitySDKAPI.System.UPvr_RemovePlatformLogo(); Pvr_UnitySDKAPI.System.UPvr_StartVRModel(); isfirst = false; } else if (isfirst && framenum < 3) { Debug.Log("+++++++++++++++++++++++++++++++" + framenum); framenum++; } // if find Overlay then Open Composition Layers feature if (Pvr_UnitySDKEyeOverlay.Instances.Count > 0) { #region Composition Layers // clera leftEyeEnableLayers.Clear(); rightEyeEnableLayers.Clear(); // for eyebuffer int eyeTextureId = 0; for (int i = 0; i < Eyes.Length; i++) { if (!Eyes[i].isActiveAndEnabled) { continue; } #region LL UL UR LR // LL lowerLeft[0] = Eyes[i].clipLowerLeft.x; lowerLeft[1] = Eyes[i].clipLowerLeft.y; lowerLeft[2] = Eyes[i].clipLowerLeft.z; lowerLeft[3] = Eyes[i].clipLowerLeft.w; lowerLeft[4] = Eyes[i].uvLowerLeft.x; lowerLeft[5] = Eyes[i].uvLowerLeft.y; // UL upperLeft[0] = Eyes[i].clipUpperLeft.x; upperLeft[1] = Eyes[i].clipUpperLeft.y; upperLeft[2] = Eyes[i].clipUpperLeft.z; upperLeft[3] = Eyes[i].clipUpperLeft.w; upperLeft[4] = Eyes[i].uvUpperLeft.x; upperLeft[5] = Eyes[i].uvUpperLeft.y; // UR upperRight[0] = Eyes[i].clipUpperRight.x; upperRight[1] = Eyes[i].clipUpperRight.y; upperRight[2] = Eyes[i].clipUpperRight.z; upperRight[3] = Eyes[i].clipUpperRight.w; upperRight[4] = Eyes[i].uvUpperRight.x; upperRight[5] = Eyes[i].uvUpperRight.y; // LR lowerRight[0] = Eyes[i].clipLowerRight.x; lowerRight[1] = Eyes[i].clipLowerRight.y; lowerRight[2] = Eyes[i].clipLowerRight.z; lowerRight[3] = Eyes[i].clipLowerRight.w; lowerRight[4] = Eyes[i].uvLowerRight.x; lowerRight[5] = Eyes[i].uvLowerRight.y; #endregion switch (Eyes[i].eyeSide) { case Pvr_UnitySDKAPI.Eye.LeftEye: eyeTextureId = Pvr_UnitySDKManager.SDK.eyeTextureIds[Pvr_UnitySDKManager.SDK.currEyeTextureIdx]; break; case Pvr_UnitySDKAPI.Eye.RightEye: eyeTextureId = Pvr_UnitySDKManager.SDK.eyeTextureIds[Pvr_UnitySDKManager.SDK.currEyeTextureIdx + 3]; break; default: break; } Pvr_UnitySDKAPI.Render.UPvr_SetupLayerData(Eyes[i].layerIndex, (int)Eyes[i].eyeSide, eyeTextureId, 0, 0); Pvr_UnitySDKAPI.Render.UPvr_SetupLayerCoords(Eyes[i].layerIndex, (int)Eyes[i].eyeSide, lowerLeft, lowerRight, upperLeft, upperRight); this.RecordEnableLayers(Eyes[i].eyeSide, Eyes[i].layerIndex, ref leftEyeEnableLayers, ref rightEyeEnableLayers); } // for overlay :current only support one layer for (int i = 0; i < Overlays.Length; i++) { if (!Overlays[i].isActiveAndEnabled) { continue; } if (Overlays[i].imageTexture == null) { continue; } if (Overlays[i].imageTransform != null && !Overlays[i].imageTransform.gameObject.activeSelf) { continue; } #region LL UL UR LR // LL lowerLeft[0] = Overlays[i].clipLowerLeft.x; lowerLeft[1] = Overlays[i].clipLowerLeft.y; lowerLeft[2] = Overlays[i].clipLowerLeft.z; lowerLeft[3] = Overlays[i].clipLowerLeft.w; lowerLeft[4] = Overlays[i].uvLowerLeft.x; lowerLeft[5] = Overlays[i].uvLowerLeft.y; // UL upperLeft[0] = Overlays[i].clipUpperLeft.x; upperLeft[1] = Overlays[i].clipUpperLeft.y; upperLeft[2] = Overlays[i].clipUpperLeft.z; upperLeft[3] = Overlays[i].clipUpperLeft.w; upperLeft[4] = Overlays[i].uvUpperLeft.x; upperLeft[5] = Overlays[i].uvUpperLeft.y; // UR upperRight[0] = Overlays[i].clipUpperRight.x; upperRight[1] = Overlays[i].clipUpperRight.y; upperRight[2] = Overlays[i].clipUpperRight.z; upperRight[3] = Overlays[i].clipUpperRight.w; upperRight[4] = Overlays[i].uvUpperRight.x; upperRight[5] = Overlays[i].uvUpperRight.y; // LR lowerRight[0] = Overlays[i].clipLowerRight.x; lowerRight[1] = Overlays[i].clipLowerRight.y; lowerRight[2] = Overlays[i].clipLowerRight.z; lowerRight[3] = Overlays[i].clipLowerRight.w; lowerRight[4] = Overlays[i].uvLowerRight.x; lowerRight[5] = Overlays[i].uvLowerRight.y; #endregion Pvr_UnitySDKAPI.Render.UPvr_SetupLayerData(Overlays[i].layerIndex, (int)Overlays[i].eyeSide, Overlays[i].ImageTextureId, 0, 0); Pvr_UnitySDKAPI.Render.UPvr_SetupLayerCoords(Overlays[i].layerIndex, (int)Overlays[i].eyeSide, lowerLeft, lowerRight, upperLeft, upperRight); this.RecordEnableLayers(Overlays[i].eyeSide, Overlays[i].layerIndex, ref leftEyeEnableLayers, ref rightEyeEnableLayers); } for (int index = 0; index < this.RenderLayersMax; index++) { // Left Layers if (!leftEyeEnableLayers.Contains(index)) { Pvr_UnitySDKAPI.Render.UPvr_SetupLayerData(index, (int)Pvr_UnitySDKAPI.Eye.LeftEye, 0, 0, 0); } // Right Layers if (!rightEyeEnableLayers.Contains(index)) { Pvr_UnitySDKAPI.Render.UPvr_SetupLayerData(index, (int)Pvr_UnitySDKAPI.Eye.RightEye, 0, 0, 0); } } #endregion } Pvr_UnitySDKPluginEvent.IssueWithData(RenderEventType.TimeWarp, Pvr_UnitySDKManager.SDK.RenderviewNumber); Pvr_UnitySDKManager.SDK.currEyeTextureIdx = Pvr_UnitySDKManager.SDK.nextEyeTextureIdx; Pvr_UnitySDKManager.SDK.nextEyeTextureIdx = (Pvr_UnitySDKManager.SDK.nextEyeTextureIdx + 1) % 3; } }
IEnumerator EndOfFrame() { while (true) { yield return(new WaitForEndOfFrame()); #if !UNITY_EDITOR if (!Pvr_UnitySDKManager.SDK.isEnterVRMode) { // Call GL.clear before Enter VRMode to avoid unexpected graph breaking. GL.Clear(false, true, Color.black); } #endif if (isFirstStartup && frameNum == this.WaitSplashScreenFrames) { Pvr_UnitySDKAPI.System.UPvr_RemovePlatformLogo(); Pvr_UnitySDKAPI.System.UPvr_StartVRModel(); isFirstStartup = false; } else if (isFirstStartup && frameNum < this.WaitSplashScreenFrames) { Debug.Log("+++++++++++++++++++++++++++++++" + frameNum); frameNum++; } #region Eyebuffer #if UNITY_2018_1_OR_NEWER if (UnityEngine.Rendering.GraphicsSettings.renderPipelineAsset != null) { for (int i = 0; i < Eyes.Length; i++) { if (!Eyes[i].isActiveAndEnabled) { continue; } switch (Eyes[i].eyeSide) { case Pvr_UnitySDKAPI.Eye.LeftEye: eyeTextureId = Pvr_UnitySDKManager.SDK.eyeTextureIds[Pvr_UnitySDKManager.SDK.currEyeTextureIdx]; eventType = RenderEventType.LeftEyeEndFrame; boundaryEventType = RenderEventType.BoundaryRenderLeft; break; case Pvr_UnitySDKAPI.Eye.RightEye: if (!Pvr_UnitySDKManager.SDK.Monoscopic) { eyeTextureId = Pvr_UnitySDKManager.SDK.eyeTextureIds[Pvr_UnitySDKManager.SDK.currEyeTextureIdx + 3]; } else { eyeTextureId = Pvr_UnitySDKManager.SDK.eyeTextureIds[Pvr_UnitySDKManager.SDK.currEyeTextureIdx]; } eventType = RenderEventType.RightEyeEndFrame; boundaryEventType = RenderEventType.BoundaryRenderRight; break; default: break; } // eyebuffer Pvr_UnitySDKPluginEvent.IssueWithData(eventType, eyeTextureId); // boundary if (!Pvr_UnitySDKManager.SDK.HmdOnlyrot) { Pvr_UnitySDKPluginEvent.IssueWithData(boundaryEventType, Pvr_UnitySDKManager.SDK.RenderviewNumber); } Pvr_UnitySDKPluginEvent.Issue(RenderEventType.EndEye); } } #endif #endregion // Compositor Layers: if find Overlay then Open Compositor Layers feature #region Compositor Layers if (Pvr_UnitySDKEyeOverlay.Instances.Count > 0) { overlayLayerDepth = 1; underlayLayerDepth = 0; Pvr_UnitySDKEyeOverlay.Instances.Sort(); for (int i = 0; i < Overlays.Length; i++) { if (!Overlays[i].isActiveAndEnabled) { continue; } if (Overlays[i].layerTextures[0] == null && Overlays[i].layerTextures[1] == null) { continue; } if (Overlays[i].layerTransform != null && !Overlays[i].layerTransform.gameObject.activeSelf) { continue; } if (Overlays[i].imageType == Pvr_UnitySDKEyeOverlay.ImageType.StandardTexture) { if (Overlays[i].overlayType == Pvr_UnitySDKEyeOverlay.OverlayType.Overlay) { isHeadLocked = false; if (Overlays[i].layerTransform != null && Overlays[i].layerTransform.parent == this.transform) { isHeadLocked = true; } Pvr_UnitySDKAPI.Render.UPvr_SetOverlayModelViewMatrix((int)Overlays[i].overlayType, Overlays[i].layerTextureIds[0], (int)Pvr_UnitySDKAPI.Eye.LeftEye, overlayLayerDepth, isHeadLocked, Overlays[i].MVMatrixs[0]); Pvr_UnitySDKAPI.Render.UPvr_SetOverlayModelViewMatrix((int)Overlays[i].overlayType, Overlays[i].layerTextureIds[1], (int)Pvr_UnitySDKAPI.Eye.RightEye, overlayLayerDepth, isHeadLocked, Overlays[i].MVMatrixs[1]); overlayLayerDepth++; } else if (Overlays[i].overlayType == Pvr_UnitySDKEyeOverlay.OverlayType.Underlay) { Pvr_UnitySDKAPI.Render.UPvr_SetOverlayModelViewMatrix((int)Overlays[i].overlayType, Overlays[i].layerTextureIds[0], (int)Pvr_UnitySDKAPI.Eye.LeftEye, underlayLayerDepth, false, Overlays[i].MVMatrixs[0]); Pvr_UnitySDKAPI.Render.UPvr_SetOverlayModelViewMatrix((int)Overlays[i].overlayType, Overlays[i].layerTextureIds[1], (int)Pvr_UnitySDKAPI.Eye.RightEye, underlayLayerDepth, false, Overlays[i].MVMatrixs[1]); underlayLayerDepth++; } } else if (Overlays[i].imageType == Pvr_UnitySDKEyeOverlay.ImageType.EquirectangularTexture) { // 360 Overlay Equirectangular Texture Pvr_UnitySDKAPI.Render.UPvr_SetupLayerData(0, (int)Pvr_UnitySDKAPI.Eye.LeftEye, Overlays[i].layerTextureIds[0], (int)Overlays[i].imageType, 0); Pvr_UnitySDKAPI.Render.UPvr_SetupLayerData(0, (int)Pvr_UnitySDKAPI.Eye.RightEye, Overlays[i].layerTextureIds[1], (int)Overlays[i].imageType, 0); } } #endregion } // Begin TimeWarp Pvr_UnitySDKPluginEvent.IssueWithData(RenderEventType.TimeWarp, Pvr_UnitySDKManager.SDK.RenderviewNumber); Pvr_UnitySDKManager.SDK.currEyeTextureIdx = Pvr_UnitySDKManager.SDK.nextEyeTextureIdx; Pvr_UnitySDKManager.SDK.nextEyeTextureIdx = (Pvr_UnitySDKManager.SDK.nextEyeTextureIdx + 1) % 3; } }
/************************************ End Of Per Frame *************************************/ IEnumerator EndOfFrame() { while (true) { yield return(new WaitForEndOfFrame()); if (isfirst && framenum == 3) { Pvr_UnitySDKAPI.System.UPvr_RemovePlatformLogo(); Pvr_UnitySDKAPI.System.UPvr_StartVRModel(); isfirst = false; } else if (isfirst && framenum < 3) { Debug.Log("+++++++++++++++++++++++++++++++" + framenum); framenum++; GL.Clear(false, true, Color.black); } // if find Overlay then Open Composition Layers feature if (Pvr_UnitySDKEyeOverlay.Instances.Count > 0) { #region Composition Layers Pvr_UnitySDKEyeOverlay.Instances.Sort(); // for Overlay for (int i = 0; i < Overlays.Length; i++) { if (!Overlays[i].gameObject.activeSelf) { continue; } if (!Overlays[i].isActiveAndEnabled) { continue; } if (Overlays[i].imageTexture == null) { continue; } if (Overlays[i].imageTransform != null && !Overlays[i].imageTransform.gameObject.activeSelf) { continue; } if (Overlays[i].imageType == Pvr_UnitySDKEyeOverlay.ImageType.StandardTexture) { // 2D Overlay Standard Texture Pvr_UnitySDKAPI.Render.UPvr_SetOverlayModelViewMatrix(Overlays[i].ImageTextureId, (int)Overlays[i].eyeSide, 1, Overlays[i].MVMatrix); } else if (Overlays[i].imageType == Pvr_UnitySDKEyeOverlay.ImageType.EquirectangularTexture) { // 360 Overlay Equirectangular Texture Pvr_UnitySDKAPI.Render.UPvr_SetupLayerData(0, (int)Overlays[i].eyeSide, Overlays[i].ImageTextureId, (int)Overlays[i].imageType, 0); } } #endregion } Pvr_UnitySDKPluginEvent.IssueWithData(RenderEventType.TimeWarp, Pvr_UnitySDKManager.SDK.RenderviewNumber); Pvr_UnitySDKManager.SDK.currEyeTextureIdx = Pvr_UnitySDKManager.SDK.nextEyeTextureIdx; Pvr_UnitySDKManager.SDK.nextEyeTextureIdx = (Pvr_UnitySDKManager.SDK.nextEyeTextureIdx + 1) % 3; } }