UniversalRenderPipelineAssetEditor.cs 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  1. using UnityEngine;
  2. using UnityEngine.Rendering.Universal;
  3. using UnityEngine.Rendering;
  4. using UnityEngine.Scripting.APIUpdating;
  5. using UnityEditorInternal;
  6. namespace UnityEditor.Rendering.Universal
  7. {
  8. [CustomEditor(typeof(UniversalRenderPipelineAsset)), CanEditMultipleObjects]
  9. [MovedFrom("UnityEditor.Rendering.LWRP")] public class UniversalRenderPipelineAssetEditor : Editor
  10. {
  11. internal class Styles
  12. {
  13. // Groups
  14. public static GUIContent generalSettingsText = EditorGUIUtility.TrTextContent("General");
  15. public static GUIContent qualitySettingsText = EditorGUIUtility.TrTextContent("Quality");
  16. public static GUIContent lightingSettingsText = EditorGUIUtility.TrTextContent("Lighting");
  17. public static GUIContent shadowSettingsText = EditorGUIUtility.TrTextContent("Shadows");
  18. public static GUIContent postProcessingSettingsText = EditorGUIUtility.TrTextContent("Post-processing");
  19. public static GUIContent advancedSettingsText = EditorGUIUtility.TrTextContent("Advanced");
  20. public static GUIContent adaptivePerformanceText = EditorGUIUtility.TrTextContent("Adaptive Performance");
  21. // General
  22. public static GUIContent rendererHeaderText = EditorGUIUtility.TrTextContent("Renderer List", "Lists all the renderers available to this Render Pipeline Asset.");
  23. public static GUIContent rendererDefaultText = EditorGUIUtility.TrTextContent("Default", "This renderer is currently the default for the render pipeline.");
  24. public static GUIContent rendererSetDefaultText = EditorGUIUtility.TrTextContent("Set Default", "Makes this renderer the default for the render pipeline.");
  25. public static GUIContent rendererSettingsText = EditorGUIUtility.TrIconContent("_Menu", "Opens settings for this renderer.");
  26. public static GUIContent rendererMissingText = EditorGUIUtility.TrIconContent("console.warnicon.sml", "Renderer missing. Click this to select a new renderer.");
  27. public static GUIContent rendererDefaultMissingText = EditorGUIUtility.TrIconContent("console.erroricon.sml", "Default renderer missing. Click this to select a new renderer.");
  28. public static GUIContent requireDepthTextureText = EditorGUIUtility.TrTextContent("Depth Texture", "If enabled the pipeline will generate camera's depth that can be bound in shaders as _CameraDepthTexture.");
  29. public static GUIContent requireOpaqueTextureText = EditorGUIUtility.TrTextContent("Opaque Texture", "If enabled the pipeline will copy the screen to texture after opaque objects are drawn. For transparent objects this can be bound in shaders as _CameraOpaqueTexture.");
  30. public static GUIContent opaqueDownsamplingText = EditorGUIUtility.TrTextContent("Opaque Downsampling", "The downsampling method that is used for the opaque texture");
  31. public static GUIContent supportsTerrainHolesText = EditorGUIUtility.TrTextContent("Terrain Holes", "When disabled, Universal Rendering Pipeline removes all Terrain hole Shader variants when you build for the Unity Player. This decreases build time.");
  32. // Quality
  33. public static GUIContent hdrText = EditorGUIUtility.TrTextContent("HDR", "Controls the global HDR settings.");
  34. public static GUIContent msaaText = EditorGUIUtility.TrTextContent("Anti Aliasing (MSAA)", "Controls the global anti aliasing settings.");
  35. public static GUIContent renderScaleText = EditorGUIUtility.TrTextContent("Render Scale", "Scales the camera render target allowing the game to render at a resolution different than native resolution. UI is always rendered at native resolution.");
  36. // Main light
  37. public static GUIContent mainLightRenderingModeText = EditorGUIUtility.TrTextContent("Main Light", "Main light is the brightest directional light.");
  38. public static GUIContent supportsMainLightShadowsText = EditorGUIUtility.TrTextContent("Cast Shadows", "If enabled the main light can be a shadow casting light.");
  39. public static GUIContent mainLightShadowmapResolutionText = EditorGUIUtility.TrTextContent("Shadow Resolution", "Resolution of the main light shadowmap texture. If cascades are enabled, cascades will be packed into an atlas and this setting controls the maximum shadows atlas resolution.");
  40. // Additional lights
  41. public static GUIContent addditionalLightsRenderingModeText = EditorGUIUtility.TrTextContent("Additional Lights", "Additional lights support.");
  42. public static GUIContent perObjectLimit = EditorGUIUtility.TrTextContent("Per Object Limit", "Maximum amount of additional lights. These lights are sorted and culled per-object.");
  43. public static GUIContent supportsAdditionalShadowsText = EditorGUIUtility.TrTextContent("Cast Shadows", "If enabled shadows will be supported for spot lights.\n");
  44. public static GUIContent additionalLightsShadowmapResolution = EditorGUIUtility.TrTextContent("Shadow Resolution", "All additional lights are packed into a single shadowmap atlas. This setting controls the atlas size.");
  45. // Shadow settings
  46. public static GUIContent shadowDistanceText = EditorGUIUtility.TrTextContent("Max Distance", "Maximum shadow rendering distance.");
  47. public static GUIContent shadowCascadesText = EditorGUIUtility.TrTextContent("Cascade Count", "Number of cascade splits used for directional shadows.");
  48. public static GUIContent shadowDepthBias = EditorGUIUtility.TrTextContent("Depth Bias", "Controls the distance at which the shadows will be pushed away from the light. Useful for avoiding false self-shadowing artifacts.");
  49. public static GUIContent shadowNormalBias = EditorGUIUtility.TrTextContent("Normal Bias", "Controls distance at which the shadow casting surfaces will be shrunk along the surface normal. Useful for avoiding false self-shadowing artifacts.");
  50. public static GUIContent supportsSoftShadows = EditorGUIUtility.TrTextContent("Soft Shadows", "If enabled pipeline will perform shadow filtering. Otherwise all lights that cast shadows will fallback to perform a single shadow sample.");
  51. // Post-processing
  52. public static GUIContent colorGradingMode = EditorGUIUtility.TrTextContent("Grading Mode", "Defines how color grading will be applied. Operators will react differently depending on the mode.");
  53. public static GUIContent colorGradingLutSize = EditorGUIUtility.TrTextContent("LUT size", "Sets the size of the internal and external color grading lookup textures (LUTs).");
  54. public static string colorGradingModeWarning = "HDR rendering is required to use the high dynamic range color grading mode. The low dynamic range will be used instead.";
  55. public static string colorGradingModeSpecInfo = "The high dynamic range color grading mode works best on platforms that support floating point textures.";
  56. public static string colorGradingLutSizeWarning = "The minimal recommended LUT size for the high dynamic range color grading mode is 32. Using lower values will potentially result in color banding and posterization effects.";
  57. // Advanced settings
  58. public static GUIContent srpBatcher = EditorGUIUtility.TrTextContent("SRP Batcher", "If enabled, the render pipeline uses the SRP batcher.");
  59. public static GUIContent dynamicBatching = EditorGUIUtility.TrTextContent("Dynamic Batching", "If enabled, the render pipeline will batch drawcalls with few triangles together by copying their vertex buffers into a shared buffer on a per-frame basis.");
  60. public static GUIContent mixedLightingSupportLabel = EditorGUIUtility.TrTextContent("Mixed Lighting", "Makes the render pipeline include mixed-lighting Shader Variants in the build.");
  61. public static GUIContent debugLevel = EditorGUIUtility.TrTextContent("Debug Level", "Controls the level of debug information generated by the render pipeline. When Profiling is selected, the pipeline provides detailed profiling tags.");
  62. public static GUIContent shaderVariantLogLevel = EditorGUIUtility.TrTextContent("Shader Variant Log Level", "Controls the level logging in of shader variants information is outputted when a build is performed. Information will appear in the Unity console when the build finishes.");
  63. public static GUIContent volumeFrameworkUpdateMode = EditorGUIUtility.TrTextContent("Volume Update Mode", "Select how Unity updates Volumes: every frame or when triggered via scripting. In the Editor, Unity updates Volumes every frame when not in the Play mode.");
  64. public static GUIContent storeActionsOptimizationText = EditorGUIUtility.TrTextContent("Store Actions", "Sets the store actions policy on tile based GPUs. Affects render targets memory usage and will impact performance.");
  65. // Adaptive performance settings
  66. public static GUIContent useAdaptivePerformance = EditorGUIUtility.TrTextContent("Use adaptive performance", "Allows Adaptive Performance to adjust rendering quality during runtime");
  67. // Renderer List Messages
  68. public static GUIContent rendererListDefaultMessage =
  69. EditorGUIUtility.TrTextContent("Cannot remove Default Renderer",
  70. "Removal of the Default Renderer is not allowed. To remove, set another Renderer to be the new Default and then remove.");
  71. public static GUIContent rendererMissingDefaultMessage =
  72. EditorGUIUtility.TrTextContent("Missing Default Renderer\nThere is no default renderer assigned, so Unity can’t perform any rendering. Set another renderer to be the new Default, or assign a renderer to the Default slot.");
  73. public static GUIContent rendererMissingMessage =
  74. EditorGUIUtility.TrTextContent("Missing Renderer(s)\nOne or more renderers are either missing or unassigned. Switching to these renderers at runtime can cause issues.");
  75. public static GUIContent rendererUnsupportedAPIMessage =
  76. EditorGUIUtility.TrTextContent("Some Renderer(s) in the Renderer List are incompatible with the Player Graphics APIs list. Switching to these renderers at runtime can cause issues.\n\n");
  77. // Dropdown menu options
  78. public static string[] mainLightOptions = { "Disabled", "Per Pixel" };
  79. public static string[] volumeFrameworkUpdateOptions = { "Every Frame", "Via Scripting" };
  80. public static string[] opaqueDownsamplingOptions = {"None", "2x (Bilinear)", "4x (Box)", "4x (Bilinear)"};
  81. }
  82. SavedBool m_GeneralSettingsFoldout;
  83. SavedBool m_QualitySettingsFoldout;
  84. SavedBool m_LightingSettingsFoldout;
  85. SavedBool m_ShadowSettingsFoldout;
  86. SavedBool m_PostProcessingSettingsFoldout;
  87. SavedBool m_AdvancedSettingsFoldout;
  88. SavedBool m_AdaptivePerformanceFoldout;
  89. SerializedProperty m_RendererDataProp;
  90. SerializedProperty m_DefaultRendererProp;
  91. ReorderableList m_RendererDataList;
  92. SerializedProperty m_RequireDepthTextureProp;
  93. SerializedProperty m_RequireOpaqueTextureProp;
  94. SerializedProperty m_OpaqueDownsamplingProp;
  95. SerializedProperty m_SupportsTerrainHolesProp;
  96. SerializedProperty m_StoreActionsOptimizationProperty;
  97. SerializedProperty m_HDR;
  98. SerializedProperty m_MSAA;
  99. SerializedProperty m_RenderScale;
  100. SerializedProperty m_MainLightRenderingModeProp;
  101. SerializedProperty m_MainLightShadowsSupportedProp;
  102. SerializedProperty m_MainLightShadowmapResolutionProp;
  103. SerializedProperty m_AdditionalLightsRenderingModeProp;
  104. SerializedProperty m_AdditionalLightsPerObjectLimitProp;
  105. SerializedProperty m_AdditionalLightShadowsSupportedProp;
  106. SerializedProperty m_AdditionalLightShadowmapResolutionProp;
  107. SerializedProperty m_ShadowDistanceProp;
  108. SerializedProperty m_ShadowCascadeCountProp;
  109. SerializedProperty m_ShadowCascade2SplitProp;
  110. SerializedProperty m_ShadowCascade3SplitProp;
  111. SerializedProperty m_ShadowCascade4SplitProp;
  112. SerializedProperty m_ShadowDepthBiasProp;
  113. SerializedProperty m_ShadowNormalBiasProp;
  114. SerializedProperty m_SoftShadowsSupportedProp;
  115. SerializedProperty m_SRPBatcher;
  116. SerializedProperty m_SupportsDynamicBatching;
  117. SerializedProperty m_MixedLightingSupportedProp;
  118. SerializedProperty m_DebugLevelProp;
  119. SerializedProperty m_ShaderVariantLogLevel;
  120. SerializedProperty m_VolumeFrameworkUpdateModeProp;
  121. LightRenderingMode selectedLightRenderingMode;
  122. SerializedProperty m_ColorGradingMode;
  123. SerializedProperty m_ColorGradingLutSize;
  124. SerializedProperty m_UseAdaptivePerformance;
  125. EditorPrefBoolFlags<EditorUtils.Unit> m_State;
  126. public override void OnInspectorGUI()
  127. {
  128. serializedObject.Update();
  129. DrawGeneralSettings();
  130. DrawQualitySettings();
  131. DrawLightingSettings();
  132. DrawShadowSettings();
  133. DrawPostProcessingSettings();
  134. DrawAdvancedSettings();
  135. #if ADAPTIVE_PERFORMANCE_2_0_0_OR_NEWER
  136. DrawAdaptivePerformance();
  137. #endif
  138. serializedObject.ApplyModifiedProperties();
  139. }
  140. void OnEnable()
  141. {
  142. m_GeneralSettingsFoldout = new SavedBool($"{target.GetType()}.GeneralSettingsFoldout", false);
  143. m_QualitySettingsFoldout = new SavedBool($"{target.GetType()}.QualitySettingsFoldout", false);
  144. m_LightingSettingsFoldout = new SavedBool($"{target.GetType()}.LightingSettingsFoldout", false);
  145. m_ShadowSettingsFoldout = new SavedBool($"{target.GetType()}.ShadowSettingsFoldout", false);
  146. m_PostProcessingSettingsFoldout = new SavedBool($"{target.GetType()}.PostProcessingSettingsFoldout", false);
  147. m_AdvancedSettingsFoldout = new SavedBool($"{target.GetType()}.AdvancedSettingsFoldout", false);
  148. m_AdaptivePerformanceFoldout = new SavedBool($"{target.GetType()}.AdaptivePerformanceFoldout", false);
  149. m_RendererDataProp = serializedObject.FindProperty("m_RendererDataList");
  150. m_DefaultRendererProp = serializedObject.FindProperty("m_DefaultRendererIndex");
  151. m_RendererDataList = new ReorderableList(serializedObject, m_RendererDataProp, true, true, true, true);
  152. DrawRendererListLayout(m_RendererDataList, m_RendererDataProp);
  153. m_RequireDepthTextureProp = serializedObject.FindProperty("m_RequireDepthTexture");
  154. m_RequireOpaqueTextureProp = serializedObject.FindProperty("m_RequireOpaqueTexture");
  155. m_OpaqueDownsamplingProp = serializedObject.FindProperty("m_OpaqueDownsampling");
  156. m_SupportsTerrainHolesProp = serializedObject.FindProperty("m_SupportsTerrainHoles");
  157. m_HDR = serializedObject.FindProperty("m_SupportsHDR");
  158. m_MSAA = serializedObject.FindProperty("m_MSAA");
  159. m_RenderScale = serializedObject.FindProperty("m_RenderScale");
  160. m_MainLightRenderingModeProp = serializedObject.FindProperty("m_MainLightRenderingMode");
  161. m_MainLightShadowsSupportedProp = serializedObject.FindProperty("m_MainLightShadowsSupported");
  162. m_MainLightShadowmapResolutionProp = serializedObject.FindProperty("m_MainLightShadowmapResolution");
  163. m_AdditionalLightsRenderingModeProp = serializedObject.FindProperty("m_AdditionalLightsRenderingMode");
  164. m_AdditionalLightsPerObjectLimitProp = serializedObject.FindProperty("m_AdditionalLightsPerObjectLimit");
  165. m_AdditionalLightShadowsSupportedProp = serializedObject.FindProperty("m_AdditionalLightShadowsSupported");
  166. m_AdditionalLightShadowmapResolutionProp = serializedObject.FindProperty("m_AdditionalLightsShadowmapResolution");
  167. m_ShadowDistanceProp = serializedObject.FindProperty("m_ShadowDistance");
  168. m_ShadowCascadeCountProp = serializedObject.FindProperty("m_ShadowCascadeCount");
  169. m_ShadowCascade2SplitProp = serializedObject.FindProperty("m_Cascade2Split");
  170. m_ShadowCascade3SplitProp = serializedObject.FindProperty("m_Cascade3Split");
  171. m_ShadowCascade4SplitProp = serializedObject.FindProperty("m_Cascade4Split");
  172. m_ShadowDepthBiasProp = serializedObject.FindProperty("m_ShadowDepthBias");
  173. m_ShadowNormalBiasProp = serializedObject.FindProperty("m_ShadowNormalBias");
  174. m_SoftShadowsSupportedProp = serializedObject.FindProperty("m_SoftShadowsSupported");
  175. m_SRPBatcher = serializedObject.FindProperty("m_UseSRPBatcher");
  176. m_SupportsDynamicBatching = serializedObject.FindProperty("m_SupportsDynamicBatching");
  177. m_MixedLightingSupportedProp = serializedObject.FindProperty("m_MixedLightingSupported");
  178. m_DebugLevelProp = serializedObject.FindProperty("m_DebugLevel");
  179. m_ShaderVariantLogLevel = serializedObject.FindProperty("m_ShaderVariantLogLevel");
  180. m_VolumeFrameworkUpdateModeProp = serializedObject.FindProperty("m_VolumeFrameworkUpdateMode");
  181. m_StoreActionsOptimizationProperty = serializedObject.FindProperty("m_StoreActionsOptimization");
  182. m_ColorGradingMode = serializedObject.FindProperty("m_ColorGradingMode");
  183. m_ColorGradingLutSize = serializedObject.FindProperty("m_ColorGradingLutSize");
  184. m_UseAdaptivePerformance = serializedObject.FindProperty("m_UseAdaptivePerformance");
  185. selectedLightRenderingMode = (LightRenderingMode)m_AdditionalLightsRenderingModeProp.intValue;
  186. string Key = "Universal_Shadow_Setting_Unit:UI_State";
  187. m_State = new EditorPrefBoolFlags<EditorUtils.Unit>(Key);
  188. }
  189. void DrawGeneralSettings()
  190. {
  191. m_GeneralSettingsFoldout.value = EditorGUILayout.BeginFoldoutHeaderGroup(m_GeneralSettingsFoldout.value, Styles.generalSettingsText);
  192. if (m_GeneralSettingsFoldout.value)
  193. {
  194. EditorGUI.indentLevel++;
  195. EditorGUILayout.Space();
  196. EditorGUI.indentLevel--;
  197. m_RendererDataList.DoLayoutList();
  198. EditorGUI.indentLevel++;
  199. UniversalRenderPipelineAsset asset = target as UniversalRenderPipelineAsset;
  200. string unsupportedGraphicsApisMessage;
  201. if (!asset.ValidateRendererData(-1))
  202. EditorGUILayout.HelpBox(Styles.rendererMissingDefaultMessage.text, MessageType.Error, true);
  203. else if (!asset.ValidateRendererDataList(true))
  204. EditorGUILayout.HelpBox(Styles.rendererMissingMessage.text, MessageType.Warning, true);
  205. else if (!ValidateRendererGraphicsAPIs(asset, out unsupportedGraphicsApisMessage))
  206. EditorGUILayout.HelpBox(Styles.rendererUnsupportedAPIMessage.text + unsupportedGraphicsApisMessage, MessageType.Warning, true);
  207. EditorGUILayout.PropertyField(m_RequireDepthTextureProp, Styles.requireDepthTextureText);
  208. EditorGUILayout.PropertyField(m_RequireOpaqueTextureProp, Styles.requireOpaqueTextureText);
  209. EditorGUI.indentLevel++;
  210. EditorGUI.BeginDisabledGroup(!m_RequireOpaqueTextureProp.boolValue);
  211. EditorGUILayout.PropertyField(m_OpaqueDownsamplingProp, Styles.opaqueDownsamplingText);
  212. EditorGUI.EndDisabledGroup();
  213. EditorGUI.indentLevel--;
  214. EditorGUILayout.PropertyField(m_SupportsTerrainHolesProp, Styles.supportsTerrainHolesText);
  215. EditorGUI.indentLevel--;
  216. EditorGUILayout.Space();
  217. EditorGUILayout.Space();
  218. }
  219. EditorGUILayout.EndFoldoutHeaderGroup();
  220. }
  221. void DrawQualitySettings()
  222. {
  223. m_QualitySettingsFoldout.value = EditorGUILayout.BeginFoldoutHeaderGroup(m_QualitySettingsFoldout.value, Styles.qualitySettingsText);
  224. if (m_QualitySettingsFoldout.value)
  225. {
  226. EditorGUI.indentLevel++;
  227. EditorGUILayout.PropertyField(m_HDR, Styles.hdrText);
  228. EditorGUILayout.PropertyField(m_MSAA, Styles.msaaText);
  229. m_RenderScale.floatValue = EditorGUILayout.Slider(Styles.renderScaleText, m_RenderScale.floatValue, UniversalRenderPipeline.minRenderScale, UniversalRenderPipeline.maxRenderScale);
  230. EditorGUI.indentLevel--;
  231. EditorGUILayout.Space();
  232. EditorGUILayout.Space();
  233. }
  234. EditorGUILayout.EndFoldoutHeaderGroup();
  235. }
  236. void DrawLightingSettings()
  237. {
  238. m_LightingSettingsFoldout.value = EditorGUILayout.BeginFoldoutHeaderGroup(m_LightingSettingsFoldout.value, Styles.lightingSettingsText);
  239. if (m_LightingSettingsFoldout.value)
  240. {
  241. EditorGUI.indentLevel++;
  242. // Main Light
  243. bool disableGroup = false;
  244. EditorGUI.BeginDisabledGroup(disableGroup);
  245. CoreEditorUtils.DrawPopup(Styles.mainLightRenderingModeText, m_MainLightRenderingModeProp, Styles.mainLightOptions);
  246. EditorGUI.EndDisabledGroup();
  247. EditorGUI.indentLevel++;
  248. disableGroup |= !m_MainLightRenderingModeProp.boolValue;
  249. EditorGUI.BeginDisabledGroup(disableGroup);
  250. EditorGUILayout.PropertyField(m_MainLightShadowsSupportedProp, Styles.supportsMainLightShadowsText);
  251. EditorGUI.EndDisabledGroup();
  252. disableGroup |= !m_MainLightShadowsSupportedProp.boolValue;
  253. EditorGUI.BeginDisabledGroup(disableGroup);
  254. EditorGUILayout.PropertyField(m_MainLightShadowmapResolutionProp, Styles.mainLightShadowmapResolutionText);
  255. EditorGUI.EndDisabledGroup();
  256. EditorGUI.indentLevel--;
  257. EditorGUILayout.Space();
  258. // Additional light
  259. selectedLightRenderingMode = (LightRenderingMode)EditorGUILayout.EnumPopup(Styles.addditionalLightsRenderingModeText, selectedLightRenderingMode);
  260. m_AdditionalLightsRenderingModeProp.intValue = (int)selectedLightRenderingMode;
  261. EditorGUI.indentLevel++;
  262. disableGroup = m_AdditionalLightsRenderingModeProp.intValue == (int)LightRenderingMode.Disabled;
  263. EditorGUI.BeginDisabledGroup(disableGroup);
  264. m_AdditionalLightsPerObjectLimitProp.intValue = EditorGUILayout.IntSlider(Styles.perObjectLimit, m_AdditionalLightsPerObjectLimitProp.intValue, 0, UniversalRenderPipeline.maxPerObjectLights);
  265. EditorGUI.EndDisabledGroup();
  266. disableGroup |= (m_AdditionalLightsPerObjectLimitProp.intValue == 0 || m_AdditionalLightsRenderingModeProp.intValue != (int)LightRenderingMode.PerPixel);
  267. EditorGUI.BeginDisabledGroup(disableGroup);
  268. EditorGUILayout.PropertyField(m_AdditionalLightShadowsSupportedProp, Styles.supportsAdditionalShadowsText);
  269. EditorGUI.EndDisabledGroup();
  270. disableGroup |= !m_AdditionalLightShadowsSupportedProp.boolValue;
  271. EditorGUI.BeginDisabledGroup(disableGroup);
  272. EditorGUILayout.PropertyField(m_AdditionalLightShadowmapResolutionProp, Styles.additionalLightsShadowmapResolution);
  273. EditorGUI.EndDisabledGroup();
  274. EditorGUI.indentLevel--;
  275. EditorGUI.indentLevel--;
  276. EditorGUILayout.Space();
  277. EditorGUILayout.Space();
  278. }
  279. EditorGUILayout.EndFoldoutHeaderGroup();
  280. }
  281. void DrawShadowSettings()
  282. {
  283. m_ShadowSettingsFoldout.value = EditorGUILayout.BeginFoldoutHeaderGroup(m_ShadowSettingsFoldout.value, Styles.shadowSettingsText);
  284. if (m_ShadowSettingsFoldout.value)
  285. {
  286. EditorGUI.indentLevel++;
  287. m_ShadowDistanceProp.floatValue = Mathf.Max(0.0f, EditorGUILayout.FloatField(Styles.shadowDistanceText, m_ShadowDistanceProp.floatValue));
  288. EditorUtils.Unit unit = EditorUtils.Unit.Metric;
  289. if (m_ShadowCascadeCountProp.intValue != 0)
  290. {
  291. EditorGUI.BeginChangeCheck();
  292. unit = (EditorUtils.Unit)EditorGUILayout.EnumPopup(EditorGUIUtility.TrTextContent("Working Unit", "Except Max Distance which will be still in meter."), m_State.value);
  293. if (EditorGUI.EndChangeCheck())
  294. {
  295. m_State.value = unit;
  296. }
  297. }
  298. UniversalRenderPipelineAsset asset = target as UniversalRenderPipelineAsset;
  299. EditorGUILayout.IntSlider(m_ShadowCascadeCountProp, UniversalRenderPipelineAsset.k_ShadowCascadeMinCount, UniversalRenderPipelineAsset.k_ShadowCascadeMaxCount, Styles.shadowCascadesText);
  300. int cascadeCount = m_ShadowCascadeCountProp.intValue;
  301. EditorGUI.indentLevel++;
  302. if (cascadeCount == 4)
  303. EditorUtils.DrawCascadeSplitGUI<Vector3>(ref m_ShadowCascade4SplitProp, m_ShadowDistanceProp.floatValue, cascadeCount, unit);
  304. else if (cascadeCount == 3)
  305. EditorUtils.DrawCascadeSplitGUI<Vector2>(ref m_ShadowCascade3SplitProp, m_ShadowDistanceProp.floatValue, cascadeCount, unit);
  306. else if (cascadeCount == 2)
  307. EditorUtils.DrawCascadeSplitGUI<float>(ref m_ShadowCascade2SplitProp, m_ShadowDistanceProp.floatValue, cascadeCount, unit);
  308. else if (cascadeCount == 1)
  309. EditorUtils.DrawCascadeSplitGUI<float>(ref m_ShadowCascade2SplitProp, m_ShadowDistanceProp.floatValue, cascadeCount, unit);
  310. m_ShadowDepthBiasProp.floatValue = EditorGUILayout.Slider(Styles.shadowDepthBias, m_ShadowDepthBiasProp.floatValue, 0.0f, UniversalRenderPipeline.maxShadowBias);
  311. m_ShadowNormalBiasProp.floatValue = EditorGUILayout.Slider(Styles.shadowNormalBias, m_ShadowNormalBiasProp.floatValue, 0.0f, UniversalRenderPipeline.maxShadowBias);
  312. EditorGUILayout.PropertyField(m_SoftShadowsSupportedProp, Styles.supportsSoftShadows);
  313. EditorGUI.indentLevel--;
  314. EditorGUILayout.Space();
  315. EditorGUILayout.Space();
  316. }
  317. EditorGUILayout.EndFoldoutHeaderGroup();
  318. }
  319. void DrawPostProcessingSettings()
  320. {
  321. m_PostProcessingSettingsFoldout.value = EditorGUILayout.BeginFoldoutHeaderGroup(m_PostProcessingSettingsFoldout.value, Styles.postProcessingSettingsText);
  322. if (m_PostProcessingSettingsFoldout.value)
  323. {
  324. bool isHdrOn = m_HDR.boolValue;
  325. EditorGUI.indentLevel++;
  326. EditorGUILayout.PropertyField(m_ColorGradingMode, Styles.colorGradingMode);
  327. if (!isHdrOn && m_ColorGradingMode.intValue == (int)ColorGradingMode.HighDynamicRange)
  328. EditorGUILayout.HelpBox(Styles.colorGradingModeWarning, MessageType.Warning);
  329. else if (isHdrOn && m_ColorGradingMode.intValue == (int)ColorGradingMode.HighDynamicRange)
  330. EditorGUILayout.HelpBox(Styles.colorGradingModeSpecInfo, MessageType.Info);
  331. EditorGUILayout.DelayedIntField(m_ColorGradingLutSize, Styles.colorGradingLutSize);
  332. m_ColorGradingLutSize.intValue = Mathf.Clamp(m_ColorGradingLutSize.intValue, UniversalRenderPipelineAsset.k_MinLutSize, UniversalRenderPipelineAsset.k_MaxLutSize);
  333. if (isHdrOn && m_ColorGradingMode.intValue == (int)ColorGradingMode.HighDynamicRange && m_ColorGradingLutSize.intValue < 32)
  334. EditorGUILayout.HelpBox(Styles.colorGradingLutSizeWarning, MessageType.Warning);
  335. EditorGUI.indentLevel--;
  336. EditorGUILayout.Space();
  337. EditorGUILayout.Space();
  338. }
  339. EditorGUILayout.EndFoldoutHeaderGroup();
  340. }
  341. void DrawAdvancedSettings()
  342. {
  343. m_AdvancedSettingsFoldout.value = EditorGUILayout.BeginFoldoutHeaderGroup(m_AdvancedSettingsFoldout.value, Styles.advancedSettingsText);
  344. if (m_AdvancedSettingsFoldout.value)
  345. {
  346. EditorGUI.indentLevel++;
  347. EditorGUILayout.PropertyField(m_SRPBatcher, Styles.srpBatcher);
  348. EditorGUILayout.PropertyField(m_SupportsDynamicBatching, Styles.dynamicBatching);
  349. EditorGUILayout.PropertyField(m_MixedLightingSupportedProp, Styles.mixedLightingSupportLabel);
  350. EditorGUILayout.PropertyField(m_DebugLevelProp, Styles.debugLevel);
  351. EditorGUILayout.PropertyField(m_ShaderVariantLogLevel, Styles.shaderVariantLogLevel);
  352. EditorGUILayout.PropertyField(m_StoreActionsOptimizationProperty, Styles.storeActionsOptimizationText);
  353. CoreEditorUtils.DrawPopup(Styles.volumeFrameworkUpdateMode, m_VolumeFrameworkUpdateModeProp, Styles.volumeFrameworkUpdateOptions);
  354. EditorGUI.indentLevel--;
  355. EditorGUILayout.Space();
  356. EditorGUILayout.Space();
  357. }
  358. EditorGUILayout.EndFoldoutHeaderGroup();
  359. }
  360. void DrawAdaptivePerformance()
  361. {
  362. m_AdaptivePerformanceFoldout.value = EditorGUILayout.BeginFoldoutHeaderGroup(m_AdaptivePerformanceFoldout.value, Styles.adaptivePerformanceText);
  363. if (m_AdaptivePerformanceFoldout.value)
  364. {
  365. EditorGUI.indentLevel++;
  366. EditorGUILayout.PropertyField(m_UseAdaptivePerformance, Styles.useAdaptivePerformance);
  367. EditorGUI.indentLevel--;
  368. EditorGUILayout.Space();
  369. EditorGUILayout.Space();
  370. }
  371. EditorGUILayout.EndFoldoutHeaderGroup();
  372. }
  373. void DrawRendererListLayout(ReorderableList list, SerializedProperty prop)
  374. {
  375. list.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) =>
  376. {
  377. rect.y += 2;
  378. Rect indexRect = new Rect(rect.x, rect.y, 14, EditorGUIUtility.singleLineHeight);
  379. EditorGUI.LabelField(indexRect, index.ToString());
  380. Rect objRect = new Rect(rect.x + indexRect.width, rect.y, rect.width - 134, EditorGUIUtility.singleLineHeight);
  381. EditorGUI.BeginChangeCheck();
  382. EditorGUI.ObjectField(objRect, prop.GetArrayElementAtIndex(index), GUIContent.none);
  383. if (EditorGUI.EndChangeCheck())
  384. EditorUtility.SetDirty(target);
  385. Rect defaultButton = new Rect(rect.width - 75, rect.y, 86, EditorGUIUtility.singleLineHeight);
  386. var defaultRenderer = m_DefaultRendererProp.intValue;
  387. GUI.enabled = index != defaultRenderer;
  388. if (GUI.Button(defaultButton, !GUI.enabled ? Styles.rendererDefaultText : Styles.rendererSetDefaultText))
  389. {
  390. m_DefaultRendererProp.intValue = index;
  391. EditorUtility.SetDirty(target);
  392. }
  393. GUI.enabled = true;
  394. Rect selectRect = new Rect(rect.x + rect.width - 24, rect.y, 24, EditorGUIUtility.singleLineHeight);
  395. UniversalRenderPipelineAsset asset = target as UniversalRenderPipelineAsset;
  396. if (asset.ValidateRendererData(index))
  397. {
  398. if (GUI.Button(selectRect, Styles.rendererSettingsText))
  399. {
  400. Selection.SetActiveObjectWithContext(prop.GetArrayElementAtIndex(index).objectReferenceValue,
  401. null);
  402. }
  403. }
  404. else // Missing ScriptableRendererData
  405. {
  406. if (GUI.Button(selectRect, index == defaultRenderer ? Styles.rendererDefaultMissingText : Styles.rendererMissingText))
  407. {
  408. EditorGUIUtility.ShowObjectPicker<ScriptableRendererData>(null, false, null, index);
  409. }
  410. }
  411. // If object selector chose an object, assign it to the correct ScriptableRendererData slot.
  412. if (Event.current.commandName == "ObjectSelectorUpdated" && EditorGUIUtility.GetObjectPickerControlID() == index)
  413. {
  414. prop.GetArrayElementAtIndex(index).objectReferenceValue = EditorGUIUtility.GetObjectPickerObject();
  415. }
  416. };
  417. list.drawHeaderCallback = (Rect rect) =>
  418. {
  419. EditorGUI.LabelField(rect, Styles.rendererHeaderText);
  420. };
  421. list.onCanRemoveCallback = li => { return li.count > 1; };
  422. list.onRemoveCallback = li =>
  423. {
  424. bool shouldUpdateIndex = false;
  425. // Checking so that the user is not deleting the default renderer
  426. if (li.index != m_DefaultRendererProp.intValue)
  427. {
  428. // Need to add the undo to the removal of our assets here, for it to work properly.
  429. Undo.RecordObject(target, $"Deleting renderer at index {li.index}");
  430. if (prop.GetArrayElementAtIndex(li.index).objectReferenceValue == null)
  431. {
  432. shouldUpdateIndex = true;
  433. }
  434. prop.DeleteArrayElementAtIndex(li.index);
  435. }
  436. else
  437. {
  438. EditorUtility.DisplayDialog(Styles.rendererListDefaultMessage.text, Styles.rendererListDefaultMessage.tooltip,
  439. "Close");
  440. }
  441. if (shouldUpdateIndex)
  442. {
  443. UpdateDefaultRendererValue(li.index);
  444. }
  445. EditorUtility.SetDirty(target);
  446. };
  447. list.onReorderCallbackWithDetails += (reorderableList, index, newIndex) =>
  448. {
  449. // Need to update the default renderer index
  450. UpdateDefaultRendererValue(index, newIndex);
  451. };
  452. }
  453. void UpdateDefaultRendererValue(int index)
  454. {
  455. // If the index that is being removed is lower than the default renderer value,
  456. // the default prop value needs to be one lower.
  457. if (index < m_DefaultRendererProp.intValue)
  458. {
  459. m_DefaultRendererProp.intValue--;
  460. }
  461. }
  462. void UpdateDefaultRendererValue(int prevIndex, int newIndex)
  463. {
  464. // If we are moving the index that is the same as the default renderer we need to update that
  465. if (prevIndex == m_DefaultRendererProp.intValue)
  466. {
  467. m_DefaultRendererProp.intValue = newIndex;
  468. }
  469. // If newIndex is the same as default
  470. // then we need to know if newIndex is above or below the default index
  471. else if (newIndex == m_DefaultRendererProp.intValue)
  472. {
  473. m_DefaultRendererProp.intValue += prevIndex > newIndex ? 1 : -1;
  474. }
  475. // If the old index is lower than default renderer and
  476. // the new index is higher then we need to move the default renderer index one lower
  477. else if (prevIndex < m_DefaultRendererProp.intValue && newIndex > m_DefaultRendererProp.intValue)
  478. {
  479. m_DefaultRendererProp.intValue--;
  480. }
  481. else if (newIndex < m_DefaultRendererProp.intValue && prevIndex > m_DefaultRendererProp.intValue)
  482. {
  483. m_DefaultRendererProp.intValue++;
  484. }
  485. }
  486. bool ValidateRendererGraphicsAPIs(UniversalRenderPipelineAsset pipelineAsset, out string unsupportedGraphicsApisMessage)
  487. {
  488. // Check the list of Renderers against all Graphics APIs the player is built with.
  489. unsupportedGraphicsApisMessage = null;
  490. BuildTarget platform = EditorUserBuildSettings.activeBuildTarget;
  491. GraphicsDeviceType[] graphicsAPIs = PlayerSettings.GetGraphicsAPIs(platform);
  492. int rendererCount = pipelineAsset.m_RendererDataList.Length;
  493. for (int i = 0; i < rendererCount; i++)
  494. {
  495. ScriptableRenderer renderer = pipelineAsset.GetRenderer(i);
  496. if (renderer == null)
  497. continue;
  498. GraphicsDeviceType[] unsupportedAPIs = renderer.unsupportedGraphicsDeviceTypes;
  499. for (int apiIndex = 0; apiIndex < unsupportedAPIs.Length; apiIndex++)
  500. {
  501. if (System.Array.FindIndex(graphicsAPIs, element => element == unsupportedAPIs[apiIndex]) >= 0)
  502. unsupportedGraphicsApisMessage += System.String.Format("{0} at index {1} does not support {2}.\n", renderer, i, unsupportedAPIs[apiIndex]);
  503. }
  504. }
  505. return unsupportedGraphicsApisMessage == null;
  506. }
  507. }
  508. }