Ingen beskrivning
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

UniversalRenderPipelineAsset.cs 76KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961
  1. using System;
  2. #if UNITY_EDITOR
  3. using UnityEditor;
  4. using UnityEditor.ProjectWindowCallback;
  5. using System.IO;
  6. using ShaderKeywordFilter = UnityEditor.ShaderKeywordFilter;
  7. #endif
  8. using System.ComponentModel;
  9. using UnityEngine.Serialization;
  10. using UnityEngine.Experimental.Rendering;
  11. using UnityEngine.Rendering.RenderGraphModule;
  12. namespace UnityEngine.Rendering.Universal
  13. {
  14. /// <summary>
  15. /// The elements in this enum define how Unity renders shadows.
  16. /// </summary>
  17. public enum ShadowQuality
  18. {
  19. /// <summary>
  20. /// Disables the shadows.
  21. /// </summary>
  22. Disabled,
  23. /// <summary>
  24. /// Shadows have hard edges.
  25. /// </summary>
  26. HardShadows,
  27. /// <summary>
  28. /// Filtering is applied when sampling shadows. Shadows have smooth edges.
  29. /// </summary>
  30. SoftShadows,
  31. }
  32. /// <summary>
  33. /// Softness quality of soft shadows. Higher means better quality, but lower performance.
  34. /// </summary>
  35. public enum SoftShadowQuality
  36. {
  37. /// <summary>
  38. /// Use this to choose the setting set on the pipeline asset.
  39. /// </summary>
  40. [InspectorName("Use settings from Render Pipeline Asset")]
  41. UsePipelineSettings,
  42. /// <summary>
  43. /// Low quality soft shadows. Recommended for mobile. 4 PCF sample filtering.
  44. /// </summary>
  45. Low,
  46. /// <summary>
  47. /// Medium quality soft shadows. The default. 5x5 tent filtering.
  48. /// </summary>
  49. Medium,
  50. /// <summary>
  51. /// High quality soft shadows. Low performance due to high sample count. 7x7 tent filtering.
  52. /// </summary>
  53. High,
  54. }
  55. /// <summary>
  56. /// This controls the size of the shadow map texture.
  57. /// </summary>
  58. public enum ShadowResolution
  59. {
  60. /// <summary>
  61. /// Use this for 256x256 shadow resolution.
  62. /// </summary>
  63. _256 = 256,
  64. /// <summary>
  65. /// Use this for 512x512 shadow resolution.
  66. /// </summary>
  67. _512 = 512,
  68. /// <summary>
  69. /// Use this for 1024x1024 shadow resolution.
  70. /// </summary>
  71. _1024 = 1024,
  72. /// <summary>
  73. /// Use this for 2048x2048 shadow resolution.
  74. /// </summary>
  75. _2048 = 2048,
  76. /// <summary>
  77. /// Use this for 4096x4096 shadow resolution.
  78. /// </summary>
  79. _4096 = 4096,
  80. /// <summary>
  81. /// Use this for 8192x8192 shadow resolution.
  82. /// </summary>
  83. _8192 = 8192,
  84. }
  85. /// <summary>
  86. /// This controls the size of the Light Cookie atlas texture for additional lights (point, spot).
  87. /// </summary>
  88. public enum LightCookieResolution
  89. {
  90. /// <summary>
  91. /// Use this for 256x256 Light Cookie resolution.
  92. /// </summary>
  93. _256 = 256,
  94. /// <summary>
  95. /// Use this for 512x512 Light Cookie resolution.
  96. /// </summary>
  97. _512 = 512,
  98. /// <summary>
  99. /// Use this for 1024x1024 Light Cookie resolution.
  100. /// </summary>
  101. _1024 = 1024,
  102. /// <summary>
  103. /// Use this for 2048x2048 Light Cookie resolution.
  104. /// </summary>
  105. _2048 = 2048,
  106. /// <summary>
  107. /// Use this for 4096x4096 Light Cookie resolution.
  108. /// </summary>
  109. _4096 = 4096
  110. }
  111. /// <summary>
  112. /// Options for selecting the format for the Light Cookie atlas texture for additional lights (point, spot).
  113. /// Low precision saves memory and bandwidth.
  114. /// </summary>
  115. public enum LightCookieFormat
  116. {
  117. /// <summary>
  118. /// Use this to select Grayscale format with low precision.
  119. /// </summary>
  120. GrayscaleLow,
  121. /// <summary>
  122. /// Use this to select Grayscale format with high precision.
  123. /// </summary>
  124. GrayscaleHigh,
  125. /// <summary>
  126. /// Use this to select Color format with low precision.
  127. /// </summary>
  128. ColorLow,
  129. /// <summary>
  130. /// Use this to select Color format with high precision.
  131. /// </summary>
  132. ColorHigh,
  133. /// <summary>
  134. /// Use this to select High Dynamic Range format.
  135. /// </summary>
  136. ColorHDR,
  137. }
  138. /// <summary>
  139. /// The default color buffer format in HDR (only).
  140. /// Affects camera rendering and postprocessing color buffers.
  141. /// </summary>
  142. public enum HDRColorBufferPrecision
  143. {
  144. /// <summary> Typically R11G11B10f for faster rendering. Recommend for mobile.
  145. /// R11G11B10f can cause a subtle blue/yellow banding in some rare cases due to lower precision of the blue component.</summary>
  146. [Tooltip("Use 32-bits per pixel for HDR rendering.")]
  147. _32Bits,
  148. /// <summary>Typically R16G16B16A16f for better quality. Can reduce banding at the cost of memory and performance.</summary>
  149. [Tooltip("Use 64-bits per pixel for HDR rendering.")]
  150. _64Bits,
  151. }
  152. /// <summary>
  153. /// Options for setting MSAA Quality.
  154. /// This defines how many samples URP computes per pixel for evaluating the effect.
  155. /// </summary>
  156. public enum MsaaQuality
  157. {
  158. /// <summary>
  159. /// Disables MSAA.
  160. /// </summary>
  161. Disabled = 1,
  162. /// <summary>
  163. /// Use this for 2 samples per pixel.
  164. /// </summary>
  165. _2x = 2,
  166. /// <summary>
  167. /// Use this for 4 samples per pixel.
  168. /// </summary>
  169. _4x = 4,
  170. /// <summary>
  171. /// Use this for 8 samples per pixel.
  172. /// </summary>
  173. _8x = 8
  174. }
  175. /// <summary>
  176. /// Options for selecting downsampling.
  177. /// </summary>
  178. public enum Downsampling
  179. {
  180. /// <summary>
  181. /// Use this to disable downsampling.
  182. /// </summary>
  183. None,
  184. /// <summary>
  185. /// Use this to produce a half-resolution image with bilinear filtering.
  186. /// </summary>
  187. _2xBilinear,
  188. /// <summary>
  189. /// Use this to produce a quarter-resolution image with box filtering. This produces a softly blurred copy.
  190. /// </summary>
  191. _4xBox,
  192. /// <summary>
  193. /// Use this to produce a quarter-resolution image with bi-linear filtering.
  194. /// </summary>
  195. _4xBilinear
  196. }
  197. /// <summary>
  198. /// Options for light rendering mode.
  199. /// </summary>
  200. public enum LightRenderingMode
  201. {
  202. /// <summary>
  203. /// Use this to disable lighting.
  204. /// </summary>
  205. Disabled = 0,
  206. /// <summary>
  207. /// Use this to select lighting to be calculated per vertex.
  208. /// </summary>
  209. PerVertex = 2,
  210. /// <summary>
  211. /// Use this to select lighting to be calculated per pixel.
  212. /// </summary>
  213. PerPixel = 1,
  214. }
  215. /// <summary>
  216. /// Defines if profiling is logged or not. This enum is not longer in use, use the Profiler instead.
  217. /// </summary>
  218. [Obsolete("PipelineDebugLevel is replaced to use the profiler and has no effect.", true)]
  219. public enum PipelineDebugLevel
  220. {
  221. /// <summary>
  222. /// Disabled logging for profiling.
  223. /// </summary>
  224. Disabled,
  225. /// <summary>
  226. /// Enabled logging for profiling.
  227. /// </summary>
  228. Profiling,
  229. }
  230. /// <summary>
  231. /// Options to select the type of Renderer to use.
  232. /// </summary>
  233. public enum RendererType
  234. {
  235. /// <summary>
  236. /// Use this for Custom Renderer.
  237. /// </summary>
  238. Custom,
  239. /// <summary>
  240. /// Use this for Universal Renderer.
  241. /// </summary>
  242. UniversalRenderer,
  243. /// <summary>
  244. /// Use this for 2D Renderer.
  245. /// </summary>
  246. _2DRenderer,
  247. }
  248. /// <summary>
  249. /// Options for selecting Color Grading modes, Low Dynamic Range (LDR) or High Dynamic Range (HDR)
  250. /// </summary>
  251. public enum ColorGradingMode
  252. {
  253. /// <summary>
  254. /// This mode follows a more classic workflow. Unity applies a limited range of color grading after tonemapping.
  255. /// </summary>
  256. LowDynamicRange,
  257. /// <summary>
  258. /// This mode works best for high precision grading similar to movie production workflows. Unity applies color grading before tonemapping.
  259. /// </summary>
  260. HighDynamicRange
  261. }
  262. /// <summary>
  263. /// Defines if Unity discards or stores the render targets of the DrawObjects Passes. Selecting the Store option significantly increases the memory bandwidth on mobile and tile-based GPUs.
  264. /// </summary>
  265. public enum StoreActionsOptimization
  266. {
  267. /// <summary>Unity uses the Discard option by default, and falls back to the Store option if it detects any injected Passes.</summary>
  268. Auto,
  269. /// <summary>Unity discards the render targets of render Passes that are not reused later (lower memory bandwidth).</summary>
  270. Discard,
  271. /// <summary>Unity stores all render targets of each Pass (higher memory bandwidth).</summary>
  272. Store
  273. }
  274. /// <summary>
  275. /// Defines the update frequency for the Volume Framework.
  276. /// </summary>
  277. public enum VolumeFrameworkUpdateMode
  278. {
  279. /// <summary>
  280. /// Use this to have the Volume Framework update every frame.
  281. /// </summary>
  282. [InspectorName("Every Frame")]
  283. EveryFrame = 0,
  284. /// <summary>
  285. /// Use this to disable Volume Framework updates or to update it manually via scripting.
  286. /// </summary>
  287. [InspectorName("Via Scripting")]
  288. ViaScripting = 1,
  289. /// <summary>
  290. /// Use this to choose the setting set on the pipeline asset.
  291. /// </summary>
  292. [InspectorName("Use Pipeline Settings")]
  293. UsePipelineSettings = 2,
  294. }
  295. /// <summary>
  296. /// Defines the upscaling filter selected by the user the universal render pipeline asset.
  297. /// </summary>
  298. public enum UpscalingFilterSelection
  299. {
  300. /// <summary>
  301. /// Unity selects a filtering option automatically based on the Render Scale value and the current screen resolution.
  302. /// </summary>
  303. [InspectorName("Automatic"), Tooltip("Unity selects a filtering option automatically based on the Render Scale value and the current screen resolution.")]
  304. Auto,
  305. /// <summary>
  306. /// Unity uses Bilinear filtering to perform upscaling.
  307. /// </summary>
  308. [InspectorName("Bilinear")]
  309. Linear,
  310. /// <summary>
  311. /// Unity uses Nearest-Neighbour filtering to perform upscaling.
  312. /// </summary>
  313. [InspectorName("Nearest-Neighbor")]
  314. Point,
  315. /// <summary>
  316. /// Unity uses the AMD FSR 1.0 technique to perform upscaling.
  317. /// </summary>
  318. [InspectorName("FidelityFX Super Resolution 1.0"), Tooltip("If the target device does not support Unity shader model 4.5, Unity falls back to the Automatic option.")]
  319. FSR,
  320. /// <summary>
  321. /// Unity uses the Spatial-Temporal Post-Processing technique to perform upscaling.
  322. /// </summary>
  323. [InspectorName("Spatial-Temporal Post-Processing"), Tooltip("If the target device does not support compute shaders or is running GLES, Unity falls back to the Automatic option.")]
  324. STP
  325. }
  326. /// <summary>
  327. /// Type of the LOD cross-fade.
  328. /// </summary>
  329. public enum LODCrossFadeDitheringType
  330. {
  331. /// <summary>Unity uses the Bayer matrix texture to compute the LOD cross-fade dithering.</summary>
  332. BayerMatrix,
  333. /// <summary>Unity uses the precomputed blue noise texture to compute the LOD cross-fade dithering.</summary>
  334. BlueNoise
  335. }
  336. /// <summary>
  337. /// The available Probe system used.
  338. /// </summary>
  339. public enum LightProbeSystem
  340. {
  341. /// <summary>The light probe group system.</summary>
  342. [InspectorName("Light Probe Groups")]
  343. LegacyLightProbes = 0,
  344. /// <summary>Adaptive Probe Volumes system.</summary>
  345. [InspectorName("Adaptive Probe Volumes")]
  346. ProbeVolumes = 1,
  347. }
  348. /// <summary>
  349. /// The type of Spherical Harmonics lighting evaluation in a shader.
  350. /// </summary>
  351. public enum ShEvalMode
  352. {
  353. /// <summary>Unity selects a mode automatically.</summary>
  354. Auto = 0,
  355. /// <summary>Evaluate lighting per vertex.</summary>
  356. PerVertex = 1,
  357. /// <summary>Evaluate lighting partially per vertex, partially per pixel.</summary>
  358. Mixed = 2,
  359. /// <summary>Evaluate lighting per pixel.</summary>
  360. PerPixel = 3,
  361. }
  362. internal struct DeprecationMessage
  363. {
  364. internal const string CompatibilityScriptingAPIObsolete = "This rendering path is for compatibility mode only (when Render Graph is disabled). Use Render Graph API instead.";
  365. internal const string CompatibilityScriptingAPIConsoleWarning = "The project currently uses the compatibility mode where the Render Graph API is disabled. Support for this mode will be removed in future Unity versions. Migrate existing ScriptableRenderPasses to the new RenderGraph API. After the migration, disable the compatibility mode in Edit > Projects Settings > Graphics > Render Graph.";
  366. }
  367. #if UNITY_EDITOR
  368. internal class WarnUsingNonRenderGraph
  369. {
  370. [InitializeOnLoadMethod]
  371. internal static void EmitConsoleWarning()
  372. {
  373. RenderGraphSettings rgs = GraphicsSettings.GetRenderPipelineSettings<RenderGraphSettings>();
  374. if (rgs != null && rgs.enableRenderCompatibilityMode)
  375. Debug.LogWarning(DeprecationMessage.CompatibilityScriptingAPIConsoleWarning);
  376. }
  377. }
  378. #endif
  379. /// <summary>
  380. /// The asset that contains the URP setting.
  381. /// You can use this asset as a graphics quality level.
  382. /// </summary>
  383. /// <see cref="RenderPipelineAsset"/>
  384. /// <see cref="UniversalRenderPipeline"/>
  385. [ExcludeFromPreset]
  386. [URPHelpURL("universalrp-asset")]
  387. #if UNITY_EDITOR
  388. [ShaderKeywordFilter.ApplyRulesIfTagsEqual("RenderPipeline", "UniversalPipeline")]
  389. #endif
  390. public partial class UniversalRenderPipelineAsset : RenderPipelineAsset<UniversalRenderPipeline>, ISerializationCallbackReceiver, IProbeVolumeEnabledRenderPipeline, IGPUResidentRenderPipeline, IRenderGraphEnabledRenderPipeline
  391. {
  392. ScriptableRenderer[] m_Renderers = new ScriptableRenderer[1];
  393. internal bool IsAtLastVersion() => k_LastVersion == k_AssetVersion;
  394. private const int k_LastVersion = 12;
  395. // Default values set when a new UniversalRenderPipeline asset is created
  396. [SerializeField] int k_AssetVersion = k_LastVersion;
  397. [SerializeField] int k_AssetPreviousVersion = k_LastVersion;
  398. // Deprecated settings for upgrading sakes
  399. [SerializeField] RendererType m_RendererType = RendererType.UniversalRenderer;
  400. [EditorBrowsable(EditorBrowsableState.Never)]
  401. [Obsolete("Use m_RendererDataList instead.")]
  402. [SerializeField] internal ScriptableRendererData m_RendererData = null;
  403. // Renderer settings
  404. [SerializeField] internal ScriptableRendererData[] m_RendererDataList = new ScriptableRendererData[1];
  405. [SerializeField] internal int m_DefaultRendererIndex = 0;
  406. // General settings
  407. [SerializeField] bool m_RequireDepthTexture = false;
  408. [SerializeField] bool m_RequireOpaqueTexture = false;
  409. [SerializeField] Downsampling m_OpaqueDownsampling = Downsampling._2xBilinear;
  410. [SerializeField] bool m_SupportsTerrainHoles = true;
  411. // Quality settings
  412. [SerializeField] bool m_SupportsHDR = true;
  413. [SerializeField] HDRColorBufferPrecision m_HDRColorBufferPrecision = HDRColorBufferPrecision._32Bits;
  414. [SerializeField] MsaaQuality m_MSAA = MsaaQuality.Disabled;
  415. [SerializeField] float m_RenderScale = 1.0f;
  416. [SerializeField] UpscalingFilterSelection m_UpscalingFilter = UpscalingFilterSelection.Auto;
  417. [SerializeField] bool m_FsrOverrideSharpness = false;
  418. [SerializeField] float m_FsrSharpness = FSRUtils.kDefaultSharpnessLinear;
  419. #if UNITY_EDITOR // multi_compile _ LOD_FADE_CROSSFADE
  420. [ShaderKeywordFilter.RemoveIf(false, keywordNames: ShaderKeywordStrings.LOD_FADE_CROSSFADE)]
  421. #endif
  422. [SerializeField] bool m_EnableLODCrossFade = true;
  423. [SerializeField] LODCrossFadeDitheringType m_LODCrossFadeDitheringType = LODCrossFadeDitheringType.BlueNoise;
  424. // ShEvalMode.Auto is handled in shader preprocessor.
  425. #if UNITY_EDITOR // multi_compile _ EVALUATE_SH_MIXED EVALUATE_SH_VERTEX
  426. [ShaderKeywordFilter.RemoveIf(ShEvalMode.PerPixel, keywordNames: new [] { ShaderKeywordStrings.EVALUATE_SH_MIXED, ShaderKeywordStrings.EVALUATE_SH_VERTEX })]
  427. [ShaderKeywordFilter.SelectIf(ShEvalMode.Mixed, keywordNames: new [] { ShaderKeywordStrings.EVALUATE_SH_MIXED })]
  428. [ShaderKeywordFilter.SelectIf(ShEvalMode.PerVertex, keywordNames: new [] { ShaderKeywordStrings.EVALUATE_SH_VERTEX })]
  429. #endif
  430. [SerializeField] ShEvalMode m_ShEvalMode = ShEvalMode.Auto;
  431. // Probe volume settings
  432. #if UNITY_EDITOR
  433. [ShaderKeywordFilter.RemoveIf(LightProbeSystem.LegacyLightProbes, keywordNames: new [] { ShaderKeywordStrings.ProbeVolumeL1, ShaderKeywordStrings.ProbeVolumeL2 })]
  434. [ShaderKeywordFilter.SelectIf(LightProbeSystem.ProbeVolumes, keywordNames: new [] { ShaderKeywordStrings.ProbeVolumeL1, ShaderKeywordStrings.ProbeVolumeL2 })]
  435. #endif
  436. [SerializeField] LightProbeSystem m_LightProbeSystem = LightProbeSystem.LegacyLightProbes;
  437. [SerializeField] ProbeVolumeTextureMemoryBudget m_ProbeVolumeMemoryBudget = ProbeVolumeTextureMemoryBudget.MemoryBudgetMedium;
  438. [SerializeField] ProbeVolumeBlendingTextureMemoryBudget m_ProbeVolumeBlendingMemoryBudget = ProbeVolumeBlendingTextureMemoryBudget.MemoryBudgetMedium;
  439. [SerializeField] [FormerlySerializedAs("m_SupportProbeVolumeStreaming")] bool m_SupportProbeVolumeGPUStreaming = false;
  440. [SerializeField] bool m_SupportProbeVolumeDiskStreaming = false;
  441. [SerializeField] bool m_SupportProbeVolumeScenarios = false;
  442. [SerializeField] bool m_SupportProbeVolumeScenarioBlending = false;
  443. #if UNITY_EDITOR
  444. [ShaderKeywordFilter.RemoveIf(ProbeVolumeSHBands.SphericalHarmonicsL1, keywordNames: ShaderKeywordStrings.ProbeVolumeL2)]
  445. [ShaderKeywordFilter.RemoveIf(ProbeVolumeSHBands.SphericalHarmonicsL2, keywordNames: ShaderKeywordStrings.ProbeVolumeL1)]
  446. #endif
  447. [SerializeField] ProbeVolumeSHBands m_ProbeVolumeSHBands = ProbeVolumeSHBands.SphericalHarmonicsL1;
  448. // Main directional light Settings
  449. [SerializeField] LightRenderingMode m_MainLightRenderingMode = LightRenderingMode.PerPixel;
  450. [SerializeField] bool m_MainLightShadowsSupported = true;
  451. [SerializeField] ShadowResolution m_MainLightShadowmapResolution = ShadowResolution._2048;
  452. // Additional lights settings
  453. [SerializeField] LightRenderingMode m_AdditionalLightsRenderingMode = LightRenderingMode.PerPixel;
  454. [SerializeField] int m_AdditionalLightsPerObjectLimit = 4;
  455. [SerializeField] bool m_AdditionalLightShadowsSupported = false;
  456. [SerializeField] ShadowResolution m_AdditionalLightsShadowmapResolution = ShadowResolution._2048;
  457. [SerializeField] int m_AdditionalLightsShadowResolutionTierLow = AdditionalLightsDefaultShadowResolutionTierLow;
  458. [SerializeField] int m_AdditionalLightsShadowResolutionTierMedium = AdditionalLightsDefaultShadowResolutionTierMedium;
  459. [SerializeField] int m_AdditionalLightsShadowResolutionTierHigh = AdditionalLightsDefaultShadowResolutionTierHigh;
  460. // Reflection Probes
  461. #if UNITY_EDITOR // multi_compile_fragment _ _REFLECTION_PROBE_BLENDING
  462. [ShaderKeywordFilter.SelectOrRemove(true, keywordNames: ShaderKeywordStrings.ReflectionProbeBlending)]
  463. #endif
  464. [SerializeField] bool m_ReflectionProbeBlending = false;
  465. #if UNITY_EDITOR // multi_compile_fragment _ _REFLECTION_PROBE_BOX_PROJECTION
  466. [ShaderKeywordFilter.SelectOrRemove(true, keywordNames: ShaderKeywordStrings.ReflectionProbeBoxProjection)]
  467. #endif
  468. [SerializeField] bool m_ReflectionProbeBoxProjection = false;
  469. // Shadows Settings
  470. [SerializeField] float m_ShadowDistance = 50.0f;
  471. [SerializeField] int m_ShadowCascadeCount = 1;
  472. [SerializeField] float m_Cascade2Split = 0.25f;
  473. [SerializeField] Vector2 m_Cascade3Split = new Vector2(0.1f, 0.3f);
  474. [SerializeField] Vector3 m_Cascade4Split = new Vector3(0.067f, 0.2f, 0.467f);
  475. [SerializeField] float m_CascadeBorder = 0.2f;
  476. [SerializeField] float m_ShadowDepthBias = 1.0f;
  477. [SerializeField] float m_ShadowNormalBias = 1.0f;
  478. #if UNITY_EDITOR // multi_compile_fragment _ _SHADOWS_SOFT
  479. [ShaderKeywordFilter.RemoveIf(false, keywordNames: ShaderKeywordStrings.SoftShadows)]
  480. [SerializeField] bool m_AnyShadowsSupported = true;
  481. // No option to force soft shadows -> we'll need to keep the off variant around
  482. [ShaderKeywordFilter.RemoveIf(false, keywordNames: ShaderKeywordStrings.SoftShadows)]
  483. #endif
  484. [SerializeField] bool m_SoftShadowsSupported = false;
  485. [SerializeField] bool m_ConservativeEnclosingSphere = false;
  486. [SerializeField] int m_NumIterationsEnclosingSphere = 64;
  487. [SerializeField] SoftShadowQuality m_SoftShadowQuality = SoftShadowQuality.Medium;
  488. // Light Cookie Settings
  489. [SerializeField] LightCookieResolution m_AdditionalLightsCookieResolution = LightCookieResolution._2048;
  490. [SerializeField] LightCookieFormat m_AdditionalLightsCookieFormat = LightCookieFormat.ColorHigh;
  491. // Advanced settings
  492. [SerializeField] bool m_UseSRPBatcher = true;
  493. [SerializeField] bool m_SupportsDynamicBatching = false;
  494. #if UNITY_EDITOR
  495. // multi_compile _ LIGHTMAP_SHADOW_MIXING
  496. [ShaderKeywordFilter.RemoveIf(false, keywordNames: ShaderKeywordStrings.LightmapShadowMixing)]
  497. // multi_compile _ SHADOWS_SHADOWMASK
  498. [ShaderKeywordFilter.RemoveIf(false, keywordNames: ShaderKeywordStrings.ShadowsShadowMask)]
  499. #endif
  500. [SerializeField] bool m_MixedLightingSupported = true;
  501. #if UNITY_EDITOR
  502. // multi_compile_fragment _ _LIGHT_COOKIES
  503. [ShaderKeywordFilter.RemoveIf(false, keywordNames: ShaderKeywordStrings.LightCookies)]
  504. #endif
  505. [SerializeField] bool m_SupportsLightCookies = true;
  506. #if UNITY_EDITOR
  507. // multi_compile_fragment _ _LIGHT_LAYERS
  508. [ShaderKeywordFilter.SelectOrRemove(true, keywordNames: ShaderKeywordStrings.LightLayers)]
  509. #endif
  510. [SerializeField] bool m_SupportsLightLayers = false;
  511. [SerializeField] [Obsolete("",true)] PipelineDebugLevel m_DebugLevel;
  512. [SerializeField] StoreActionsOptimization m_StoreActionsOptimization = StoreActionsOptimization.Auto;
  513. // Adaptive performance settings
  514. [SerializeField] bool m_UseAdaptivePerformance = true;
  515. // Post-processing settings
  516. [SerializeField] ColorGradingMode m_ColorGradingMode = ColorGradingMode.LowDynamicRange;
  517. [SerializeField] int m_ColorGradingLutSize = 32;
  518. #if UNITY_EDITOR // multi_compile_fragment _ _ENABLE_ALPHA_OUTPUT
  519. [ShaderKeywordFilter.SelectOrRemove(true, keywordNames: ShaderKeywordStrings._ENABLE_ALPHA_OUTPUT)]
  520. #endif
  521. [SerializeField] bool m_AllowPostProcessAlphaOutput = false;
  522. #if UNITY_EDITOR // multi_compile_local_fragment _ _USE_FAST_SRGB_LINEAR_CONVERSION
  523. [ShaderKeywordFilter.SelectOrRemove(true, keywordNames: ShaderKeywordStrings.UseFastSRGBLinearConversion)]
  524. #endif
  525. [SerializeField] bool m_UseFastSRGBLinearConversion = false;
  526. [SerializeField] bool m_SupportDataDrivenLensFlare = true;
  527. [SerializeField] bool m_SupportScreenSpaceLensFlare = true;
  528. // GPU Resident Drawer
  529. [FormerlySerializedAs("m_MacroBatcherMode"), SerializeField]
  530. private GPUResidentDrawerMode m_GPUResidentDrawerMode = GPUResidentDrawerMode.Disabled;
  531. [SerializeField] float m_SmallMeshScreenPercentage = 0.0f;
  532. [SerializeField] bool m_GPUResidentDrawerEnableOcclusionCullingInCameras;
  533. GPUResidentDrawerSettings IGPUResidentRenderPipeline.gpuResidentDrawerSettings => new()
  534. {
  535. mode = m_GPUResidentDrawerMode,
  536. enableOcclusionCulling = m_GPUResidentDrawerEnableOcclusionCullingInCameras,
  537. supportDitheringCrossFade = m_EnableLODCrossFade,
  538. allowInEditMode = true,
  539. smallMeshScreenPercentage = m_SmallMeshScreenPercentage,
  540. #if UNITY_EDITOR
  541. pickingShader = Shader.Find("Hidden/Universal Render Pipeline/BRGPicking"),
  542. #endif
  543. errorShader = Shader.Find("Hidden/Universal Render Pipeline/FallbackError"),
  544. loadingShader = Shader.Find("Hidden/Universal Render Pipeline/FallbackLoading"),
  545. };
  546. // Deprecated settings
  547. [SerializeField] ShadowQuality m_ShadowType = ShadowQuality.HardShadows;
  548. [SerializeField] bool m_LocalShadowsSupported = false;
  549. [SerializeField] ShadowResolution m_LocalShadowsAtlasResolution = ShadowResolution._256;
  550. [SerializeField] int m_MaxPixelLights = 0;
  551. [SerializeField] ShadowResolution m_ShadowAtlasResolution = ShadowResolution._256;
  552. [SerializeField] VolumeFrameworkUpdateMode m_VolumeFrameworkUpdateMode = VolumeFrameworkUpdateMode.EveryFrame;
  553. [SerializeField] VolumeProfile m_VolumeProfile;
  554. // Note: A lut size of 16^3 is barely usable with the HDR grading mode. 32 should be the
  555. // minimum, the lut being encoded in log. Lower sizes would work better with an additional
  556. // 1D shaper lut but for now we'll keep it simple.
  557. /// <summary>
  558. /// The minimum color grading LUT (lookup table) size.
  559. /// </summary>
  560. public const int k_MinLutSize = 16;
  561. /// <summary>
  562. /// The maximum color grading LUT (lookup table) size.
  563. /// </summary>
  564. public const int k_MaxLutSize = 65;
  565. internal const int k_ShadowCascadeMinCount = 1;
  566. internal const int k_ShadowCascadeMaxCount = 4;
  567. /// <summary>
  568. /// The default low tier resolution for additional lights shadow texture.
  569. /// </summary>
  570. public static readonly int AdditionalLightsDefaultShadowResolutionTierLow = 256;
  571. /// <summary>
  572. /// The default medium tier resolution for additional lights shadow texture.
  573. /// </summary>
  574. public static readonly int AdditionalLightsDefaultShadowResolutionTierMedium = 512;
  575. /// <summary>
  576. /// The default high tier resolution for additional lights shadow texture.
  577. /// </summary>
  578. public static readonly int AdditionalLightsDefaultShadowResolutionTierHigh = 1024;
  579. /// <summary>
  580. /// The list of renderer data used by this pipeline asset.
  581. /// </summary>
  582. public ReadOnlySpan<ScriptableRendererData> rendererDataList => m_RendererDataList;
  583. /// <summary>
  584. /// The list of renderers used by this pipeline asset.
  585. /// </summary>
  586. public ReadOnlySpan<ScriptableRenderer> renderers => m_Renderers;
  587. static string[] s_Names;
  588. static int[] s_Values;
  589. /// <inheritdoc/>
  590. public bool isImmediateModeSupported => false;
  591. #if UNITY_EDITOR
  592. public static readonly string packagePath = "Packages/com.unity.render-pipelines.universal";
  593. public static UniversalRenderPipelineAsset Create(ScriptableRendererData rendererData = null)
  594. {
  595. // Create Universal RP Asset
  596. var instance = CreateInstance<UniversalRenderPipelineAsset>();
  597. // Initialize default renderer data
  598. instance.m_RendererDataList[0] = (rendererData != null) ? rendererData : CreateInstance<UniversalRendererData>();
  599. // Only enable for new URP assets by default
  600. instance.m_ConservativeEnclosingSphere = true;
  601. ResourceReloader.ReloadAllNullIn(instance, packagePath);
  602. return instance;
  603. }
  604. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1812")]
  605. internal class CreateUniversalPipelineAsset : EndNameEditAction
  606. {
  607. public override void Action(int instanceId, string pathName, string resourceFile)
  608. {
  609. //Create asset
  610. AssetDatabase.CreateAsset(Create(CreateRendererAsset(pathName, RendererType.UniversalRenderer)), pathName);
  611. }
  612. }
  613. [MenuItem("Assets/Create/Rendering/URP Asset (with Universal Renderer)", priority = CoreUtils.Sections.section2 + CoreUtils.Priorities.assetsCreateRenderingMenuPriority + 1)]
  614. static void CreateUniversalPipeline()
  615. {
  616. ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, CreateInstance<CreateUniversalPipelineAsset>(),
  617. "New Universal Render Pipeline Asset.asset", null, null);
  618. }
  619. internal static ScriptableRendererData CreateRendererAsset(string path, RendererType type, bool relativePath = true, string suffix = "Renderer")
  620. {
  621. ScriptableRendererData data = CreateRendererData(type);
  622. string dataPath;
  623. if (relativePath)
  624. dataPath =
  625. $"{Path.Combine(Path.GetDirectoryName(path), Path.GetFileNameWithoutExtension(path))}_{suffix}{Path.GetExtension(path)}";
  626. else
  627. dataPath = path;
  628. AssetDatabase.CreateAsset(data, dataPath);
  629. ResourceReloader.ReloadAllNullIn(data, packagePath);
  630. return data;
  631. }
  632. static ScriptableRendererData CreateRendererData(RendererType type)
  633. {
  634. switch (type)
  635. {
  636. case RendererType.UniversalRenderer:
  637. default:
  638. {
  639. var rendererData = CreateInstance<UniversalRendererData>();
  640. rendererData.postProcessData = PostProcessData.GetDefaultPostProcessData();
  641. return rendererData;
  642. }
  643. }
  644. }
  645. #endif
  646. /// <summary>
  647. /// Use this class to initialize the rendererData element that is required by the renderer.
  648. /// </summary>
  649. /// <param name="type">The <c>RendererType</c> of the new renderer that is initialized within this asset.</param>
  650. /// <returns></returns>
  651. /// <see cref="RendererType"/>
  652. public ScriptableRendererData LoadBuiltinRendererData(RendererType type = RendererType.UniversalRenderer)
  653. {
  654. #if UNITY_EDITOR
  655. EditorUtility.SetDirty(this);
  656. return m_RendererDataList[0] =
  657. CreateRendererAsset("Assets/UniversalRenderer.asset", type, false);
  658. #else
  659. m_RendererDataList[0] = null;
  660. return m_RendererDataList[0];
  661. #endif
  662. }
  663. /// <summary>
  664. /// Ensures Global Settings are ready and registered into GraphicsSettings
  665. /// </summary>
  666. protected override void EnsureGlobalSettings()
  667. {
  668. base.EnsureGlobalSettings();
  669. #if UNITY_EDITOR
  670. UniversalRenderPipelineGlobalSettings.Ensure();
  671. #endif
  672. }
  673. /// <summary>
  674. /// Creates a <c>UniversalRenderPipeline</c> from the <c>UniversalRenderPipelineAsset</c>.
  675. /// </summary>
  676. /// <returns>Returns a <c>UniversalRenderPipeline</c> created from this UniversalRenderPipelineAsset.</returns>
  677. /// <see cref="RenderPipeline"/>
  678. protected override RenderPipeline CreatePipeline()
  679. {
  680. if (m_RendererDataList == null)
  681. m_RendererDataList = new ScriptableRendererData[1];
  682. // If no default data we can't create pipeline instance
  683. if (m_DefaultRendererIndex >= m_RendererDataList.Length || m_RendererDataList[m_DefaultRendererIndex] == null)
  684. {
  685. // If previous version and current version are miss-matched then we are waiting for the upgrader to kick in
  686. if (k_AssetPreviousVersion != k_AssetVersion)
  687. return null;
  688. Debug.LogError(
  689. $"Default Renderer is missing, make sure there is a Renderer assigned as the default on the current Universal RP asset:{UniversalRenderPipeline.asset.name}",
  690. this);
  691. return null;
  692. }
  693. DestroyRenderers();
  694. var pipeline = new UniversalRenderPipeline(this);
  695. CreateRenderers();
  696. IGPUResidentRenderPipeline.ReinitializeGPUResidentDrawer();
  697. return pipeline;
  698. }
  699. internal void DestroyRenderers()
  700. {
  701. if (m_Renderers == null)
  702. return;
  703. for (int i = 0; i < m_Renderers.Length; i++)
  704. DestroyRenderer(ref m_Renderers[i]);
  705. }
  706. void DestroyRenderer(ref ScriptableRenderer renderer)
  707. {
  708. if (renderer != null)
  709. {
  710. renderer.Dispose();
  711. renderer = null;
  712. }
  713. }
  714. /// <summary>
  715. /// Unity calls this function when the asset is disabled.
  716. /// </summary>
  717. protected override void OnDisable()
  718. {
  719. DestroyRenderers();
  720. // This will call RenderPipelineManager.CleanupRenderPipeline that in turn disposes the render pipeline instance and
  721. // assign pipeline asset reference to null
  722. base.OnDisable();
  723. }
  724. void CreateRenderers()
  725. {
  726. if (m_Renderers != null)
  727. {
  728. for (int i = 0; i < m_Renderers.Length; ++i)
  729. {
  730. if (m_Renderers[i] != null)
  731. Debug.LogError($"Creating renderers but previous instance wasn't properly destroyed: m_Renderers[{i}]");
  732. }
  733. }
  734. if (m_Renderers == null || m_Renderers.Length != m_RendererDataList.Length)
  735. m_Renderers = new ScriptableRenderer[m_RendererDataList.Length];
  736. for (int i = 0; i < m_RendererDataList.Length; ++i)
  737. {
  738. if (m_RendererDataList[i] != null)
  739. m_Renderers[i] = m_RendererDataList[i].InternalCreateRenderer();
  740. }
  741. }
  742. /// <summary>
  743. /// Returns the default renderer being used by this pipeline.
  744. /// </summary>
  745. public ScriptableRenderer scriptableRenderer
  746. {
  747. get
  748. {
  749. if (m_RendererDataList?.Length > m_DefaultRendererIndex && m_RendererDataList[m_DefaultRendererIndex] == null)
  750. {
  751. Debug.LogError("Default renderer is missing from the current Pipeline Asset.", this);
  752. return null;
  753. }
  754. if (scriptableRendererData.isInvalidated || m_Renderers[m_DefaultRendererIndex] == null)
  755. {
  756. DestroyRenderer(ref m_Renderers[m_DefaultRendererIndex]);
  757. m_Renderers[m_DefaultRendererIndex] = scriptableRendererData.InternalCreateRenderer();
  758. // GPU Resident Drawer may need to be reinitialized if renderer data has become incompatible/compatible
  759. if (gpuResidentDrawerMode != GPUResidentDrawerMode.Disabled)
  760. {
  761. IGPUResidentRenderPipeline.ReinitializeGPUResidentDrawer();
  762. }
  763. }
  764. return m_Renderers[m_DefaultRendererIndex];
  765. }
  766. }
  767. /// <summary>
  768. /// Returns a renderer from the current pipeline asset
  769. /// </summary>
  770. /// <param name="index">Index to the renderer. If invalid index is passed, the default renderer is returned instead.</param>
  771. /// <returns></returns>
  772. public ScriptableRenderer GetRenderer(int index)
  773. {
  774. if (index == -1)
  775. index = m_DefaultRendererIndex;
  776. if (index >= m_RendererDataList.Length || index < 0 || m_RendererDataList[index] == null)
  777. {
  778. Debug.LogWarning(
  779. $"Renderer at index {index.ToString()} is missing, falling back to Default Renderer {m_RendererDataList[m_DefaultRendererIndex].name}",
  780. this);
  781. index = m_DefaultRendererIndex;
  782. }
  783. // RendererData list differs from RendererList. Create RendererList.
  784. if (m_Renderers == null || m_Renderers.Length < m_RendererDataList.Length)
  785. {
  786. DestroyRenderers();
  787. CreateRenderers();
  788. }
  789. // This renderer data is outdated or invalid, we recreate the renderer
  790. // so we construct all render passes with the updated data
  791. if (m_RendererDataList[index].isInvalidated || m_Renderers[index] == null)
  792. {
  793. DestroyRenderer(ref m_Renderers[index]);
  794. m_Renderers[index] = m_RendererDataList[index].InternalCreateRenderer();
  795. // GPU Resident Drawer may need to be reinitialized if renderer data has become incompatible/compatible
  796. if (gpuResidentDrawerMode != GPUResidentDrawerMode.Disabled)
  797. {
  798. IGPUResidentRenderPipeline.ReinitializeGPUResidentDrawer();
  799. }
  800. }
  801. return m_Renderers[index];
  802. }
  803. internal ScriptableRendererData scriptableRendererData
  804. {
  805. get
  806. {
  807. if (m_RendererDataList[m_DefaultRendererIndex] == null)
  808. CreatePipeline();
  809. return m_RendererDataList[m_DefaultRendererIndex];
  810. }
  811. }
  812. #if UNITY_EDITOR
  813. internal GUIContent[] rendererDisplayList
  814. {
  815. get
  816. {
  817. GUIContent[] list = new GUIContent[m_RendererDataList.Length + 1];
  818. list[0] = new GUIContent($"Default Renderer ({RendererDataDisplayName(m_RendererDataList[m_DefaultRendererIndex])})");
  819. for (var i = 1; i < list.Length; i++)
  820. {
  821. list[i] = new GUIContent($"{(i - 1).ToString()}: {RendererDataDisplayName(m_RendererDataList[i - 1])}");
  822. }
  823. return list;
  824. }
  825. }
  826. string RendererDataDisplayName(ScriptableRendererData data)
  827. {
  828. if (data != null)
  829. return data.name;
  830. return "NULL (Missing RendererData)";
  831. }
  832. #endif
  833. private static GraphicsFormat[][] s_LightCookieFormatList = new GraphicsFormat[][]
  834. {
  835. /* Grayscale Low */ new GraphicsFormat[] {GraphicsFormat.R8_UNorm},
  836. /* Grayscale High*/ new GraphicsFormat[] {GraphicsFormat.R16_UNorm},
  837. /* Color Low */ new GraphicsFormat[] {GraphicsFormat.R5G6B5_UNormPack16, GraphicsFormat.B5G6R5_UNormPack16, GraphicsFormat.R5G5B5A1_UNormPack16, GraphicsFormat.B5G5R5A1_UNormPack16},
  838. /* Color High */ new GraphicsFormat[] {GraphicsFormat.A2B10G10R10_UNormPack32, GraphicsFormat.R8G8B8A8_SRGB, GraphicsFormat.B8G8R8A8_SRGB},
  839. /* Color HDR */ new GraphicsFormat[] {GraphicsFormat.B10G11R11_UFloatPack32},
  840. };
  841. internal GraphicsFormat additionalLightsCookieFormat
  842. {
  843. get
  844. {
  845. GraphicsFormat result = GraphicsFormat.None;
  846. foreach (var format in s_LightCookieFormatList[(int)m_AdditionalLightsCookieFormat])
  847. {
  848. if (SystemInfo.IsFormatSupported(format, GraphicsFormatUsage.Render))
  849. {
  850. result = format;
  851. break;
  852. }
  853. }
  854. if (QualitySettings.activeColorSpace == ColorSpace.Gamma)
  855. result = GraphicsFormatUtility.GetLinearFormat(result);
  856. // Fallback
  857. if (result == GraphicsFormat.None)
  858. {
  859. result = GraphicsFormat.R8G8B8A8_UNorm;
  860. Debug.LogWarning($"Additional Lights Cookie Format ({ m_AdditionalLightsCookieFormat.ToString() }) is not supported by the platform. Falling back to {GraphicsFormatUtility.GetBlockSize(result) * 8}-bit format ({GraphicsFormatUtility.GetFormatString(result)})");
  861. }
  862. return result;
  863. }
  864. }
  865. internal Vector2Int additionalLightsCookieResolution => new Vector2Int((int)m_AdditionalLightsCookieResolution, (int)m_AdditionalLightsCookieResolution);
  866. internal int[] rendererIndexList
  867. {
  868. get
  869. {
  870. int[] list = new int[m_RendererDataList.Length + 1];
  871. for (int i = 0; i < list.Length; i++)
  872. {
  873. list[i] = i - 1;
  874. }
  875. return list;
  876. }
  877. }
  878. /// <summary>
  879. /// When true, the pipeline creates a depth texture that can be read in shaders. The depth texture can be accessed as _CameraDepthTexture. This setting can be overridden per camera.
  880. /// </summary>
  881. public bool supportsCameraDepthTexture
  882. {
  883. get => m_RequireDepthTexture;
  884. set => m_RequireDepthTexture = value;
  885. }
  886. /// <summary>
  887. /// When true, the pipeline creates a texture that contains a copy of the color buffer after rendering opaque objects. This texture can be accessed in shaders as _CameraOpaqueTexture. This setting can be overridden per camera.
  888. /// </summary>
  889. public bool supportsCameraOpaqueTexture
  890. {
  891. get => m_RequireOpaqueTexture;
  892. set => m_RequireOpaqueTexture = value;
  893. }
  894. /// <summary>
  895. /// Returns the downsampling method used when copying the camera color texture after rendering opaques.
  896. /// </summary>
  897. public Downsampling opaqueDownsampling => m_OpaqueDownsampling;
  898. /// <summary>
  899. /// This settings controls if the asset <c>UniversalRenderPipelineAsset</c> supports terrain holes.
  900. /// </summary>
  901. /// <see href="https://docs.unity3d.com/Manual/terrain-PaintHoles.html"/>
  902. public bool supportsTerrainHoles => m_SupportsTerrainHoles;
  903. /// <summary>
  904. /// Returns the active store action optimization value.
  905. /// </summary>
  906. /// <returns>Returns the active store action optimization value.</returns>
  907. public StoreActionsOptimization storeActionsOptimization
  908. {
  909. get => m_StoreActionsOptimization;
  910. set => m_StoreActionsOptimization = value;
  911. }
  912. /// <summary>
  913. /// When enabled, the camera renders to HDR buffers. This setting can be overridden per camera.
  914. /// </summary>
  915. /// <see href="https://docs.unity3d.com/Manual/HDR.html"/>
  916. public bool supportsHDR
  917. {
  918. get => m_SupportsHDR;
  919. set => m_SupportsHDR = value;
  920. }
  921. /// <summary>
  922. /// Graphics format requested for HDR color buffers.
  923. /// </summary>
  924. public HDRColorBufferPrecision hdrColorBufferPrecision
  925. {
  926. get => m_HDRColorBufferPrecision;
  927. set => m_HDRColorBufferPrecision = value;
  928. }
  929. /// <summary>
  930. /// Specifies the msaa sample count used by this <c>UniversalRenderPipelineAsset</c>
  931. /// </summary>
  932. /// <see cref="MsaaQuality"/>
  933. public int msaaSampleCount
  934. {
  935. get => (int)m_MSAA;
  936. set => m_MSAA = (MsaaQuality)value;
  937. }
  938. /// <summary>
  939. /// Specifies the render scale which scales the render target resolution used by this <c>UniversalRenderPipelineAsset</c>.
  940. /// </summary>
  941. public float renderScale
  942. {
  943. get => m_RenderScale;
  944. set => m_RenderScale = ValidateRenderScale(value);
  945. }
  946. /// <summary>
  947. /// Returns true if the cross-fade style blending between the current LOD and the next LOD is enabled.
  948. /// </summary>
  949. public bool enableLODCrossFade => m_EnableLODCrossFade;
  950. /// <summary>
  951. /// Returns the type of active LOD cross-fade.
  952. /// </summary>
  953. public LODCrossFadeDitheringType lodCrossFadeDitheringType => m_LODCrossFadeDitheringType;
  954. /// <summary>
  955. /// Returns the upscaling filter desired by the user
  956. /// Note: Filter selections differ from actual filters in that they may include "meta-filters" such as
  957. /// "Automatic" which resolve to an actual filter at a later time.
  958. /// </summary>
  959. public UpscalingFilterSelection upscalingFilter
  960. {
  961. get => m_UpscalingFilter;
  962. set => m_UpscalingFilter = value;
  963. }
  964. /// <summary>
  965. /// If this property is set to true, the value from the fsrSharpness property will control the intensity of the
  966. /// sharpening filter associated with FidelityFX Super Resolution.
  967. /// </summary>
  968. public bool fsrOverrideSharpness
  969. {
  970. get => m_FsrOverrideSharpness;
  971. set => m_FsrOverrideSharpness = value;
  972. }
  973. /// <summary>
  974. /// Controls the intensity of the sharpening filter associated with FidelityFX Super Resolution.
  975. /// A value of 1.0 produces maximum sharpness while a value of 0.0 disables the sharpening filter entirely.
  976. ///
  977. /// Note: This value only has an effect when the fsrOverrideSharpness property is set to true.
  978. /// </summary>
  979. public float fsrSharpness
  980. {
  981. get => m_FsrSharpness;
  982. set => m_FsrSharpness = value;
  983. }
  984. /// <summary>
  985. /// Defines the type of Spherical Harmonic (SH) evaluation in lighting.
  986. /// </summary>
  987. public ShEvalMode shEvalMode
  988. {
  989. get => m_ShEvalMode;
  990. internal set => m_ShEvalMode = value;
  991. }
  992. /// <summary>
  993. /// Determines what system to use.
  994. /// </summary>
  995. public LightProbeSystem lightProbeSystem
  996. {
  997. get => m_LightProbeSystem;
  998. internal set => m_LightProbeSystem = value;
  999. }
  1000. /// <summary>
  1001. /// Probe Volume Memory Budget.
  1002. /// </summary>
  1003. public ProbeVolumeTextureMemoryBudget probeVolumeMemoryBudget
  1004. {
  1005. get => m_ProbeVolumeMemoryBudget;
  1006. internal set => m_ProbeVolumeMemoryBudget = value;
  1007. }
  1008. /// <summary>
  1009. /// Probe Volume Blending Memory Budget.
  1010. /// </summary>
  1011. public ProbeVolumeBlendingTextureMemoryBudget probeVolumeBlendingMemoryBudget
  1012. {
  1013. get => m_ProbeVolumeBlendingMemoryBudget;
  1014. internal set => m_ProbeVolumeBlendingMemoryBudget = value;
  1015. }
  1016. /// <summary>
  1017. /// Support GPU Streaming for Probe Volumes.
  1018. /// </summary>
  1019. [Obsolete( "This is obsolete, use supportProbeVolumeGPUStreaming instead.")]
  1020. public bool supportProbeVolumeStreaming
  1021. {
  1022. get => m_SupportProbeVolumeGPUStreaming;
  1023. internal set => m_SupportProbeVolumeGPUStreaming = value;
  1024. }
  1025. /// <summary>
  1026. /// Support GPU Streaming for Probe Volumes.
  1027. /// </summary>
  1028. public bool supportProbeVolumeGPUStreaming
  1029. {
  1030. get => m_SupportProbeVolumeGPUStreaming;
  1031. internal set => m_SupportProbeVolumeGPUStreaming = value;
  1032. }
  1033. /// <summary>
  1034. /// Support Disk Streaming for Probe Volumes.
  1035. /// </summary>
  1036. public bool supportProbeVolumeDiskStreaming
  1037. {
  1038. get => m_SupportProbeVolumeDiskStreaming;
  1039. internal set => m_SupportProbeVolumeDiskStreaming = value;
  1040. }
  1041. /// <summary>
  1042. /// Support Lighting Scenario Baking for Probe Volumes.
  1043. /// </summary>
  1044. public bool supportProbeVolumeScenarios
  1045. {
  1046. get { return m_SupportProbeVolumeScenarios; }
  1047. internal set { m_SupportProbeVolumeScenarios = value; }
  1048. }
  1049. /// <summary>
  1050. /// Support Lighting Scenario Blending for Probe Volumes.
  1051. /// </summary>
  1052. public bool supportProbeVolumeScenarioBlending
  1053. {
  1054. get { return m_SupportProbeVolumeScenarioBlending; }
  1055. internal set { m_SupportProbeVolumeScenarioBlending = value; }
  1056. }
  1057. /// <summary>
  1058. /// Probe Volumes SH Bands.
  1059. /// </summary>
  1060. public ProbeVolumeSHBands probeVolumeSHBands
  1061. {
  1062. get => m_ProbeVolumeSHBands;
  1063. internal set => m_ProbeVolumeSHBands = value;
  1064. }
  1065. /// <summary>
  1066. /// Specifies the <c>LightRenderingMode</c> for the main light used by this <c>UniversalRenderPipelineAsset</c>.
  1067. /// </summary>
  1068. /// <see cref="LightRenderingMode"/>
  1069. public LightRenderingMode mainLightRenderingMode
  1070. {
  1071. get => m_MainLightRenderingMode;
  1072. internal set => m_MainLightRenderingMode = value;
  1073. }
  1074. /// <summary>
  1075. /// Specifies if objects lit by main light cast shadows.
  1076. /// </summary>
  1077. public bool supportsMainLightShadows
  1078. {
  1079. get => m_MainLightShadowsSupported;
  1080. internal set
  1081. {
  1082. m_MainLightShadowsSupported = value;
  1083. #if UNITY_EDITOR
  1084. m_AnyShadowsSupported = m_MainLightShadowsSupported || m_AdditionalLightShadowsSupported;
  1085. #endif
  1086. }
  1087. }
  1088. /// <summary>
  1089. /// Returns the main light shadowmap resolution used for this <c>UniversalRenderPipelineAsset</c>.
  1090. /// </summary>
  1091. public int mainLightShadowmapResolution
  1092. {
  1093. get => (int)m_MainLightShadowmapResolution;
  1094. set => m_MainLightShadowmapResolution = (ShadowResolution)value;
  1095. }
  1096. /// <summary>
  1097. /// Specifies the <c>LightRenderingMode</c> for the additional lights used by this <c>UniversalRenderPipelineAsset</c>.
  1098. /// </summary>
  1099. /// <see cref="LightRenderingMode"/>
  1100. public LightRenderingMode additionalLightsRenderingMode
  1101. {
  1102. get => m_AdditionalLightsRenderingMode;
  1103. internal set => m_AdditionalLightsRenderingMode = value;
  1104. }
  1105. /// <summary>
  1106. /// Specifies the maximum amount of per-object additional lights which can be used by this <c>UniversalRenderPipelineAsset</c>.
  1107. /// </summary>
  1108. public int maxAdditionalLightsCount
  1109. {
  1110. get => m_AdditionalLightsPerObjectLimit;
  1111. set => m_AdditionalLightsPerObjectLimit = ValidatePerObjectLights(value);
  1112. }
  1113. /// <summary>
  1114. /// Specifies if objects lit by additional lights cast shadows.
  1115. /// </summary>
  1116. public bool supportsAdditionalLightShadows
  1117. {
  1118. get => m_AdditionalLightShadowsSupported;
  1119. internal set
  1120. {
  1121. m_AdditionalLightShadowsSupported = value;
  1122. #if UNITY_EDITOR
  1123. m_AnyShadowsSupported = m_MainLightShadowsSupported || m_AdditionalLightShadowsSupported;
  1124. #endif
  1125. }
  1126. }
  1127. /// <summary>
  1128. /// Additional light shadows are rendered into a single shadow map atlas texture. This setting controls the resolution of the shadow map atlas texture.
  1129. /// </summary>
  1130. public int additionalLightsShadowmapResolution
  1131. {
  1132. get => (int)m_AdditionalLightsShadowmapResolution;
  1133. set => m_AdditionalLightsShadowmapResolution = (ShadowResolution)value;
  1134. }
  1135. /// <summary>
  1136. /// Returns the additional light shadow resolution defined for tier "Low" in the UniversalRenderPipeline asset.
  1137. /// </summary>
  1138. public int additionalLightsShadowResolutionTierLow
  1139. {
  1140. get => m_AdditionalLightsShadowResolutionTierLow;
  1141. internal set => m_AdditionalLightsShadowResolutionTierLow = value;
  1142. }
  1143. /// <summary>
  1144. /// Returns the additional light shadow resolution defined for tier "Medium" in the UniversalRenderPipeline asset.
  1145. /// </summary>
  1146. public int additionalLightsShadowResolutionTierMedium
  1147. {
  1148. get => m_AdditionalLightsShadowResolutionTierMedium;
  1149. internal set => m_AdditionalLightsShadowResolutionTierMedium = value;
  1150. }
  1151. /// <summary>
  1152. /// Returns the additional light shadow resolution defined for tier "High" in the UniversalRenderPipeline asset.
  1153. /// </summary>
  1154. public int additionalLightsShadowResolutionTierHigh
  1155. {
  1156. get => m_AdditionalLightsShadowResolutionTierHigh;
  1157. internal set => m_AdditionalLightsShadowResolutionTierHigh = value;
  1158. }
  1159. internal int GetAdditionalLightsShadowResolution(int additionalLightsShadowResolutionTier)
  1160. {
  1161. if (additionalLightsShadowResolutionTier <= UniversalAdditionalLightData.AdditionalLightsShadowResolutionTierLow /* 0 */)
  1162. return additionalLightsShadowResolutionTierLow;
  1163. if (additionalLightsShadowResolutionTier == UniversalAdditionalLightData.AdditionalLightsShadowResolutionTierMedium /* 1 */)
  1164. return additionalLightsShadowResolutionTierMedium;
  1165. if (additionalLightsShadowResolutionTier >= UniversalAdditionalLightData.AdditionalLightsShadowResolutionTierHigh /* 2 */)
  1166. return additionalLightsShadowResolutionTierHigh;
  1167. return additionalLightsShadowResolutionTierMedium;
  1168. }
  1169. /// <summary>
  1170. /// Specifies if this <c>UniversalRenderPipelineAsset</c> should use Probe blending for the reflection probes in the scene.
  1171. /// </summary>
  1172. public bool reflectionProbeBlending
  1173. {
  1174. get => m_ReflectionProbeBlending;
  1175. internal set => m_ReflectionProbeBlending = value;
  1176. }
  1177. /// <summary>
  1178. /// Specifies if this <c>UniversalRenderPipelineAsset</c> should allow box projection for the reflection probes in the scene.
  1179. /// </summary>
  1180. public bool reflectionProbeBoxProjection
  1181. {
  1182. get => m_ReflectionProbeBoxProjection;
  1183. internal set => m_ReflectionProbeBoxProjection = value;
  1184. }
  1185. /// <summary>
  1186. /// Controls the maximum distance at which shadows are visible.
  1187. /// </summary>
  1188. public float shadowDistance
  1189. {
  1190. get => m_ShadowDistance;
  1191. set => m_ShadowDistance = Mathf.Max(0.0f, value);
  1192. }
  1193. /// <summary>
  1194. /// Returns the number of shadow cascades.
  1195. /// </summary>
  1196. public int shadowCascadeCount
  1197. {
  1198. get => m_ShadowCascadeCount;
  1199. set
  1200. {
  1201. if (value < k_ShadowCascadeMinCount || value > k_ShadowCascadeMaxCount)
  1202. {
  1203. throw new ArgumentException($"Value ({value}) needs to be between {k_ShadowCascadeMinCount} and {k_ShadowCascadeMaxCount}.");
  1204. }
  1205. m_ShadowCascadeCount = value;
  1206. }
  1207. }
  1208. /// <summary>
  1209. /// Returns the split value.
  1210. /// </summary>
  1211. /// <returns>Returns a Float with the split value.</returns>
  1212. public float cascade2Split
  1213. {
  1214. get => m_Cascade2Split;
  1215. set => m_Cascade2Split = value;
  1216. }
  1217. /// <summary>
  1218. /// Returns the split values.
  1219. /// </summary>
  1220. /// <returns>Returns a Vector2 with the split values.</returns>
  1221. public Vector2 cascade3Split
  1222. {
  1223. get => m_Cascade3Split;
  1224. set => m_Cascade3Split = value;
  1225. }
  1226. /// <summary>
  1227. /// Returns the split values.
  1228. /// </summary>
  1229. /// <returns>Returns a Vector3 with the split values.</returns>
  1230. public Vector3 cascade4Split
  1231. {
  1232. get => m_Cascade4Split;
  1233. set => m_Cascade4Split = value;
  1234. }
  1235. /// <summary>
  1236. /// Last cascade fade distance in percentage.
  1237. /// </summary>
  1238. public float cascadeBorder
  1239. {
  1240. get => m_CascadeBorder;
  1241. set => m_CascadeBorder = value;
  1242. }
  1243. /// <summary>
  1244. /// The Shadow Depth Bias, controls the offset of the lit pixels.
  1245. /// </summary>
  1246. public float shadowDepthBias
  1247. {
  1248. get => m_ShadowDepthBias;
  1249. set => m_ShadowDepthBias = ValidateShadowBias(value);
  1250. }
  1251. /// <summary>
  1252. /// Controls the distance at which the shadow casting surfaces are shrunk along the surface normal.
  1253. /// </summary>
  1254. public float shadowNormalBias
  1255. {
  1256. get => m_ShadowNormalBias;
  1257. set => m_ShadowNormalBias = ValidateShadowBias(value);
  1258. }
  1259. /// <summary>
  1260. /// Supports Soft Shadows controls the Soft Shadows.
  1261. /// </summary>
  1262. public bool supportsSoftShadows
  1263. {
  1264. get => m_SoftShadowsSupported;
  1265. internal set => m_SoftShadowsSupported = value;
  1266. }
  1267. /// <summary>
  1268. /// Light default Soft Shadow Quality.
  1269. /// </summary>
  1270. internal SoftShadowQuality softShadowQuality
  1271. {
  1272. get => m_SoftShadowQuality;
  1273. set => m_SoftShadowQuality = value;
  1274. }
  1275. /// <summary>
  1276. /// Specifies if this <c>UniversalRenderPipelineAsset</c> should use dynamic batching.
  1277. /// </summary>
  1278. /// <see href="https://docs.unity3d.com/Manual/DrawCallBatching.html"/>
  1279. public bool supportsDynamicBatching
  1280. {
  1281. get => m_SupportsDynamicBatching;
  1282. set => m_SupportsDynamicBatching = value;
  1283. }
  1284. /// <summary>
  1285. /// Returns true if the Render Pipeline Asset supports mixed lighting, false otherwise.
  1286. /// </summary>
  1287. /// <see href="https://docs.unity3d.com/Manual/LightMode-Mixed.html"/>
  1288. public bool supportsMixedLighting => m_MixedLightingSupported;
  1289. /// <summary>
  1290. /// Returns true if the Render Pipeline Asset supports light cookies, false otherwise.
  1291. /// </summary>
  1292. public bool supportsLightCookies => m_SupportsLightCookies;
  1293. /// <summary>
  1294. /// Returns true if the Render Pipeline Asset supports light layers, false otherwise.
  1295. /// </summary>
  1296. [Obsolete("This is obsolete, use useRenderingLayers instead.", true)]
  1297. public bool supportsLightLayers => m_SupportsLightLayers;
  1298. /// <summary>
  1299. /// Returns true if the Render Pipeline Asset supports rendering layers for lights, false otherwise.
  1300. /// </summary>
  1301. public bool useRenderingLayers => m_SupportsLightLayers;
  1302. /// <summary>
  1303. /// Returns the selected update mode for volumes.
  1304. /// </summary>
  1305. public VolumeFrameworkUpdateMode volumeFrameworkUpdateMode => m_VolumeFrameworkUpdateMode;
  1306. /// <summary>
  1307. /// A volume profile that can be used to override global default volume profile values. This provides a way e.g.
  1308. /// to have different volume default values per quality level without having to place global volumes in scenes.
  1309. /// </summary>
  1310. public VolumeProfile volumeProfile
  1311. {
  1312. get => m_VolumeProfile;
  1313. set => m_VolumeProfile = value;
  1314. }
  1315. /// <summary>
  1316. /// Previously returned the debug level for this Render Pipeline Asset but is now deprecated. Replaced to use the profiler and is no longer used.
  1317. /// </summary>
  1318. [Obsolete("PipelineDebugLevel is deprecated and replaced to use the profiler. Calling debugLevel is not necessary.", true)]
  1319. public PipelineDebugLevel debugLevel => PipelineDebugLevel.Disabled;
  1320. /// <summary>
  1321. /// Specifies if SRPBacher is used by this <c>UniversalRenderPipelineAsset</c>.
  1322. /// </summary>
  1323. /// <see href="https://docs.unity3d.com/Manual/SRPBatcher.html"/>
  1324. public bool useSRPBatcher
  1325. {
  1326. get => m_UseSRPBatcher;
  1327. set => m_UseSRPBatcher = value;
  1328. }
  1329. /// <summary>
  1330. /// Controls whether the RenderGraph render path is enabled.
  1331. /// </summary>
  1332. [Obsolete("This has been deprecated, please use GraphicsSettings.GetRenderPipelineSettings<RenderGraphSettings>().enableRenderCompatibilityMode instead.")]
  1333. public bool enableRenderGraph
  1334. {
  1335. get
  1336. {
  1337. if (RenderGraphGraphicsAutomatedTests.enabled)
  1338. return true;
  1339. if (GraphicsSettings.TryGetRenderPipelineSettings<RenderGraphSettings>(out var renderGraphSettings))
  1340. return !renderGraphSettings.enableRenderCompatibilityMode;
  1341. return false;
  1342. }
  1343. }
  1344. internal void OnEnableRenderGraphChanged()
  1345. {
  1346. OnValidate();
  1347. }
  1348. /// <summary>
  1349. /// Returns the selected ColorGradingMode in the URP Asset.
  1350. /// <see cref="ColorGradingMode"/>
  1351. /// </summary>
  1352. public ColorGradingMode colorGradingMode
  1353. {
  1354. get => m_ColorGradingMode;
  1355. set => m_ColorGradingMode = value;
  1356. }
  1357. /// <summary>
  1358. /// Specifies the color grading LUT (lookup table) size in the URP Asset.
  1359. /// </summary>
  1360. public int colorGradingLutSize
  1361. {
  1362. get => m_ColorGradingLutSize;
  1363. set => m_ColorGradingLutSize = Mathf.Clamp(value, k_MinLutSize, k_MaxLutSize);
  1364. }
  1365. /// <summary>
  1366. /// Returns true if post-processing should process and output alpha. Requires the color target to have an alpha channel.
  1367. /// </summary>
  1368. public bool allowPostProcessAlphaOutput => m_AllowPostProcessAlphaOutput;
  1369. /// <summary>
  1370. /// Returns true if fast approximation functions are used when converting between the sRGB and Linear color spaces, false otherwise.
  1371. /// </summary>
  1372. public bool useFastSRGBLinearConversion => m_UseFastSRGBLinearConversion;
  1373. /// <summary>
  1374. /// Returns true if Screen Space Lens Flare are supported by this asset, false otherwise.
  1375. /// </summary>
  1376. public bool supportScreenSpaceLensFlare => m_SupportScreenSpaceLensFlare;
  1377. /// <summary>
  1378. /// Returns true if Data Driven Lens Flare are supported by this asset, false otherwise.
  1379. /// </summary>
  1380. public bool supportDataDrivenLensFlare => m_SupportDataDrivenLensFlare;
  1381. /// <summary>
  1382. /// Set to true to allow Adaptive performance to modify graphics quality settings during runtime.
  1383. /// Only applicable when Adaptive performance package is available.
  1384. /// </summary>
  1385. public bool useAdaptivePerformance
  1386. {
  1387. get => m_UseAdaptivePerformance;
  1388. set => m_UseAdaptivePerformance = value;
  1389. }
  1390. /// <summary>
  1391. /// Set to true to enable a conservative method for calculating the size and position of the minimal enclosing sphere around the frustum cascade corner points for shadow culling.
  1392. /// </summary>
  1393. public bool conservativeEnclosingSphere
  1394. {
  1395. get => m_ConservativeEnclosingSphere;
  1396. set => m_ConservativeEnclosingSphere = value;
  1397. }
  1398. /// <summary>
  1399. /// Set the number of iterations to reduce the cascade culling enlcosing sphere to be closer to the absolute minimun enclosing sphere, but will also require more CPU computation for increasing values.
  1400. /// This parameter is used only when conservativeEnclosingSphere is set to true. Default value is 64.
  1401. /// </summary>
  1402. public int numIterationsEnclosingSphere
  1403. {
  1404. get => m_NumIterationsEnclosingSphere;
  1405. set => m_NumIterationsEnclosingSphere = value;
  1406. }
  1407. /// <inheritdoc/>
  1408. public override string renderPipelineShaderTag => UniversalRenderPipeline.k_ShaderTagName;
  1409. /// <summary>Names used for display of rendering layer masks.</summary>
  1410. [Obsolete("This property is obsolete. Use RenderingLayerMask API and Tags & Layers project settings instead. #from(23.3)", false)]
  1411. public override string[] renderingLayerMaskNames => RenderingLayerMask.GetDefinedRenderingLayerNames();
  1412. /// <summary>Names used for display of rendering layer masks with prefix.</summary>
  1413. [Obsolete("This property is obsolete. Use RenderingLayerMask API and Tags & Layers project settings instead. #from(23.3)", false)]
  1414. public override string[] prefixedRenderingLayerMaskNames => Array.Empty<string>();
  1415. /// <summary>
  1416. /// Names used for display of light layers.
  1417. /// </summary>
  1418. [Obsolete("This is obsolete, please use renderingLayerMaskNames instead.", true)]
  1419. public string[] lightLayerMaskNames => new string[0];
  1420. /// <summary>
  1421. /// GPUResidentDrawerMode configured on this pipeline asset
  1422. /// </summary>
  1423. public GPUResidentDrawerMode gpuResidentDrawerMode
  1424. {
  1425. get => m_GPUResidentDrawerMode;
  1426. set
  1427. {
  1428. if (value == m_GPUResidentDrawerMode)
  1429. return;
  1430. m_GPUResidentDrawerMode = value;
  1431. OnValidate();
  1432. }
  1433. }
  1434. /// <summary>
  1435. /// Determines if the GPU Resident Drawer should perform occlusion culling in camera views
  1436. /// </summary>
  1437. public bool gpuResidentDrawerEnableOcclusionCullingInCameras
  1438. {
  1439. get => m_GPUResidentDrawerEnableOcclusionCullingInCameras;
  1440. set
  1441. {
  1442. if (value == m_GPUResidentDrawerEnableOcclusionCullingInCameras)
  1443. return;
  1444. m_GPUResidentDrawerEnableOcclusionCullingInCameras = value;
  1445. OnValidate();
  1446. }
  1447. }
  1448. static class Strings
  1449. {
  1450. public static readonly string notURPRenderer = $"{nameof(GPUResidentDrawer)} Disabled due to some configured Universal Renderers not being {nameof(UniversalRendererData)}.";
  1451. public static readonly string forwardPlusMissing = $"{nameof(GPUResidentDrawer)} Disabled due to some configured Universal Renderers not supporting Forward+.";
  1452. }
  1453. /// <inheritdoc/>
  1454. public bool IsGPUResidentDrawerSupportedBySRP(out string message, out LogType severty)
  1455. {
  1456. message = string.Empty;
  1457. severty = LogType.Warning;
  1458. // if any of the renderers are not set to Forward+ return false
  1459. foreach (var rendererData in m_RendererDataList)
  1460. {
  1461. if (rendererData is not UniversalRendererData universalRendererData)
  1462. {
  1463. message = Strings.notURPRenderer;
  1464. return false;
  1465. }
  1466. if (universalRendererData.renderingMode == RenderingMode.ForwardPlus)
  1467. continue;
  1468. message = Strings.forwardPlusMissing;
  1469. return false;
  1470. }
  1471. return true;
  1472. }
  1473. /// <summary>
  1474. /// Default minimum screen percentage (0-20%) gpu-driven Renderers can cover before getting culled.
  1475. /// </summary>
  1476. public float smallMeshScreenPercentage
  1477. {
  1478. get => m_SmallMeshScreenPercentage;
  1479. set
  1480. {
  1481. if (Math.Abs(value - m_SmallMeshScreenPercentage) < float.Epsilon)
  1482. return;
  1483. m_SmallMeshScreenPercentage = Mathf.Clamp(value, 0.0f, 20.0f);
  1484. OnValidate();
  1485. }
  1486. }
  1487. /// <summary>
  1488. /// Unity raises a callback to this method before it serializes the asset.
  1489. /// </summary>
  1490. public void OnBeforeSerialize()
  1491. {
  1492. }
  1493. /// <summary>
  1494. /// Unity raises a callback to this method after it deserializes the asset.
  1495. /// </summary>
  1496. public void OnAfterDeserialize()
  1497. {
  1498. if (k_AssetVersion < 3)
  1499. {
  1500. m_SoftShadowsSupported = (m_ShadowType == ShadowQuality.SoftShadows);
  1501. k_AssetPreviousVersion = k_AssetVersion;
  1502. k_AssetVersion = 3;
  1503. }
  1504. if (k_AssetVersion < 4)
  1505. {
  1506. m_AdditionalLightShadowsSupported = m_LocalShadowsSupported;
  1507. m_AdditionalLightsShadowmapResolution = m_LocalShadowsAtlasResolution;
  1508. m_AdditionalLightsPerObjectLimit = m_MaxPixelLights;
  1509. m_MainLightShadowmapResolution = m_ShadowAtlasResolution;
  1510. k_AssetPreviousVersion = k_AssetVersion;
  1511. k_AssetVersion = 4;
  1512. }
  1513. if (k_AssetVersion < 5)
  1514. {
  1515. if (m_RendererType == RendererType.Custom)
  1516. {
  1517. #pragma warning disable 618 // Obsolete warning
  1518. m_RendererDataList[0] = m_RendererData;
  1519. #pragma warning restore 618 // Obsolete warning
  1520. }
  1521. k_AssetPreviousVersion = k_AssetVersion;
  1522. k_AssetVersion = 5;
  1523. }
  1524. if (k_AssetVersion < 6)
  1525. {
  1526. #pragma warning disable 618 // Obsolete warning
  1527. // Adding an upgrade here so that if it was previously set to 2 it meant 4 cascades.
  1528. // So adding a 3rd cascade shifted this value up 1.
  1529. int value = (int)m_ShadowCascades;
  1530. if (value == 2)
  1531. {
  1532. m_ShadowCascadeCount = 4;
  1533. }
  1534. else
  1535. {
  1536. m_ShadowCascadeCount = value + 1;
  1537. }
  1538. k_AssetVersion = 6;
  1539. #pragma warning restore 618 // Obsolete warning
  1540. }
  1541. if (k_AssetVersion < 7)
  1542. {
  1543. k_AssetPreviousVersion = k_AssetVersion;
  1544. k_AssetVersion = 7;
  1545. }
  1546. if (k_AssetVersion < 8)
  1547. {
  1548. k_AssetPreviousVersion = k_AssetVersion;
  1549. m_CascadeBorder = 0.1f; // In previous version we had this hard coded
  1550. k_AssetVersion = 8;
  1551. }
  1552. if (k_AssetVersion < 9)
  1553. {
  1554. bool assetContainsCustomAdditionalLightShadowResolutions =
  1555. m_AdditionalLightsShadowResolutionTierHigh != AdditionalLightsDefaultShadowResolutionTierHigh ||
  1556. m_AdditionalLightsShadowResolutionTierMedium != AdditionalLightsDefaultShadowResolutionTierMedium ||
  1557. m_AdditionalLightsShadowResolutionTierLow != AdditionalLightsDefaultShadowResolutionTierLow;
  1558. if (!assetContainsCustomAdditionalLightShadowResolutions)
  1559. {
  1560. // if all resolutions are still the default values, we assume that they have never been customized and that it is safe to upgrade them to fit better the Additional Lights Shadow Atlas size
  1561. m_AdditionalLightsShadowResolutionTierHigh = (int)m_AdditionalLightsShadowmapResolution;
  1562. m_AdditionalLightsShadowResolutionTierMedium = Mathf.Max(m_AdditionalLightsShadowResolutionTierHigh / 2, UniversalAdditionalLightData.AdditionalLightsShadowMinimumResolution);
  1563. m_AdditionalLightsShadowResolutionTierLow = Mathf.Max(m_AdditionalLightsShadowResolutionTierMedium / 2, UniversalAdditionalLightData.AdditionalLightsShadowMinimumResolution);
  1564. }
  1565. k_AssetPreviousVersion = k_AssetVersion;
  1566. k_AssetVersion = 9;
  1567. }
  1568. if (k_AssetVersion < 10)
  1569. {
  1570. k_AssetPreviousVersion = k_AssetVersion;
  1571. k_AssetVersion = 10;
  1572. }
  1573. if (k_AssetVersion < 11)
  1574. {
  1575. k_AssetPreviousVersion = k_AssetVersion;
  1576. k_AssetVersion = 11;
  1577. }
  1578. if (k_AssetVersion < 12)
  1579. {
  1580. k_AssetPreviousVersion = k_AssetVersion;
  1581. k_AssetVersion = 12;
  1582. }
  1583. #if UNITY_EDITOR
  1584. if (k_AssetPreviousVersion != k_AssetVersion)
  1585. {
  1586. EditorApplication.delayCall += () => UpgradeAsset(this.GetInstanceID());
  1587. }
  1588. #endif
  1589. }
  1590. #if UNITY_EDITOR
  1591. static void UpgradeAsset(int assetInstanceID)
  1592. {
  1593. UniversalRenderPipelineAsset asset = EditorUtility.InstanceIDToObject(assetInstanceID) as UniversalRenderPipelineAsset;
  1594. if (asset.k_AssetPreviousVersion < 5)
  1595. {
  1596. if (asset.m_RendererType == RendererType.UniversalRenderer)
  1597. {
  1598. var data = AssetDatabase.LoadAssetAtPath<UniversalRendererData>("Assets/UniversalRenderer.asset");
  1599. if (data)
  1600. {
  1601. asset.m_RendererDataList[0] = data;
  1602. }
  1603. else
  1604. {
  1605. asset.LoadBuiltinRendererData();
  1606. }
  1607. #pragma warning disable 618 // Obsolete warning
  1608. asset.m_RendererData = null; // Clears the old renderer
  1609. #pragma warning restore 618 // Obsolete warning
  1610. }
  1611. asset.k_AssetPreviousVersion = 5;
  1612. }
  1613. if (asset.k_AssetPreviousVersion < 9)
  1614. {
  1615. // The added feature was reverted, we keep this version to avoid breakage in case somebody already has version 7
  1616. asset.k_AssetPreviousVersion = 9;
  1617. }
  1618. if (asset.k_AssetPreviousVersion < 10)
  1619. {
  1620. #pragma warning disable 618 // Obsolete warning
  1621. var instance = UniversalRenderPipelineGlobalSettings.Ensure();
  1622. instance.m_ShaderVariantLogLevel = (Rendering.ShaderVariantLogLevel) asset.m_ShaderVariantLogLevel;
  1623. #pragma warning restore 618 // Obsolete warning
  1624. asset.k_AssetPreviousVersion = 10;
  1625. }
  1626. if (asset.k_AssetPreviousVersion < 11)
  1627. {
  1628. asset.k_AssetPreviousVersion = 11;
  1629. }
  1630. if (asset.k_AssetPreviousVersion < 12)
  1631. {
  1632. var globalSettings = UniversalRenderPipelineGlobalSettings.Ensure();
  1633. #pragma warning disable CS0618 // Type or member is obsolete
  1634. if (asset.apvScenesData != null)
  1635. globalSettings.apvScenesData = asset.apvScenesData;
  1636. #pragma warning restore CS0618 // Type or member is obsolete
  1637. asset.k_AssetPreviousVersion = 12;
  1638. }
  1639. ResourceReloader.ReloadAllNullIn(asset, packagePath);
  1640. EditorUtility.SetDirty(asset);
  1641. }
  1642. #endif
  1643. float ValidateShadowBias(float value)
  1644. {
  1645. return Mathf.Max(0.0f, Mathf.Min(value, UniversalRenderPipeline.maxShadowBias));
  1646. }
  1647. int ValidatePerObjectLights(int value)
  1648. {
  1649. return System.Math.Max(0, System.Math.Min(value, UniversalRenderPipeline.maxPerObjectLights));
  1650. }
  1651. float ValidateRenderScale(float value)
  1652. {
  1653. return Mathf.Max(UniversalRenderPipeline.minRenderScale, Mathf.Min(value, UniversalRenderPipeline.maxRenderScale));
  1654. }
  1655. /// <summary>
  1656. /// Check to see if the RendererData list contains valid RendererData references.
  1657. /// </summary>
  1658. /// <param name="partial">This bool controls whether to test against all or any, if false then there has to be no invalid RendererData</param>
  1659. /// <returns></returns>
  1660. internal bool ValidateRendererDataList(bool partial = false)
  1661. {
  1662. var emptyEntries = 0;
  1663. for (int i = 0; i < m_RendererDataList.Length; i++) emptyEntries += ValidateRendererData(i) ? 0 : 1;
  1664. if (partial)
  1665. return emptyEntries == 0;
  1666. return emptyEntries != m_RendererDataList.Length;
  1667. }
  1668. internal bool ValidateRendererData(int index)
  1669. {
  1670. // Check to see if you are asking for the default renderer
  1671. if (index == -1) index = m_DefaultRendererIndex;
  1672. return index < m_RendererDataList.Length ? m_RendererDataList[index] != null : false;
  1673. }
  1674. #region APV
  1675. [SerializeField, Obsolete("Kept for migration. #from(2023.3")]
  1676. internal ProbeVolumeSceneData apvScenesData;
  1677. #endregion
  1678. /// <summary>
  1679. /// Indicates if this render pipeline instance supports Adaptive Probe Volume.
  1680. /// </summary>
  1681. public bool supportProbeVolume
  1682. {
  1683. get => lightProbeSystem == LightProbeSystem.ProbeVolumes;
  1684. }
  1685. /// <summary>
  1686. /// Indicates the maximum number of SH Bands used by this render pipeline instance.
  1687. /// </summary>
  1688. public ProbeVolumeSHBands maxSHBands
  1689. {
  1690. get
  1691. {
  1692. if (lightProbeSystem == LightProbeSystem.ProbeVolumes)
  1693. return probeVolumeSHBands;
  1694. else
  1695. return ProbeVolumeSHBands.SphericalHarmonicsL1;
  1696. }
  1697. }
  1698. /// <summary>
  1699. /// Returns the projects global ProbeVolumeSceneData instance.
  1700. /// </summary>
  1701. [Obsolete("This property is no longer necessary.")]
  1702. public ProbeVolumeSceneData probeVolumeSceneData => null;
  1703. }
  1704. }