Example #1
0
        public void Init()
        {
            Debug.AssertFormat(m_CaptureObjects.Length == (int)MultiCamStyle.Num,
                               "There needs to be exactly the number of capture objects as MultiCam styles.");

            // This is necessary to initialize the video renderer.
            gameObject.SetActive(true);
            gameObject.SetActive(false);

            for (int i = 0; i < m_CaptureObjects.Length; ++i)
            {
                m_CaptureObjects[i].m_Manager =
                    m_CaptureObjects[i].m_Camera.GetComponentInChildren <ScreenshotManager>(true);
                m_CaptureObjects[i].m_CameraComponent =
                    m_CaptureObjects[i].m_Camera.GetComponentInChildren <Camera>();
                m_CaptureObjects[i].m_CameraClipPlanesBase.x =
                    m_CaptureObjects[i].m_CameraComponent.nearClipPlane;
                m_CaptureObjects[i].m_CameraClipPlanesBase.y =
                    m_CaptureObjects[i].m_CameraComponent.farClipPlane;
            }

            m_VideoUsdSerializer = m_CaptureObjects[(int)MultiCamStyle.Video].m_Camera.GetComponentInChildren <UsdPathSerializer>(true);

            CameraConfig.FovChanged += UpdateFovs;
            UpdateFovs();
        }
  public void Init() {
    // This is necessary to initialize the video renderer.
    m_Object.SetActive(true);
    m_Object.SetActive(false);

    m_VideoUsdSerializer = m_Camera.GetComponentInChildren<UsdPathSerializer>(true);
    m_Manager = m_Camera.GetComponentInChildren<ScreenshotManager>(true);
    m_CameraComponent = m_Manager.GetComponent<Camera>();
    m_CameraClipPlanesBase.x = m_CameraComponent.nearClipPlane;
    m_CameraClipPlanesBase.y = m_CameraComponent.farClipPlane;
    m_Widget = GetComponentInChildren<CameraPathPreviewWidget>();
    m_Widget.gameObject.SetActive(false);
  }
Example #3
0
        static public void StopVideoCapture(bool saveCapture)
        {
            // Debug reset changes to quality settings.
            if (m_DebugVideoCaptureQualityLevel != -1)
            {
                QualityControls.m_Instance.QualityLevel = m_PreCaptureQualityLevel;
            }

            App.VrSdk.SetHmdScalingFactor(1.0f);

            // Stop capturing, reset colors
            m_ActiveVideoRecording.gameObject.GetComponent <RenderWrapper>().SuperSampling =
                m_PreCaptureSuperSampling;
            m_ActiveVideoRecording.StopCapture(save: saveCapture);

#if USD_SUPPORTED
            if (m_UsdPathSerializer != null)
            {
                bool wasRecording = m_UsdPathSerializer.IsRecording;
                m_UsdPathSerializer.Stop();
                if (wasRecording)
                {
                    m_RecordingStopwatch.Stop();
                    if (!string.IsNullOrEmpty(m_UsdPath))
                    {
                        if (App.UserConfig.Video.SaveCameraPath && saveCapture)
                        {
                            m_UsdPathSerializer.Save();
                            CreateOfflineRenderBatchFile(SaveLoadScript.m_Instance.SceneFile.FullPath, m_UsdPath);
                        }
                    }
                }
            }

            m_UsdPathSerializer  = null;
            m_RecordingStopwatch = null;
#endif

            m_ActiveVideoRecording = null;
            App.Switchboard.TriggerVideoRecordingStopped();
        }
Example #4
0
        static public bool StartVideoCapture(string filePath, VideoRecorder recorder,
                                             UsdPathSerializer usdPathSerializer, bool offlineRender = false)
        {
            // Only one video at a time.
            if (m_ActiveVideoRecording != null)
            {
                return(false);
            }

            // Don't start recording unless there is enough space left.
            if (!FileUtils.InitializeDirectoryWithUserError(
                    Path.GetDirectoryName(filePath),
                    "Failed to start video capture"))
            {
                return(false);
            }

            // Vertical video is disabled.
            recorder.IsPortrait = false;

            // Start the capture first, which may fail, so do this before toggling any state.
            // While the state below is important for the actual frame capture, starting the capture process
            // does not require it.
            int sampleRate = 0;

            if (AudioCaptureManager.m_Instance.IsCapturingAudio)
            {
                sampleRate = AudioCaptureManager.m_Instance.SampleRate;
            }

            if (!recorder.StartCapture(filePath, sampleRate,
                                       AudioCaptureManager.m_Instance.IsCapturingAudio, offlineRender,
                                       offlineRender ? App.UserConfig.Video.OfflineFPS : App.UserConfig.Video.FPS))
            {
                OutputWindowScript.ReportFileSaved("Failed to start capture!", null,
                                                   OutputWindowScript.InfoCardSpawnPos.Brush);
                return(false);
            }

            m_ActiveVideoRecording = recorder;

            // Perform any necessary VR camera rendering optimizations to reduce CPU & GPU workload

            // Debug reduce quality for capture.
            // XXX This should just be ADAPTIVE RENDERING
            if (m_DebugVideoCaptureQualityLevel != -1)
            {
                m_PreCaptureQualityLevel = QualityControls.m_Instance.QualityLevel;
                QualityControls.m_Instance.QualityLevel = m_DebugVideoCaptureQualityLevel;
            }

            App.VrSdk.SetHmdScalingFactor(m_VideoCaptureResolutionScale);

            // Setup SSAA
            RenderWrapper wrapper = recorder.gameObject.GetComponent <RenderWrapper>();

            m_PreCaptureSuperSampling = wrapper.SuperSampling;
            wrapper.SuperSampling     = m_SuperSampling;

#if USD_SUPPORTED
            // Read from the Usd serializer if we're recording offline.  Write to it otherwise.
            m_UsdPathSerializer = usdPathSerializer;
            if (!offlineRender)
            {
                m_UsdPath = SaveLoadScript.m_Instance.SceneFile.Valid ?
                            Path.ChangeExtension(filePath, "usda") : null;
                m_RecordingStopwatch = new System.Diagnostics.Stopwatch();
                m_RecordingStopwatch.Start();
                if (!m_UsdPathSerializer.StartRecording(m_UsdPath))
                {
                    UnityEngine.Object.Destroy(m_UsdPathSerializer);
                    m_UsdPathSerializer = null;
                }
            }
            else
            {
                recorder.SetCaptureFramerate(Mathf.RoundToInt(App.UserConfig.Video.OfflineFPS));
                m_UsdPath = null;
                if (m_UsdPathSerializer.Load(App.Config.m_VideoPathToRender))
                {
                    m_UsdPathSerializer.StartPlayback();
                }
                else
                {
                    UnityEngine.Object.Destroy(m_UsdPathSerializer);
                    m_UsdPathSerializer = null;
                }
            }
#endif

            return(true);
        }
Example #5
0
        public void BeginRender()
        {
            IsRendering = true;

            // Turn off shadows, until depth disparity can be fixed.
            // See http://b/68952256 for details
            UnityEngine.QualitySettings.shadows = ShadowQuality.Disable;
            for (int i = 0; i < App.Scene.GetNumLights(); i++)
            {
                App.Scene.GetLight(i).shadows = LightShadows.None;
            }

            for (int i = 0; ; ++i)
            {
                string o      = string.Format("{0}_{1:00}", m_outputBasename, i);
                string outVid = Path.Combine(m_outputFolder, o + ".mp4");
                string outDir = Path.Combine(m_outputFolder, o + "/");

                if (!File.Exists(outVid) && !File.Exists(outDir))
                {
                    m_videoPath  = outVid;
                    m_imagesPath = outDir + m_outputBasename;

                    m_odsCamera.outputFolder = outDir;
                    m_odsCamera.basename     = m_outputBasename;

                    // Touch the destination folder.
                    Directory.CreateDirectory(outDir);

                    // Touch the destination file.
                    FileStream fs = File.Open(m_videoPath, FileMode.OpenOrCreate,
                                              FileAccess.Write, FileShare.ReadWrite);
                    fs.Close();
                    fs.Dispose();
                    File.SetLastWriteTimeUtc(m_videoPath, System.DateTime.UtcNow);
                    break;
                }
            }

            if (!string.IsNullOrEmpty(CameraPath) && File.Exists(CameraPath))
            {
#if USD_SUPPORTED
                m_PathSerializer = gameObject.AddComponent <UsdPathSerializer>();
                if (m_PathSerializer.Load(CameraPath))
                {
                    m_PathSerializer.StartPlayback("/Sketch", "/VideoCamera");
                    FramesToCapture       = Mathf.FloorToInt((float)(m_PathSerializer.Duration) * m_fps);
                    m_PathSerializer.Time = 0;
                    m_PathSerializer.Deserialize();
                }
                else
                {
                    Destroy(m_PathSerializer);
                    m_PathSerializer = null;
                }
#else
                throw new System.NotImplementedException("CameraPath requires USD support");
#endif
            }

            Debug.LogFormat("ODS Output Video: {0}" + System.Environment.NewLine +
                            "ODS Output Path: {1}" + System.Environment.NewLine +
                            "ODS Basename: {2}"
                            , m_videoPath, m_odsCamera.outputFolder, m_odsCamera.basename);

            Shader.SetGlobalFloat("ODS_PoleCollapseAmount", App.UserConfig.Video.OdsPoleCollapsing);


            gameObject.SetActive(true);

            App.Instance.FrameCountDisplay.gameObject.SetActive(true);
        }