forked from googlevr/seurat-unity-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSeuratAutomator.cs
More file actions
107 lines (98 loc) · 4.83 KB
/
SeuratAutomator.cs
File metadata and controls
107 lines (98 loc) · 4.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Seurat
{
[ExecuteInEditMode]
public class SeuratAutomator : MonoBehaviour
{
// Capture Settings
[SerializeField, Tooltip("Folders for each headbox will be created in this folder")]
public string output_folder_;
[SerializeField, Tooltip("If true, all child capture headboxes will have their parameters overriden by the Override settings below")]
private bool override_all_ = true;
[Header("Override Settings")]
[SerializeField, Tooltip("The number of samples per face of the headbox.")]
private PositionSampleCount samples_per_face_ = PositionSampleCount.k32;
[SerializeField, Tooltip("The resolution of the center image, taken at the camera position at the center of the headbox. This should be 4x higher than the resolution of the remaining samples, for antialiasing.")]
private CubeFaceResolution center_resolution_ = CubeFaceResolution.k4096;
[SerializeField, Tooltip("The resolution of all samples other than the center.")]
private CubeFaceResolution resolution_ = CubeFaceResolution.k1024;
[SerializeField, Tooltip("Capture in standard (SDR) or high dynamic range (HDR). HDR requires floating-point render targets, the Camera Component have allow HDR enabled, and enables EXR output.")]
private CaptureDynamicRange dynamic_range_ = CaptureDynamicRange.kSDR;
// Pipeline Settings
[SerializeField, Tooltip("Path to the executable that runs the seurat pipeline")]
public string seurat_executable_path_;
[Tooltip("If true, cache output geometry in cache folders. Cache speeds up repeated iterations, useful if iterating on textures. Unique folder will be created for each capture.")]
public bool use_cache_;
[Tooltip("Seurat Commandline Params")]
public SeuratParams options = new SeuratParams
{
//Initialize with default values - note that premultiply_alphas is by default true, but Unity expects false
premultiply_alphas = false,
gamma = 1.0f,
triangle_count = 72000,
skybox_radius = 200.0f,
fast_preview = false
};
// Import Settings
[Tooltip("Folder to import meshes & textures to")]
public string asset_path_;
[Tooltip("List of all seurat meshes imported")]
public GameObject[] cur_meshes_;
[Tooltip("List of all seurat textures imported")]
public Texture2D[] cur_tex_;
// Scene Builder Settings
[Tooltip("Prefab to be resized for the headbox")]
public GameObject headbox_prefab_;
[Tooltip("Shader to use for each seurat material")]
public Shader seurat_shader_;
[Tooltip("Relative path to place each seurat mesh in, relative to the headbox prefab. Leave blank to spawn at root")]
public string prefab_path_;
[Tooltip("Target render queue position to set material to. Default is 1999, should be around there in order to interact with other objects in the scene.")]
public int render_queue_ = 1999;
[Tooltip("Select to save a material, instead of creating a local, scene relative material. Recommended")]
public bool use_mat_ = true;
[Tooltip("Path to place material in. Must be inside Asset folder.")]
public string material_path_;
[Tooltip("List of all materials built. If use_mat_ is false, this will not be used")]
public Material[] cur_mats_;
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 OverrideParams(CaptureHeadbox head)
{
head.options = options;
}
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 BuildScene()
{
GameObject scene = Instantiate(this.gameObject);
CaptureHeadbox[] headboxes = scene.GetComponentsInChildren<CaptureHeadbox>();
foreach (CaptureHeadbox box in headboxes)
{
box.BuildCapture(true, false);
}
SeuratAutomator auto = scene.GetComponent<SeuratAutomator>();
DestroyImmediate(auto);
}
}
}