public void RunSeurat()
        {
            CaptureHeadbox headbox = (CaptureHeadbox)target;
            string         seurat_output_folder = headbox.seurat_output_folder_;

            if (seurat_output_folder.Length <= 0)
            {
                seurat_output_folder          = FileUtil.GetUniqueTempPathInProject();
                headbox.seurat_output_folder_ = seurat_output_folder;
            }
            if (headbox.use_cache_)
            {
                string cache_folder_ = headbox.cache_folder_;
                if (cache_folder_.Length <= 0)
                {
                    cache_folder_ = FileUtil.GetUniqueTempPathInProject();
                }
                Directory.CreateDirectory(cache_folder_);
            }
            Directory.CreateDirectory(seurat_output_folder);
            string args = headbox.GetArgString();

            status_interface_ = new SeuratRunnerStatus();
            pipeline_runner_  = new SeuratPipelineRunner(
                args,
                headbox.seurat_exec_,
                status_interface_);

            runner_progress_window_ = (SeuratWindow)EditorWindow.GetWindow(typeof(SeuratWindow));
            runner_progress_window_.SetupStatus(status_interface_);

            runner_progress_window_.SetupRunnerProcess(headbox, pipeline_runner_);
        }
 public void SetupRunnerProcess(CaptureHeadbox capture_notification_component,
                                SeuratPipelineRunner runner)
 {
     bake_stage_ = BakeStage.kRunning;
     capture_notification_component_ = capture_notification_component;
     monitored_runner_ = runner;
     monitored_runner_.Run();
 }
        public void ImportAssets()
        {
            CaptureHeadbox headbox = (CaptureHeadbox)target;

            headbox.CopyFiles();
            headbox.ImportSeurat();
            headbox.FetchAssets();
            UnityEditor.EditorUtility.SetDirty(headbox);
        }
 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;
 }
Example #5
0
 public void OverrideHeadbox(CaptureHeadbox head)
 {
     if (override_all_)
     {
         head.samples_per_face_  = samples_per_face_;
         head.center_resolution_ = center_resolution_;
         head.resolution_        = resolution_;
         head.dynamic_range_     = dynamic_range_;
     }
 }
        public void BeginCapture(CaptureHeadbox headbox, string capture_dir, int max_frames, CaptureStatus status_interface, string to_prepend = "")
        {
            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(to_prepend + "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>();
        }
Example #7
0
 public void OverrideSceneBuilder(CaptureHeadbox head)
 {
     head.prefab_path_    = prefab_path_;
     head.headbox_prefab_ = headbox_prefab_;
     head.seurat_shader_  = seurat_shader_;
     head.render_queue_   = render_queue_;
     if (use_mat_)
     {
         head.material_path_ = material_path_;
         head.use_mat_       = use_mat_;
     }
 }
        public void Capture()
        {
            SeuratAutomator automator = (SeuratAutomator)target;

            string capture_output_folder = automator.output_folder_;

            if (capture_output_folder.Length <= 0)
            {
                capture_output_folder = FileUtil.GetUniqueTempPathInProject();
            }
            Directory.CreateDirectory(capture_output_folder);

            int numCaptures = automator.transform.childCount;

            capture_status_  = new AutomatorStatus();
            capture_builder_ = new CaptureBuilder[numCaptures];
            CaptureHeadbox[] headboxes = new CaptureHeadbox[numCaptures];
            bake_progress_window_ = (AutomateWindow)EditorWindow.GetWindow(typeof(AutomateWindow));
            bake_progress_window_.SetupStatus(capture_status_);
            int num_not_null = 0;

            for (int i = 0; i < numCaptures; i++)
            {
                headboxes[i] = automator.transform.GetChild(i).GetComponent <CaptureHeadbox>();
                if (headboxes[i].isActiveAndEnabled)
                {
                    num_not_null++;
                    capture_builder_[i] = new CaptureBuilder();
                    automator.OverrideHeadbox(headboxes[i]);
                    string output = capture_output_folder + "\\" + (i + 1);
                    headboxes[i].output_folder_ = output;
                    UnityEditor.EditorUtility.SetDirty(headboxes[i]);
                    Directory.CreateDirectory(output);
                    capture_builder_[i].BeginCapture(headboxes[i], output, 1, capture_status_, "Capture " + (i + 1) + ": ");
                }
            }
            CaptureHeadbox[] total_headboxes        = new CaptureHeadbox[num_not_null];
            CaptureBuilder[] total_capture_builders = new CaptureBuilder[num_not_null];
            int j = 0;

            for (int i = 0; i < numCaptures; i++)
            {
                if (capture_builder_[i] != null)
                {
                    total_headboxes[j]        = headboxes[i];
                    total_capture_builders[j] = capture_builder_[i];
                    j++;
                }
            }

            bake_progress_window_.SetupCaptureProcess(total_headboxes, total_capture_builders);
        }
        private void BuildScene()
        {
            SeuratAutomator automator   = (SeuratAutomator)target;
            int             numCaptures = automator.transform.childCount;

            CaptureHeadbox[] headboxes = new CaptureHeadbox[numCaptures];
            for (int i = 0; i < numCaptures; i++)
            {
                headboxes[i] = automator.transform.GetChild(i).GetComponent <CaptureHeadbox>();
                automator.OverrideSceneBuilder(headboxes[i]);
                UnityEditor.EditorUtility.SetDirty(headboxes[i]);
            }

            automator.BuildScene();
        }
        public void BuildMaterials()
        {
            SeuratAutomator automator   = (SeuratAutomator)target;
            int             numCaptures = automator.transform.childCount;

            CaptureHeadbox[] headboxes = new CaptureHeadbox[numCaptures];
            automator.cur_mats_ = new Material[numCaptures];

            for (int i = 0; i < numCaptures; i++)
            {
                headboxes[i] = automator.transform.GetChild(i).GetComponent <CaptureHeadbox>();
                automator.OverrideSceneBuilder(headboxes[i]);
                automator.cur_mats_[i] = headboxes[i].CreateMaterial();
                UnityEditor.EditorUtility.SetDirty(headboxes[i]);
            }
            UnityEditor.EditorUtility.SetDirty(automator);
        }
        public void RunSeurat()
        {
            SeuratAutomator automator             = (SeuratAutomator)target;
            string          capture_output_folder = automator.output_folder_;
            string          exec_path             = automator.seurat_executable_path_;
            int             numCaptures           = automator.transform.childCount;

            runner_status_ = new SeuratCollectionRunnerStatus();

            CaptureHeadbox[]       headboxes = new CaptureHeadbox[numCaptures];
            SeuratPipelineRunner[] runners   = new SeuratPipelineRunner[numCaptures];

            for (int i = 0; i < numCaptures; i++)
            {
                headboxes[i] = automator.transform.GetChild(i).GetComponent <CaptureHeadbox>();
                if (headboxes[i].isActiveAndEnabled)
                {
                    headboxes[i].output_folder_        = Path.Combine(capture_output_folder, (i + 1).ToString());
                    headboxes[i].seurat_output_folder_ = capture_output_folder;
                    Directory.CreateDirectory(capture_output_folder);
                    headboxes[i].seurat_output_name_ = "capture_" + (i + 1);
                    if (automator.use_cache_)
                    {
                        headboxes[i].use_cache_ = true;
                        string cache_path = Path.Combine(capture_output_folder, "capture_" + (i + 1) + "_cache");
                        headboxes[i].cache_folder_ = cache_path;
                        Directory.CreateDirectory(cache_path);
                    }
                    automator.OverrideParams(headboxes[i]);
                    string arg = headboxes[i].GetArgString();
                    UnityEditor.EditorUtility.SetDirty(headboxes[i]);
                    runners[i] = new SeuratPipelineRunner(arg, exec_path, runner_status_);
                }
            }
            Debug.Log("All processes set up");
            Debug.Log("Beginning seurat captures...");
            collection_runner_ = new SeuratPipelineCollectionRunner(runners, runner_status_);

            runner_window_ = (SeuratRunnerWindow)EditorWindow.GetWindow(typeof(SeuratRunnerWindow));
            runner_window_.SetupStatus(runner_status_);

            runner_window_.SetupRunnerProcess(automator, collection_runner_);
        }
        public void ImportAll()
        {
            SeuratAutomator automator      = (SeuratAutomator)target;
            string          output_folder_ = automator.output_folder_;
            int             numCaptures    = automator.transform.childCount;

            CaptureHeadbox[] headboxes = new CaptureHeadbox[numCaptures];
            automator.cur_meshes_ = new GameObject[numCaptures];
            automator.cur_tex_    = new Texture2D[numCaptures];

            Debug.Log("Setting up all headboxes...");
            for (int i = 0; i < numCaptures; i++)
            {
                headboxes[i] = automator.transform.GetChild(i).GetComponent <CaptureHeadbox>();
                headboxes[i].seurat_output_name_   = "capture_" + (i + 1);
                headboxes[i].seurat_output_folder_ = output_folder_;
                headboxes[i].asset_path_           = automator.asset_path_;
                UnityEditor.EditorUtility.SetDirty(headboxes[i]);
            }
            Debug.Log("Copying assets to project folder...");
            for (int i = 0; i < numCaptures; i++)
            {
                headboxes[i].CopyFiles();
            }
            Debug.Log("Beginning import...");
            AssetDatabase.Refresh();
            for (int i = 0; i < numCaptures; i++)
            {
                headboxes[i].CorrectTextureSettings();
            }
            Debug.Log("Fetch imported assets...");
            for (int i = 0; i < numCaptures; i++)
            {
                headboxes[i].FetchAssets();
                automator.cur_meshes_[i] = headboxes[i].current_obj_;
                automator.cur_tex_[i]    = headboxes[i].current_tex_;
                UnityEditor.EditorUtility.SetDirty(headboxes[i]);
            }
            UnityEditor.EditorUtility.SetDirty(automator);
        }
        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_);
        }
        public void BuildScene()
        {
            CaptureHeadbox headbox = (CaptureHeadbox)target;

            headbox.BuildCapture();
        }
        public void BuildMaterial()
        {
            CaptureHeadbox headbox = (CaptureHeadbox)target;

            headbox.CreateMaterial();
        }
Example #16
0
 public void OverrideParams(CaptureHeadbox head)
 {
     head.options = options;
 }