public void BeginCapture(CaptureHeadbox headbox, string capture_dir, int max_frames, CaptureStatus status_interface) { start_time_ = Time.realtimeSinceStartup; headbox_ = headbox; dynamic_range_ = headbox_.dynamic_range_; samples_per_face_ = (int)headbox_.samples_per_face_; capture_dir_ = capture_dir; capture_frame_ = 0; status_interface_ = status_interface; max_frames_ = max_frames; status_interface_.SendProgress("Capturing Images...", 0.0f); List <Vector3> samples = new List <Vector3>(); // Use Hammersly point set to distribute samples. for (int position_sample_index = 0; position_sample_index < samples_per_face_; ++position_sample_index) { Vector3 headbox_position = new Vector3( (float)position_sample_index / (float)(samples_per_face_ - 1), RadicalInverse((ulong)position_sample_index, 2), RadicalInverse((ulong)position_sample_index, 3)); headbox_position.Scale(headbox.size_); headbox_position -= headbox.size_ * 0.5f; // Headbox samples are in camera space; transform to world space. headbox_position = headbox.transform.TransformPoint(headbox_position); samples.Add(headbox_position); } // Sort samples by distance from center of the headbox. samples.Sort(delegate(Vector3 a, Vector3 b) { float length_a = a.sqrMagnitude; float length_b = b.sqrMagnitude; return(length_a.CompareTo(length_b)); }); // Replace the sample closest to the center of the headbox with a sample at // exactly the center. This is important because Seurat requires // sampling information at the center of the headbox. samples[0] = headbox.transform.position; samples_ = samples; // Note this uses a modified version of Unity's standard internal depth // capture shader. See the shader in Assets/builtin_shaders/ // DefaultResourcesExtra/Internal-DepthNormalsTexture.shader. render_depth_shader_ = Shader.Find("GoogleVR/Seurat/CaptureEyeDepth"); capture_manifest_ = new JsonManifest.Capture(); // Setup cameras color_camera_ = headbox_.ColorCamera; depth_camera_object_ = new GameObject("Depth Camera"); depth_camera_ = depth_camera_object_.AddComponent <Camera>(); //Checks if we are using HDRP, if so, we need to add additional components. #if UNITY_RENDER_PIPELINE_HDRP OverrideMaterialRenderer overrideMaterialRenderer = depth_camera_object_.AddComponent <OverrideMaterialRenderer>(); overrideMaterialRenderer.EnableOverride(); #endif }
public void SetupCaptureProcess(CaptureHeadbox capture_notification_component, CaptureBuilder capture) { capture_timer_ = kTimerExpirationsPerCapture; bake_stage_ = BakeStage.kCapture; last_time_ = Time.realtimeSinceStartup; capture_notification_component_ = capture_notification_component; monitored_capture_ = capture; }
public void Capture() { CaptureHeadbox headbox = (CaptureHeadbox)target; string capture_output_folder = headbox.output_folder_; if (capture_output_folder.Length <= 0) { capture_output_folder = FileUtil.GetUniqueTempPathInProject(); } headbox.last_output_dir_ = capture_output_folder; Directory.CreateDirectory(capture_output_folder); capture_status_ = new EditorBakeStatus(); capture_builder_ = new CaptureBuilder(); // Kick off the interactive Editor bake window. bake_progress_window_ = (CaptureWindow)EditorWindow.GetWindow(typeof(CaptureWindow)); bake_progress_window_.SetupStatus(capture_status_); capture_builder_.BeginCapture(headbox, capture_output_folder, 1, capture_status_); bake_progress_window_.SetupCaptureProcess(headbox, capture_builder_); }