CaptureFromCamera360Editor.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. #if UNITY_EDITOR
  2. #if UNITY_2018_1_OR_NEWER
  3. // Unity 2018.1 introduces stereo cubemap render methods
  4. #define AVPRO_MOVIECAPTURE_UNITY_STEREOCUBEMAP_RENDER
  5. #endif
  6. using UnityEngine;
  7. using UnityEditor;
  8. //-----------------------------------------------------------------------------
  9. // Copyright 2012-2022 RenderHeads Ltd. All rights reserved.
  10. //-----------------------------------------------------------------------------
  11. namespace RenderHeads.Media.AVProMovieCapture.Editor
  12. {
  13. [CanEditMultipleObjects]
  14. [CustomEditor(typeof(CaptureFromCamera360))]
  15. public class CaptureFromCamera360Editor : CaptureBaseEditor
  16. {
  17. //private CaptureFromCamera360 _capture;
  18. private SerializedProperty _propCameraSelector;
  19. private SerializedProperty _propCamera;
  20. private SerializedProperty _propRenderResolution;
  21. private SerializedProperty _propRenderSize;
  22. private SerializedProperty _propAntiAliasing;
  23. private SerializedProperty _propCubemapResolution;
  24. private SerializedProperty _propCubemapDepth;
  25. private SerializedProperty _propSupportGUI;
  26. private SerializedProperty _propSupporCameraRotation;
  27. private SerializedProperty _propOnlyLeftRightRotation;
  28. private SerializedProperty _propStereoRendering;
  29. private SerializedProperty _propRender180Degrees;
  30. private SerializedProperty _propIPD;
  31. private SerializedProperty _propBlendOverlapPercent;
  32. protected override void OnEnable()
  33. {
  34. base.OnEnable();
  35. //_capture = (this.target) as CaptureFromCamera360;
  36. _propCameraSelector = serializedObject.AssertFindProperty("_cameraSelector");
  37. _propCamera = serializedObject.AssertFindProperty("_camera");
  38. _propRenderResolution = serializedObject.AssertFindProperty("_renderResolution");
  39. _propRenderSize = serializedObject.AssertFindProperty("_renderSize");
  40. _propAntiAliasing = serializedObject.AssertFindProperty("_renderAntiAliasing");
  41. _propCubemapResolution = serializedObject.AssertFindProperty("_cubemapResolution");
  42. _propCubemapDepth = serializedObject.AssertFindProperty("_cubemapDepth");
  43. _propSupportGUI = serializedObject.AssertFindProperty("_supportGUI");
  44. _propSupporCameraRotation = serializedObject.AssertFindProperty("_supportCameraRotation");
  45. _propOnlyLeftRightRotation = serializedObject.AssertFindProperty("_onlyLeftRightRotation");
  46. _propRender180Degrees = serializedObject.AssertFindProperty("_render180Degrees");
  47. _propStereoRendering = serializedObject.AssertFindProperty("_stereoRendering");
  48. _propIPD = serializedObject.AssertFindProperty("_ipd");
  49. _propBlendOverlapPercent = serializedObject.AssertFindProperty("_blendOverlapPercent");
  50. }
  51. protected void GUI_Camera()
  52. {
  53. EditorGUILayout.PropertyField(_propCameraSelector);
  54. if (null == _propCameraSelector.objectReferenceValue)
  55. {
  56. EditorGUILayout.PropertyField(_propCamera);
  57. }
  58. EditorUtils.EnumAsDropdown("Resolution", _propRenderResolution, CaptureBaseEditor.ResolutionStrings);
  59. if (_propRenderResolution.enumValueIndex == (int)CaptureBase.Resolution.Custom)
  60. {
  61. EditorGUILayout.PropertyField(_propRenderSize, new GUIContent("Size"));
  62. _propRenderSize.vector2Value = new Vector2(Mathf.Clamp((int)_propRenderSize.vector2Value.x, 1, NativePlugin.MaxRenderWidth), Mathf.Clamp((int)_propRenderSize.vector2Value.y, 1, NativePlugin.MaxRenderHeight));
  63. }
  64. {
  65. string currentAA = "None";
  66. if (QualitySettings.antiAliasing > 1)
  67. {
  68. currentAA = QualitySettings.antiAliasing.ToString() + "x";
  69. }
  70. EditorUtils.IntAsDropdown("Anti-aliasing", _propAntiAliasing, new string[] { "Current (" + currentAA + ")", "None", "2x", "4x", "8x" }, new int[] { -1, 1, 2, 4, 8 });
  71. }
  72. EditorUtils.IntAsDropdown("Cubemap Resolution", _propCubemapResolution, new string[] { "256", "512", "1024", "2048", "4096", "8192" }, new int[] { 256, 512, 1024, 2048, 4096, 8192 });
  73. EditorUtils.IntAsDropdown("Cubemap Depth", _propCubemapDepth, new string[] { "0", "16", "24" }, new int[] { 0, 16, 24 });
  74. EditorGUILayout.PropertyField(_propSupportGUI, new GUIContent("Capture GUI"));
  75. EditorGUILayout.PropertyField(_propSupporCameraRotation, new GUIContent("Camera Rotation"));
  76. if (_propSupporCameraRotation.boolValue)
  77. {
  78. EditorGUILayout.PropertyField(_propOnlyLeftRightRotation);
  79. }
  80. EditorGUILayout.PropertyField(_propRender180Degrees);
  81. EditorGUILayout.PropertyField(_propStereoRendering);
  82. if (_propStereoRendering.enumValueIndex != (int)StereoPacking.None)
  83. {
  84. #if AVPRO_MOVIECAPTURE_UNITY_STEREOCUBEMAP_RENDER
  85. if (!PlayerSettings.enable360StereoCapture)
  86. {
  87. ShowNoticeBox(MessageType.Warning, "360 Stereo Capture needs to be enabled in PlayerSettings");
  88. if (GUILayout.Button("Enable 360 Stereo Capture"))
  89. {
  90. PlayerSettings.enable360StereoCapture = true;
  91. }
  92. }
  93. #endif
  94. // TODO: detect HDRP and warn that stereo capture is not supported
  95. EditorGUILayout.PropertyField(_propIPD, new GUIContent("Interpupillary distance"));
  96. }
  97. // RJT TODO: Supports stereo via 'CubemapRenderMethod.Manual' but I gather its results are not correct so either:
  98. // - 1. Fix up 'Manual' stereo if possible
  99. // - 2. Disable/warn here if stereo is selected
  100. // if (_propStereoRendering.enumValueIndex == (int)StereoPacking.None)
  101. {
  102. // RJT TODO: Could technically allow more than 100% as camera perspective visually means 100% != a complete face, but
  103. // definitely approaches a point of massively diminishing (but increasingly costly) returns so probably not worthwhile
  104. EditorGUILayout.Slider(_propBlendOverlapPercent, 0.0f, 100.0f, new GUIContent("Blend Overlap %"));
  105. }
  106. }
  107. protected override void GUI_User()
  108. {
  109. if (_baseCapture != null && !_baseCapture.IsCapturing())
  110. {
  111. serializedObject.Update();
  112. bool boolTrue = true;
  113. EditorUtils.DrawSection("Capture From Camera 360+Stereo", ref boolTrue, GUI_Camera);
  114. if (serializedObject.ApplyModifiedProperties())
  115. {
  116. EditorUtility.SetDirty(target);
  117. }
  118. }
  119. }
  120. }
  121. }
  122. #endif