UniversalRenderPipelineAssetEditor.cs 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  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))]
  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. // General
  21. public static GUIContent rendererHeaderText = EditorGUIUtility.TrTextContent("Renderer List", "Lists all the renderers available to this Render Pipeline Asset.");
  22. public static GUIContent rendererDefaultText = EditorGUIUtility.TrTextContent("Default", "This renderer is currently the default for the render pipeline.");
  23. public static GUIContent rendererSetDefaultText = EditorGUIUtility.TrTextContent("Set Default", "Makes this renderer the default for the render pipeline.");
  24. public static GUIContent rendererSettingsText = EditorGUIUtility.TrIconContent("_Menu", "Opens settings for this renderer.");
  25. public static GUIContent rendererMissingText = EditorGUIUtility.TrIconContent("console.warnicon.sml", "Renderer missing. Click this to select a new renderer.");
  26. public static GUIContent rendererDefaultMissingText = EditorGUIUtility.TrIconContent("console.erroricon.sml", "Default renderer missing. Click this to select a new renderer.");
  27. 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.");
  28. 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.");
  29. public static GUIContent opaqueDownsamplingText = EditorGUIUtility.TrTextContent("Opaque Downsampling", "The downsampling method that is used for the opaque texture");
  30. 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.");
  31. // Quality
  32. public static GUIContent hdrText = EditorGUIUtility.TrTextContent("HDR", "Controls the global HDR settings.");
  33. public static GUIContent msaaText = EditorGUIUtility.TrTextContent("Anti Aliasing (MSAA)", "Controls the global anti aliasing settings.");
  34. 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. When VR is enabled, this is overridden by XRSettings.");
  35. // Main light
  36. public static GUIContent mainLightRenderingModeText = EditorGUIUtility.TrTextContent("Main Light", "Main light is the brightest directional light.");
  37. public static GUIContent supportsMainLightShadowsText = EditorGUIUtility.TrTextContent("Cast Shadows", "If enabled the main light can be a shadow casting light.");
  38. 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.");
  39. // Additional lights
  40. public static GUIContent addditionalLightsRenderingModeText = EditorGUIUtility.TrTextContent("Additional Lights", "Additional lights support.");
  41. public static GUIContent perObjectLimit = EditorGUIUtility.TrTextContent("Per Object Limit", "Maximum amount of additional lights. These lights are sorted and culled per-object.");
  42. public static GUIContent supportsAdditionalShadowsText = EditorGUIUtility.TrTextContent("Cast Shadows", "If enabled shadows will be supported for spot lights.\n");
  43. public static GUIContent additionalLightsShadowmapResolution = EditorGUIUtility.TrTextContent("Shadow Resolution", "All additional lights are packed into a single shadowmap atlas. This setting controls the atlas size.");
  44. // Shadow settings
  45. public static GUIContent shadowDistanceText = EditorGUIUtility.TrTextContent("Distance", "Maximum shadow rendering distance.");
  46. public static GUIContent shadowCascadesText = EditorGUIUtility.TrTextContent("Cascades", "Number of cascade splits used in for directional shadows");
  47. 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.");
  48. 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.");
  49. 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.");
  50. // Post-processing
  51. public static GUIContent postProcessingFeatureSet = EditorGUIUtility.TrTextContent("Feature Set", "Sets the post-processing solution to use. To future proof your application, use Integrated instead of the comparability mode. Only use compatibility mode if your project still uses the Post-processing V2 package, but be aware that Unity plans to deprecate Post-processing V2 support for the Universal Render Pipeline in the near future.");
  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 postProcessingFeatureSetWarning = "Unity plans to deprecate Post-processing V2 support for the Universal Render Pipeline in the near future. You should only use this mode for compatibility purposes.";
  55. 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.";
  56. public static string colorGradingModeSpecInfo = "The high dynamic range color grading mode works best on platforms that support floating point textures.";
  57. 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.";
  58. public static string postProcessingGlobalWarning = "The Post-processing Feature Set in the URP Asset is set to Post-processing V2. This Volume component will not have any effect.";
  59. // Advanced settings
  60. public static GUIContent srpBatcher = EditorGUIUtility.TrTextContent("SRP Batcher", "If enabled, the render pipeline uses the SRP batcher.");
  61. 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.");
  62. public static GUIContent mixedLightingSupportLabel = EditorGUIUtility.TrTextContent("Mixed Lighting", "Makes the render pipeline include mixed-lighting Shader Variants in the build.");
  63. 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.");
  64. 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.");
  65. // Renderer List Messages
  66. public static GUIContent rendererListDefaultMessage =
  67. EditorGUIUtility.TrTextContent("Cannot remove Default Renderer",
  68. "Removal of the Default Renderer is not allowed. To remove, set another Renderer to be the new Default and then remove.");
  69. public static GUIContent rendererMissingDefaultMessage =
  70. 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.");
  71. public static GUIContent rendererMissingMessage =
  72. EditorGUIUtility.TrTextContent("Missing Renderer(s)\nOne or more renderers are either missing or unassigned. Switching to these renderers at runtime can cause issues.");
  73. // Dropdown menu options
  74. public static string[] mainLightOptions = { "Disabled", "Per Pixel" };
  75. public static string[] shadowCascadeOptions = {"No Cascades", "Two Cascades", "Four Cascades"};
  76. public static string[] opaqueDownsamplingOptions = {"None", "2x (Bilinear)", "4x (Box)", "4x (Bilinear)"};
  77. }
  78. SavedBool m_GeneralSettingsFoldout;
  79. SavedBool m_QualitySettingsFoldout;
  80. SavedBool m_LightingSettingsFoldout;
  81. SavedBool m_ShadowSettingsFoldout;
  82. SavedBool m_PostProcessingSettingsFoldout;
  83. SavedBool m_AdvancedSettingsFoldout;
  84. SerializedProperty m_RendererDataProp;
  85. SerializedProperty m_DefaultRendererProp;
  86. ReorderableList m_RendererDataList;
  87. SerializedProperty m_RequireDepthTextureProp;
  88. SerializedProperty m_RequireOpaqueTextureProp;
  89. SerializedProperty m_OpaqueDownsamplingProp;
  90. SerializedProperty m_SupportsTerrainHolesProp;
  91. SerializedProperty m_HDR;
  92. SerializedProperty m_MSAA;
  93. SerializedProperty m_RenderScale;
  94. SerializedProperty m_MainLightRenderingModeProp;
  95. SerializedProperty m_MainLightShadowsSupportedProp;
  96. SerializedProperty m_MainLightShadowmapResolutionProp;
  97. SerializedProperty m_AdditionalLightsRenderingModeProp;
  98. SerializedProperty m_AdditionalLightsPerObjectLimitProp;
  99. SerializedProperty m_AdditionalLightShadowsSupportedProp;
  100. SerializedProperty m_AdditionalLightShadowmapResolutionProp;
  101. SerializedProperty m_ShadowDistanceProp;
  102. SerializedProperty m_ShadowCascadesProp;
  103. SerializedProperty m_ShadowCascade2SplitProp;
  104. SerializedProperty m_ShadowCascade4SplitProp;
  105. SerializedProperty m_ShadowDepthBiasProp;
  106. SerializedProperty m_ShadowNormalBiasProp;
  107. SerializedProperty m_SoftShadowsSupportedProp;
  108. SerializedProperty m_SRPBatcher;
  109. SerializedProperty m_SupportsDynamicBatching;
  110. SerializedProperty m_MixedLightingSupportedProp;
  111. SerializedProperty m_DebugLevelProp;
  112. SerializedProperty m_ShaderVariantLogLevel;
  113. LightRenderingMode selectedLightRenderingMode;
  114. SerializedProperty m_PostProcessingFeatureSet;
  115. SerializedProperty m_ColorGradingMode;
  116. SerializedProperty m_ColorGradingLutSize;
  117. public override void OnInspectorGUI()
  118. {
  119. serializedObject.Update();
  120. DrawGeneralSettings();
  121. DrawQualitySettings();
  122. DrawLightingSettings();
  123. DrawShadowSettings();
  124. DrawPostProcessingSettings();
  125. DrawAdvancedSettings();
  126. serializedObject.ApplyModifiedProperties();
  127. }
  128. void OnEnable()
  129. {
  130. m_GeneralSettingsFoldout = new SavedBool($"{target.GetType()}.GeneralSettingsFoldout", false);
  131. m_QualitySettingsFoldout = new SavedBool($"{target.GetType()}.QualitySettingsFoldout", false);
  132. m_LightingSettingsFoldout = new SavedBool($"{target.GetType()}.LightingSettingsFoldout", false);
  133. m_ShadowSettingsFoldout = new SavedBool($"{target.GetType()}.ShadowSettingsFoldout", false);
  134. m_PostProcessingSettingsFoldout = new SavedBool($"{target.GetType()}.PostProcessingSettingsFoldout", false);
  135. m_AdvancedSettingsFoldout = new SavedBool($"{target.GetType()}.AdvancedSettingsFoldout", false);
  136. m_RendererDataProp = serializedObject.FindProperty("m_RendererDataList");
  137. m_DefaultRendererProp = serializedObject.FindProperty("m_DefaultRendererIndex");
  138. m_RendererDataList = new ReorderableList(serializedObject, m_RendererDataProp, false, true, true, true);
  139. DrawRendererListLayout(m_RendererDataList, m_RendererDataProp);
  140. m_RequireDepthTextureProp = serializedObject.FindProperty("m_RequireDepthTexture");
  141. m_RequireOpaqueTextureProp = serializedObject.FindProperty("m_RequireOpaqueTexture");
  142. m_OpaqueDownsamplingProp = serializedObject.FindProperty("m_OpaqueDownsampling");
  143. m_SupportsTerrainHolesProp = serializedObject.FindProperty("m_SupportsTerrainHoles");
  144. m_HDR = serializedObject.FindProperty("m_SupportsHDR");
  145. m_MSAA = serializedObject.FindProperty("m_MSAA");
  146. m_RenderScale = serializedObject.FindProperty("m_RenderScale");
  147. m_MainLightRenderingModeProp = serializedObject.FindProperty("m_MainLightRenderingMode");
  148. m_MainLightShadowsSupportedProp = serializedObject.FindProperty("m_MainLightShadowsSupported");
  149. m_MainLightShadowmapResolutionProp = serializedObject.FindProperty("m_MainLightShadowmapResolution");
  150. m_AdditionalLightsRenderingModeProp = serializedObject.FindProperty("m_AdditionalLightsRenderingMode");
  151. m_AdditionalLightsPerObjectLimitProp = serializedObject.FindProperty("m_AdditionalLightsPerObjectLimit");
  152. m_AdditionalLightShadowsSupportedProp = serializedObject.FindProperty("m_AdditionalLightShadowsSupported");
  153. m_AdditionalLightShadowmapResolutionProp = serializedObject.FindProperty("m_AdditionalLightsShadowmapResolution");
  154. m_ShadowDistanceProp = serializedObject.FindProperty("m_ShadowDistance");
  155. m_ShadowCascadesProp = serializedObject.FindProperty("m_ShadowCascades");
  156. m_ShadowCascade2SplitProp = serializedObject.FindProperty("m_Cascade2Split");
  157. m_ShadowCascade4SplitProp = serializedObject.FindProperty("m_Cascade4Split");
  158. m_ShadowDepthBiasProp = serializedObject.FindProperty("m_ShadowDepthBias");
  159. m_ShadowNormalBiasProp = serializedObject.FindProperty("m_ShadowNormalBias");
  160. m_SoftShadowsSupportedProp = serializedObject.FindProperty("m_SoftShadowsSupported");
  161. m_SRPBatcher = serializedObject.FindProperty("m_UseSRPBatcher");
  162. m_SupportsDynamicBatching = serializedObject.FindProperty("m_SupportsDynamicBatching");
  163. m_MixedLightingSupportedProp = serializedObject.FindProperty("m_MixedLightingSupported");
  164. m_DebugLevelProp = serializedObject.FindProperty("m_DebugLevel");
  165. m_ShaderVariantLogLevel = serializedObject.FindProperty("m_ShaderVariantLogLevel");
  166. m_PostProcessingFeatureSet = serializedObject.FindProperty("m_PostProcessingFeatureSet");
  167. m_ColorGradingMode = serializedObject.FindProperty("m_ColorGradingMode");
  168. m_ColorGradingLutSize = serializedObject.FindProperty("m_ColorGradingLutSize");
  169. selectedLightRenderingMode = (LightRenderingMode)m_AdditionalLightsRenderingModeProp.intValue;
  170. }
  171. void DrawGeneralSettings()
  172. {
  173. m_GeneralSettingsFoldout.value = EditorGUILayout.BeginFoldoutHeaderGroup(m_GeneralSettingsFoldout.value, Styles.generalSettingsText);
  174. if (m_GeneralSettingsFoldout.value)
  175. {
  176. EditorGUI.indentLevel++;
  177. EditorGUILayout.Space();
  178. EditorGUI.indentLevel--;
  179. m_RendererDataList.DoLayoutList();
  180. EditorGUI.indentLevel++;
  181. UniversalRenderPipelineAsset asset = target as UniversalRenderPipelineAsset;
  182. if (!asset.ValidateRendererData(-1))
  183. EditorGUILayout.HelpBox(Styles.rendererMissingDefaultMessage.text, MessageType.Error, true);
  184. else if (!asset.ValidateRendererDataList(true))
  185. EditorGUILayout.HelpBox(Styles.rendererMissingMessage.text, MessageType.Warning, true);
  186. EditorGUILayout.PropertyField(m_RequireDepthTextureProp, Styles.requireDepthTextureText);
  187. EditorGUILayout.PropertyField(m_RequireOpaqueTextureProp, Styles.requireOpaqueTextureText);
  188. EditorGUI.indentLevel++;
  189. EditorGUI.BeginDisabledGroup(!m_RequireOpaqueTextureProp.boolValue);
  190. EditorGUILayout.PropertyField(m_OpaqueDownsamplingProp, Styles.opaqueDownsamplingText);
  191. EditorGUI.EndDisabledGroup();
  192. EditorGUI.indentLevel--;
  193. EditorGUILayout.PropertyField(m_SupportsTerrainHolesProp, Styles.supportsTerrainHolesText);
  194. EditorGUI.indentLevel--;
  195. EditorGUILayout.Space();
  196. EditorGUILayout.Space();
  197. }
  198. EditorGUILayout.EndFoldoutHeaderGroup();
  199. }
  200. void DrawQualitySettings()
  201. {
  202. m_QualitySettingsFoldout.value = EditorGUILayout.BeginFoldoutHeaderGroup(m_QualitySettingsFoldout.value, Styles.qualitySettingsText);
  203. if (m_QualitySettingsFoldout.value)
  204. {
  205. EditorGUI.indentLevel++;
  206. EditorGUILayout.PropertyField(m_HDR, Styles.hdrText);
  207. EditorGUILayout.PropertyField(m_MSAA, Styles.msaaText);
  208. EditorGUI.BeginDisabledGroup(XRGraphics.enabled);
  209. m_RenderScale.floatValue = EditorGUILayout.Slider(Styles.renderScaleText, m_RenderScale.floatValue, UniversalRenderPipeline.minRenderScale, UniversalRenderPipeline.maxRenderScale);
  210. EditorGUI.EndDisabledGroup();
  211. EditorGUI.indentLevel--;
  212. EditorGUILayout.Space();
  213. EditorGUILayout.Space();
  214. }
  215. EditorGUILayout.EndFoldoutHeaderGroup();
  216. }
  217. void DrawLightingSettings()
  218. {
  219. m_LightingSettingsFoldout.value = EditorGUILayout.BeginFoldoutHeaderGroup(m_LightingSettingsFoldout.value, Styles.lightingSettingsText);
  220. if (m_LightingSettingsFoldout.value)
  221. {
  222. EditorGUI.indentLevel++;
  223. // Main Light
  224. bool disableGroup = false;
  225. EditorGUI.BeginDisabledGroup(disableGroup);
  226. CoreEditorUtils.DrawPopup(Styles.mainLightRenderingModeText, m_MainLightRenderingModeProp, Styles.mainLightOptions);
  227. EditorGUI.EndDisabledGroup();
  228. EditorGUI.indentLevel++;
  229. disableGroup |= !m_MainLightRenderingModeProp.boolValue;
  230. EditorGUI.BeginDisabledGroup(disableGroup);
  231. EditorGUILayout.PropertyField(m_MainLightShadowsSupportedProp, Styles.supportsMainLightShadowsText);
  232. EditorGUI.EndDisabledGroup();
  233. disableGroup |= !m_MainLightShadowsSupportedProp.boolValue;
  234. EditorGUI.BeginDisabledGroup(disableGroup);
  235. EditorGUILayout.PropertyField(m_MainLightShadowmapResolutionProp, Styles.mainLightShadowmapResolutionText);
  236. EditorGUI.EndDisabledGroup();
  237. EditorGUI.indentLevel--;
  238. EditorGUILayout.Space();
  239. // Additional light
  240. selectedLightRenderingMode = (LightRenderingMode)EditorGUILayout.EnumPopup(Styles.addditionalLightsRenderingModeText, selectedLightRenderingMode);
  241. m_AdditionalLightsRenderingModeProp.intValue = (int)selectedLightRenderingMode;
  242. EditorGUI.indentLevel++;
  243. disableGroup = m_AdditionalLightsRenderingModeProp.intValue == (int)LightRenderingMode.Disabled;
  244. EditorGUI.BeginDisabledGroup(disableGroup);
  245. m_AdditionalLightsPerObjectLimitProp.intValue = EditorGUILayout.IntSlider(Styles.perObjectLimit, m_AdditionalLightsPerObjectLimitProp.intValue, 0, UniversalRenderPipeline.maxPerObjectLights);
  246. EditorGUI.EndDisabledGroup();
  247. disableGroup |= (m_AdditionalLightsPerObjectLimitProp.intValue == 0 || m_AdditionalLightsRenderingModeProp.intValue != (int)LightRenderingMode.PerPixel);
  248. EditorGUI.BeginDisabledGroup(disableGroup);
  249. EditorGUILayout.PropertyField(m_AdditionalLightShadowsSupportedProp, Styles.supportsAdditionalShadowsText);
  250. EditorGUI.EndDisabledGroup();
  251. disableGroup |= !m_AdditionalLightShadowsSupportedProp.boolValue;
  252. EditorGUI.BeginDisabledGroup(disableGroup);
  253. EditorGUILayout.PropertyField(m_AdditionalLightShadowmapResolutionProp, Styles.additionalLightsShadowmapResolution);
  254. EditorGUI.EndDisabledGroup();
  255. EditorGUI.indentLevel--;
  256. EditorGUI.indentLevel--;
  257. EditorGUILayout.Space();
  258. EditorGUILayout.Space();
  259. }
  260. EditorGUILayout.EndFoldoutHeaderGroup();
  261. }
  262. void DrawShadowSettings()
  263. {
  264. m_ShadowSettingsFoldout.value = EditorGUILayout.BeginFoldoutHeaderGroup(m_ShadowSettingsFoldout.value, Styles.shadowSettingsText);
  265. if (m_ShadowSettingsFoldout.value)
  266. {
  267. EditorGUI.indentLevel++;
  268. m_ShadowDistanceProp.floatValue = Mathf.Max(0.0f, EditorGUILayout.FloatField(Styles.shadowDistanceText, m_ShadowDistanceProp.floatValue));
  269. CoreEditorUtils.DrawPopup(Styles.shadowCascadesText, m_ShadowCascadesProp, Styles.shadowCascadeOptions);
  270. ShadowCascadesOption cascades = (ShadowCascadesOption)m_ShadowCascadesProp.intValue;
  271. if (cascades == ShadowCascadesOption.FourCascades)
  272. EditorUtils.DrawCascadeSplitGUI<Vector3>(ref m_ShadowCascade4SplitProp);
  273. else if (cascades == ShadowCascadesOption.TwoCascades)
  274. EditorUtils.DrawCascadeSplitGUI<float>(ref m_ShadowCascade2SplitProp);
  275. m_ShadowDepthBiasProp.floatValue = EditorGUILayout.Slider(Styles.shadowDepthBias, m_ShadowDepthBiasProp.floatValue, 0.0f, UniversalRenderPipeline.maxShadowBias);
  276. m_ShadowNormalBiasProp.floatValue = EditorGUILayout.Slider(Styles.shadowNormalBias, m_ShadowNormalBiasProp.floatValue, 0.0f, UniversalRenderPipeline.maxShadowBias);
  277. EditorGUILayout.PropertyField(m_SoftShadowsSupportedProp, Styles.supportsSoftShadows);
  278. EditorGUI.indentLevel--;
  279. EditorGUILayout.Space();
  280. EditorGUILayout.Space();
  281. }
  282. EditorGUILayout.EndFoldoutHeaderGroup();
  283. }
  284. void DrawPostProcessingSettings()
  285. {
  286. m_PostProcessingSettingsFoldout.value = EditorGUILayout.BeginFoldoutHeaderGroup(m_PostProcessingSettingsFoldout.value, Styles.postProcessingSettingsText);
  287. if (m_PostProcessingSettingsFoldout.value)
  288. {
  289. bool isHdrOn = m_HDR.boolValue;
  290. EditorGUI.indentLevel++;
  291. bool ppv2Enabled = false;
  292. #if POST_PROCESSING_STACK_2_0_0_OR_NEWER
  293. EditorGUILayout.PropertyField(m_PostProcessingFeatureSet, Styles.postProcessingFeatureSet);
  294. if (m_PostProcessingFeatureSet.intValue == (int)PostProcessingFeatureSet.PostProcessingV2)
  295. {
  296. EditorGUILayout.HelpBox(Styles.postProcessingFeatureSetWarning, MessageType.Warning);
  297. ppv2Enabled = true;
  298. }
  299. #endif
  300. if (!ppv2Enabled)
  301. {
  302. EditorGUILayout.PropertyField(m_ColorGradingMode, Styles.colorGradingMode);
  303. if (!isHdrOn && m_ColorGradingMode.intValue == (int)ColorGradingMode.HighDynamicRange)
  304. EditorGUILayout.HelpBox(Styles.colorGradingModeWarning, MessageType.Warning);
  305. else if (isHdrOn && m_ColorGradingMode.intValue == (int)ColorGradingMode.HighDynamicRange)
  306. EditorGUILayout.HelpBox(Styles.colorGradingModeSpecInfo, MessageType.Info);
  307. EditorGUILayout.DelayedIntField(m_ColorGradingLutSize, Styles.colorGradingLutSize);
  308. m_ColorGradingLutSize.intValue = Mathf.Clamp(m_ColorGradingLutSize.intValue, UniversalRenderPipelineAsset.k_MinLutSize, UniversalRenderPipelineAsset.k_MaxLutSize);
  309. if (isHdrOn && m_ColorGradingMode.intValue == (int)ColorGradingMode.HighDynamicRange && m_ColorGradingLutSize.intValue < 32)
  310. EditorGUILayout.HelpBox(Styles.colorGradingLutSizeWarning, MessageType.Warning);
  311. }
  312. EditorGUI.indentLevel--;
  313. EditorGUILayout.Space();
  314. EditorGUILayout.Space();
  315. }
  316. EditorGUILayout.EndFoldoutHeaderGroup();
  317. }
  318. void DrawAdvancedSettings()
  319. {
  320. m_AdvancedSettingsFoldout.value = EditorGUILayout.BeginFoldoutHeaderGroup(m_AdvancedSettingsFoldout.value, Styles.advancedSettingsText);
  321. if (m_AdvancedSettingsFoldout.value)
  322. {
  323. EditorGUI.indentLevel++;
  324. EditorGUILayout.PropertyField(m_SRPBatcher, Styles.srpBatcher);
  325. EditorGUILayout.PropertyField(m_SupportsDynamicBatching, Styles.dynamicBatching);
  326. EditorGUILayout.PropertyField(m_MixedLightingSupportedProp, Styles.mixedLightingSupportLabel);
  327. EditorGUILayout.PropertyField(m_DebugLevelProp, Styles.debugLevel);
  328. EditorGUILayout.PropertyField(m_ShaderVariantLogLevel, Styles.shaderVariantLogLevel);
  329. EditorGUI.indentLevel--;
  330. EditorGUILayout.Space();
  331. EditorGUILayout.Space();
  332. }
  333. EditorGUILayout.EndFoldoutHeaderGroup();
  334. }
  335. void DrawRendererListLayout(ReorderableList list, SerializedProperty prop)
  336. {
  337. list.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) =>
  338. {
  339. rect.y += 2;
  340. Rect indexRect = new Rect(rect.x, rect.y, 14, EditorGUIUtility.singleLineHeight);
  341. EditorGUI.LabelField(indexRect, index.ToString());
  342. Rect objRect = new Rect(rect.x + indexRect.width, rect.y, rect.width - 134, EditorGUIUtility.singleLineHeight);
  343. EditorGUI.BeginChangeCheck();
  344. EditorGUI.ObjectField(objRect, prop.GetArrayElementAtIndex(index), GUIContent.none);
  345. if(EditorGUI.EndChangeCheck())
  346. EditorUtility.SetDirty(target);
  347. Rect defaultButton = new Rect(rect.width - 90, rect.y, 86, EditorGUIUtility.singleLineHeight);
  348. var defaultRenderer = m_DefaultRendererProp.intValue;
  349. GUI.enabled = index != defaultRenderer;
  350. if(GUI.Button(defaultButton, !GUI.enabled ? Styles.rendererDefaultText : Styles.rendererSetDefaultText))
  351. {
  352. m_DefaultRendererProp.intValue = index;
  353. EditorUtility.SetDirty(target);
  354. }
  355. GUI.enabled = true;
  356. Rect selectRect = new Rect(rect.x + rect.width - 24, rect.y, 24, EditorGUIUtility.singleLineHeight);
  357. UniversalRenderPipelineAsset asset = target as UniversalRenderPipelineAsset;
  358. if (asset.ValidateRendererData(index))
  359. {
  360. if (GUI.Button(selectRect, Styles.rendererSettingsText))
  361. {
  362. Selection.SetActiveObjectWithContext(prop.GetArrayElementAtIndex(index).objectReferenceValue,
  363. null);
  364. }
  365. }
  366. else // Missing ScriptableRendererData
  367. {
  368. if (GUI.Button(selectRect, index == defaultRenderer ? Styles.rendererDefaultMissingText : Styles.rendererMissingText))
  369. {
  370. EditorGUIUtility.ShowObjectPicker<ScriptableRendererData>(null, false, null, index);
  371. }
  372. }
  373. // If object selector chose an object, assign it to the correct ScriptableRendererData slot.
  374. if (Event.current.commandName == "ObjectSelectorUpdated" && EditorGUIUtility.GetObjectPickerControlID() == index)
  375. {
  376. prop.GetArrayElementAtIndex(index).objectReferenceValue = EditorGUIUtility.GetObjectPickerObject();
  377. }
  378. };
  379. list.drawHeaderCallback = (Rect rect) =>
  380. {
  381. EditorGUI.LabelField(rect, Styles.rendererHeaderText);
  382. list.index = list.count - 1;
  383. };
  384. list.onCanRemoveCallback = li => { return li.count > 1; };
  385. list.onCanAddCallback = li => { return li.count < UniversalRenderPipeline.maxScriptableRenderers; };
  386. list.onRemoveCallback = li =>
  387. {
  388. if (li.serializedProperty.arraySize - 1 != m_DefaultRendererProp.intValue)
  389. {
  390. if(li.serializedProperty.GetArrayElementAtIndex(li.serializedProperty.arraySize - 1).objectReferenceValue != null)
  391. li.serializedProperty.DeleteArrayElementAtIndex(li.serializedProperty.arraySize - 1);
  392. li.serializedProperty.arraySize--;
  393. li.index = li.count - 1;
  394. }
  395. else
  396. {
  397. EditorUtility.DisplayDialog(Styles.rendererListDefaultMessage.text, Styles.rendererListDefaultMessage.tooltip,
  398. "Close");
  399. }
  400. EditorUtility.SetDirty(target);
  401. };
  402. }
  403. }
  404. }