/// public override void OnInspectorGUI() { serializedObject.Update(); RoveCamera rove_camera = (RoveCamera)target; EditorGUILayout.BeginVertical("box"); { EditorGUILayout.BeginVertical(m_dark_style); { GUILayout.Space(10); EditorGUILayout.BeginHorizontal(); { int logo_width = 256; int logo_height = 64; GUILayout.Space((EditorGUIUtility.currentViewWidth / 2) - (logo_width / 2) - 10); EditorGUILayout.LabelField(new GUIContent(m_logo), GUILayout.Width(logo_width), GUILayout.Height(logo_height)); EditorGUILayout.EndHorizontal(); } GUILayout.Space(10); m_dark_style.normal.background = m_gbg; EditorGUILayout.BeginVertical(m_dark_style); { m_dark_style.fontSize = 17; m_dark_style.alignment = TextAnchor.MiddleCenter; EditorGUILayout.LabelField("Camera", m_dark_style); m_dark_style.fontSize = 12; m_dark_style.alignment = TextAnchor.MiddleLeft; EditorGUILayout.EndVertical(); } m_dark_style.normal.background = m_bg; EditorGUILayout.EndVertical(); } EditorGUILayout.EndVertical(); } EditorGUILayout.BeginVertical(m_dark_style); { EditorGUILayout.BeginVertical("box"); { EditorGUILayout.BeginVertical(m_dark_style); { GUILayout.Space(20); m_dark_style.fontSize = 17; m_dark_style.alignment = TextAnchor.MiddleCenter; EditorGUILayout.LabelField("Lens", m_dark_style); m_dark_style.fontSize = 12; m_dark_style.alignment = TextAnchor.MiddleLeft; GUILayout.Space(20); EditorGUILayout.BeginHorizontal(m_dark_style); { EditorGUI.BeginChangeCheck(); { EditorGUILayout.LabelField("Field Of View: ", m_dark_style, GUILayout.MaxWidth(100.0f)); mp_field_of_view.floatValue = EditorGUILayout.Slider(mp_field_of_view.floatValue, 1.0f, 360.0f); if (Application.isPlaying && EditorGUI.EndChangeCheck()) { rove_camera.SetFieldOfView(mp_field_of_view.floatValue); } } EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); { EditorGUI.BeginChangeCheck(); { EditorGUILayout.LabelField("Aperture Size: ", m_dark_style, GUILayout.MaxWidth(100.0f)); mp_aperture_size.floatValue = EditorGUILayout.Slider(mp_aperture_size.floatValue, 0.0f, 1.0f); if (Application.isPlaying && EditorGUI.EndChangeCheck()) { rove_camera.SetCameraApertureSize(mp_aperture_size.floatValue); } } EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); { EditorGUI.BeginChangeCheck(); { EditorGUILayout.LabelField("Focal Depth: ", m_dark_style, GUILayout.MaxWidth(100.0f)); mp_focal_depth.floatValue = EditorGUILayout.Slider(mp_focal_depth.floatValue, 0.1f, 500.0f); if (Application.isPlaying && EditorGUI.EndChangeCheck()) { rove_camera.SetCameraFocalDepth(mp_focal_depth.floatValue); } } EditorGUILayout.EndHorizontal(); } GUILayout.Space(10); EditorGUILayout.EndVertical(); } EditorGUILayout.EndVertical(); } EditorGUILayout.EndVertical(); } EditorGUILayout.BeginVertical(m_dark_style); { EditorGUILayout.BeginVertical("box"); { EditorGUILayout.BeginVertical(m_dark_style); { GUILayout.Space(20); m_dark_style.fontSize = 17; m_dark_style.alignment = TextAnchor.MiddleCenter; EditorGUILayout.LabelField("Image Adjustment", m_dark_style); m_dark_style.fontSize = 12; m_dark_style.alignment = TextAnchor.MiddleLeft; GUILayout.Space(20); EditorGUI.BeginChangeCheck(); { EditorGUILayout.BeginHorizontal(); { EditorGUILayout.LabelField("Tonemapping: ", m_dark_style, GUILayout.MaxWidth(100.0f)); string[] tonemaps = { "None", "Basic" }; mp_tonemap.intValue = EditorGUILayout.Popup(mp_tonemap.intValue, tonemaps); EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); { EditorGUILayout.LabelField("Gamma: ", m_dark_style, GUILayout.MaxWidth(100.0f)); mp_gamma.floatValue = EditorGUILayout.Slider(mp_gamma.floatValue, 0.0f, 5.0f); EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); { EditorGUILayout.LabelField("Exposure: ", m_dark_style, GUILayout.MaxWidth(100.0f)); mp_exposure.floatValue = EditorGUILayout.Slider(mp_exposure.floatValue, 0.0f, 10.0f); EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); { EditorGUILayout.LabelField("Contrast: ", m_dark_style, GUILayout.MaxWidth(100.0f)); mp_contrast.floatValue = EditorGUILayout.Slider(mp_contrast.floatValue, 0.0f, 2.0f); EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); { EditorGUILayout.LabelField("Saturation: ", m_dark_style, GUILayout.MaxWidth(100.0f)); mp_saturation.floatValue = EditorGUILayout.Slider(mp_saturation.floatValue, 0.0f, 2.0f); EditorGUILayout.EndHorizontal(); } EditorGUILayout.BeginHorizontal(); { EditorGUILayout.LabelField("Brightness: ", m_dark_style, GUILayout.MaxWidth(100.0f)); mp_brightness.floatValue = EditorGUILayout.Slider(mp_brightness.floatValue, 0.0f, 2.0f); EditorGUILayout.EndHorizontal(); } if (Application.isPlaying && EditorGUI.EndChangeCheck()) { rove_camera.SetImageProperties(mp_tonemap.boolValue, mp_gamma.floatValue, mp_exposure.floatValue, mp_contrast.floatValue, mp_saturation.floatValue, mp_brightness.floatValue); } } GUILayout.Space(10); EditorGUILayout.EndVertical(); } EditorGUILayout.EndVertical(); } EditorGUILayout.EndVertical(); } serializedObject.ApplyModifiedProperties(); }
/// IEnumerator SetupRove() { yield return(new WaitForEndOfFrame()); m_last_screen_size = new Vector2(Screen.width, Screen.height); string data_path = Application.dataPath + "/Rove/Data"; string log_path = data_path + "/rove.log"; bool valid_log_file = false; try { File.WriteAllText(log_path, "Test write to log."); valid_log_file = true; } catch { valid_log_file = false; } if (!valid_log_file) { Debug.LogError("Rove: Unable to write to log file at: " + log_path + "."); Destroy(this); yield return(null); } m_target_width = Screen.width >> m_target_downsample; m_target_height = Screen.height >> m_target_downsample; #if (UNITY_EDITOR) if (PlayerSettings.colorSpace != ColorSpace.Gamma) { Debug.LogWarning("Rove: Gamma color space is recommended."); } #endif m_target = new Texture2D(m_target_width, m_target_height, TextureFormat.ARGB32, false, true); m_target.filterMode = FilterMode.Bilinear; IntPtr native_tex = m_target.GetNativeTexturePtr(); m_target_material = (Material)Resources.Load("RoveTargetMaterial"); m_target_material.SetTexture("target", m_target); #if ((!ROVE_FORCE_GL) && (UNITY_EDITOR_WIN || UNITY_STANDALONE_WIN)) IntPtr d3d11_device = RoveInternal.RoveUnityGetD3D11Device(); if (d3d11_device == IntPtr.Zero) { Debug.LogError("Failed to get D3D11 device."); Destroy(this); yield return(null); } RoveInternal.SetD3D11Device(d3d11_device); #endif GL.IssuePluginEvent(RoveInternal.Setup(data_path, m_use_multi_device, m_use_integrated_device, m_optimization_level, native_tex), 0); yield return(new WaitForEndOfFrame()); if (RoveInternal.GetLock() == LOCKED) { Debug.LogError("Rove: Failed setup; check 'Rove/Data/rove.log' " + "for details."); Destroy(this); yield return(null); } else { // Additional resize fixes bug on some Linux drivers. m_target.Resize(m_target_width, m_target_height); m_target.Apply(); native_tex = m_target.GetNativeTexturePtr(); GL.IssuePluginEvent(RoveInternal.Resize(native_tex), 0); yield return(new WaitForEndOfFrame()); if (RoveInternal.GetLock() == LOCKED) { Debug.LogError("Rove: Failed to resize; check 'Rove/Data/rove.log' " + "for details."); Destroy(this); yield return(null); } Color[] black_pixels = new Color[m_target_width * m_target_height]; for (uint p = 0; p < m_target_width * m_target_height; ++p) { black_pixels[p] = Color.black; } m_target.SetPixels(black_pixels); m_target.Apply(); m_system_info.m_thread_count = RoveInternal.GetThreadCount(); m_system_info.m_compute_api = RoveInternal.GetComputeAPI(); m_system_info.m_device_count = RoveInternal.GetDeviceCount(); m_system_info.m_device_names = new string[m_system_info.m_device_count]; for (uint d = 0; d < m_system_info.m_device_count; ++d) { m_system_info.m_device_names[d] = Marshal.PtrToStringAnsi(RoveInternal.GetDeviceName(d)); } } m_rove_camera = GetAPIComponent <RoveCamera>(); if (!m_rove_camera) { Debug.LogError("Rove: Could not find an active RoveCamera component."); Destroy(this); yield return(null); } m_rove_environment = GetAPIComponent <RoveEnvironment>(); if (!m_rove_environment) { Debug.LogError("Rove: Could not find an active RoveEnvironment component."); Destroy(this); yield return(null); } SetMaxBounces(m_max_bounces); SetSamplesPerFrame(m_samples_per_frame); m_rove_camera.SetCameraApertureSize(m_rove_camera.m_aperture_size); m_rove_camera.SetCameraFocalDepth(m_rove_camera.m_focal_depth); m_rove_camera.SetImageProperties(m_rove_camera.m_tonemap, m_rove_camera.m_gamma, m_rove_camera.m_exposure, m_rove_camera.m_contrast, m_rove_camera.m_saturation, m_rove_camera.m_brightness); m_rove_environment.SetType(m_rove_environment.m_type); if (m_rove_environment.m_type == RoveEnvironment.TYPE_MAP) { m_rove_environment.SetEnvironmentMap(m_rove_environment.m_environment_map); m_rove_environment.SetMapProperties(m_rove_environment.m_map_intensity, m_rove_environment.m_map_rotation); } m_setup_success = true; }