This commit is contained in:
2026-11-24 15:51:02 +01:00
parent cca4d73e41
commit f4aa17114a
22092 changed files with 5042406 additions and 0 deletions
@@ -0,0 +1,15 @@
namespace UnityEngine.Rendering
{
/// <summary>
/// Interface defining if an SRP supports environment effects for lens flare occlusion
/// </summary>
public interface ICloudBackground
{
/// <summary>
/// Check is the current Render Pipeline supports environement effects for lens flare occlusion.
/// </summary>
/// <returns>true if environement effects may occlude lens flares.</returns>
public bool IsCloudBackgroundUsable();
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 59ae371e1145bd94dbfe718b3584e7cc
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,16 @@
namespace UnityEngine.Rendering
{
/// <summary>
/// Volumetric Cloud
/// Interface for VolumetricCloud on each SRP
/// </summary>
public interface IVolumetricCloud
{
/// <summary>
/// Check is the current Render Pipeline had VolumetricCloud
/// </summary>
/// <returns>true if the VolumetricCloud is usable on the current pipeline</returns>
public bool IsVolumetricCloudUsable();
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4d6dfcf181cc0d446a1593c77ef2c6f9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,43 @@
using System;
using Unity.Scripting.LifecycleManagement;
#if UNITY_EDITOR
using UnityEditor.Rendering;
#endif
namespace UnityEngine.Rendering
{
/// <summary>
/// A <see cref="ScriptableObject"/> to associate with a <see cref="RenderPipeline"/> and store project-wide settings for that pipeline.
/// You can register a single <see cref="RenderPipelineGlobalSettings"/> instance to the <see cref="GraphicsSettings"/> by using <see cref="Rendering.GraphicsSettings.RegisterRenderPipelineSettings"/>. You can use this to save `RenderPipeline` settings that appear in `GraphicsSettings`.
/// </summary>
/// <typeparam name="TGlobalRenderPipelineSettings"><see cref="RenderPipelineGlobalSettings"/></typeparam>
/// <typeparam name="TRenderPipeline"><see cref="RenderPipeline"/></typeparam>
public abstract class RenderPipelineGlobalSettings<TGlobalRenderPipelineSettings, TRenderPipeline> : RenderPipelineGlobalSettings
where TRenderPipeline : RenderPipeline
where TGlobalRenderPipelineSettings : RenderPipelineGlobalSettings
{
/// <summary>
/// Active Global Settings asset. If the value is `null` then no `TGlobalRenderPipelineSettings` is registered to the Graphics Settings with the `TRenderPipeline`.
/// </summary>
#if UNITY_EDITOR
public static TGlobalRenderPipelineSettings instance =>
EditorGraphicsSettings.GetRenderPipelineGlobalSettingsAsset<TRenderPipeline>() as TGlobalRenderPipelineSettings;
#else
public static TGlobalRenderPipelineSettings instance => s_Instance.Value;
[NoAutoStaticsCleanup]
private static Lazy<TGlobalRenderPipelineSettings> s_Instance = new (() => GraphicsSettings.GetSettingsForRenderPipeline<TRenderPipeline>() as TGlobalRenderPipelineSettings);
#endif
/// <summary>
/// Called when settings asset is reset in the editor.
/// </summary>
public virtual void Reset()
{
#if UNITY_EDITOR
EditorGraphicsSettings.PopulateRenderPipelineGraphicsSettings(this);
Initialize();
#endif
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bf7039235906400da1eecd0fd65ace22
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,144 @@
#if UNITY_EDITOR
using System;
using System.Linq;
using System.Reflection;
using UnityEditor;
using UnityEditor.Rendering;
namespace UnityEngine.Rendering
{
/// <summary>
/// Set of utilities for <see cref="RenderPipelineGlobalSettings"/>
/// </summary>
public class RenderPipelineGlobalSettingsUtils
{
/// <summary>
/// Creates a <see cref="RenderPipelineGlobalSettings"/> asset
/// </summary>
/// <param name="path">The path where Unity generates the asset.</param>
/// <param name="dataSource">Another `RenderPipelineGlobalSettings` that Unity uses as a data source.</param>
/// <typeparam name="TGlobalSetting"><see cref="RenderPipelineGlobalSettings"/> </typeparam>
/// <returns>Returns the asset created.</returns>
public static TGlobalSetting Create<TGlobalSetting>(string path, TGlobalSetting dataSource = null)
where TGlobalSetting : RenderPipelineGlobalSettings
{
return Create(typeof(TGlobalSetting), path, dataSource) as TGlobalSetting;
}
/// <summary>
/// Creates a <see cref="RenderPipelineGlobalSettings"/> asset
/// </summary>
/// <param name="renderPipelineGlobalSettingsType"></param>
/// <param name="path">The path where Unity generates the asset.</param>
/// <param name="dataSource">Another `RenderPipelineGlobalSettings` that Unity uses as a data source.</param>
/// <returns>Returns the asset created.</returns>
public static RenderPipelineGlobalSettings Create(Type renderPipelineGlobalSettingsType, string path, RenderPipelineGlobalSettings dataSource = null)
{
if (!typeof(RenderPipelineGlobalSettings).IsAssignableFrom(renderPipelineGlobalSettingsType))
throw new ArgumentException(
$"{nameof(renderPipelineGlobalSettingsType)} must be a valid {typeof(RenderPipelineGlobalSettings)}");
// Sanitize the path
if (string.IsNullOrEmpty(path))
path = $"Assets/{renderPipelineGlobalSettingsType.Name}.asset";
if (!path.StartsWith("assets/", StringComparison.CurrentCultureIgnoreCase))
path = $"Assets/{path}";
CoreUtils.EnsureFolderTreeInAssetFilePath(path);
path = AssetDatabase.GenerateUniqueAssetPath(path);
var assetCreated = ScriptableObject.CreateInstance(renderPipelineGlobalSettingsType) as RenderPipelineGlobalSettings;
if (assetCreated != null)
{
AssetDatabase.CreateAsset(assetCreated, path);
// copy data from provided source
if (dataSource != null)
EditorUtility.CopySerializedManagedFieldsOnly(dataSource, assetCreated);
EditorGraphicsSettings.PopulateRenderPipelineGraphicsSettings(assetCreated);
assetCreated.Initialize(dataSource);
EditorUtility.SetDirty(assetCreated);
AssetDatabase.SaveAssetIfDirty(assetCreated);
AssetDatabase.Refresh();
}
return assetCreated;
}
/// <summary>
/// Checks that a <see cref="RenderPipelineGlobalSettings"/> asset exists.
/// If the asset isn't valid, Unity tries the following in order:
/// 1. Loads the asset at the default path.
/// 2. Finds any asset in the project with the same type.
/// 3. If `canCreateNewAsset` is true, creates a new asset in the default path.
/// If Unity finds or creates a valid asset, Unity updates the <see cref="GraphicsSettings"/> with it. Otherwise Unity will unregister the settings for the given pipeline.
/// </summary>
/// <param name="instance">The current instance of the asset.</param>
/// <param name="defaultPath">The default path.</param>
/// <param name="canCreateNewAsset">If set to `true`, Unity creates a new asset if it can't find an existing asset in the project.</param>
/// <typeparam name="TGlobalSetting">The type of global settings asset to check.</typeparam>
/// <typeparam name="TRenderPipeline">The type of `RenderPipeline` that this asset belongs to.</typeparam>
/// <returns>The asset that Unity found or created, or `null` if Unity can't find or create a valid asset.</returns>
public static bool TryEnsure<TGlobalSetting, TRenderPipeline>(ref TGlobalSetting instance, string defaultPath = "", bool canCreateNewAsset = true)
where TGlobalSetting : RenderPipelineGlobalSettings<TGlobalSetting, TRenderPipeline>
where TRenderPipeline : RenderPipeline
{
if (!TryEnsure<TGlobalSetting, TRenderPipeline>(ref instance, defaultPath, canCreateNewAsset, out var error))
{
Debug.LogError(error.Message);
return false;
}
return true;
}
// This method is exposed to Unit Tests
internal static bool TryEnsure<TGlobalSetting, TRenderPipeline>(ref TGlobalSetting instance, string defaultPath, bool canCreateNewAsset, out Exception error)
where TGlobalSetting : RenderPipelineGlobalSettings<TGlobalSetting, TRenderPipeline>
where TRenderPipeline : RenderPipeline
{
var globalSettingsName = typeof(TGlobalSetting).GetCustomAttribute<DisplayInfoAttribute>()?.name ?? typeof(TGlobalSetting).Name;
if (instance == null || instance.Equals(null))
{
if (!string.IsNullOrEmpty(defaultPath))
{
// Look at default path, if the asset exist, is the one that we need
instance = AssetDatabase.LoadAssetAtPath<TGlobalSetting>(defaultPath);
}
if (instance == null)
{
// There was not saved into the default path, fetch the asset database to see if there is one defined in the project
instance = CoreUtils.LoadAllAssets<TGlobalSetting>().FirstOrDefault();
if (instance == null)
{
// Try to create one if possible
if (canCreateNewAsset)
{
instance = Create<TGlobalSetting>(defaultPath);
if (instance != null)
{
Debug.LogWarning($"{globalSettingsName} has been created for you. If you want to modify it, go to Project Settings > Graphics > {globalSettingsName}");
}
}
}
}
}
error = instance == null || instance.Equals(null)
? new Exception(
$"Unable to find or create a {globalSettingsName}. The configured Render Pipeline may not work correctly. Go to Project Settings > Graphics > {globalSettingsName} for additional help.")
: null;
EditorGraphicsSettings.SetRenderPipelineGlobalSettingsAsset<TRenderPipeline>(instance);
return error == null;
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7f7239a21a2f6a24cb33f14a1b761706
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace UnityEngine.Rendering
{
/// <summary>
/// Contains a double list of <see cref="IRenderPipelineGraphicsSettings"/> one is used for editor
/// and the other for standalone release, the standalone release will be stripped by <see cref="IRenderPipelineGraphicsSettingsStripper{T}"/>
/// </summary>
[Serializable]
public class RenderPipelineGraphicsSettingsContainer : ISerializationCallbackReceiver
{
#if UNITY_EDITOR
[SerializeField] private RenderPipelineGraphicsSettingsCollection m_SettingsList = new();
#endif
[SerializeField, HideInInspector] private RenderPipelineGraphicsSettingsCollection m_RuntimeSettings = new();
/// <summary>
/// Returns one list for editor and another for runtime
/// </summary>
public List<IRenderPipelineGraphicsSettings> settingsList
{
#if UNITY_EDITOR
get => m_SettingsList.settingsList;
#else
get => m_RuntimeSettings.settingsList;
#endif
}
/// <summary>
/// On Before Serialize callback where the stripping is performed
/// </summary>
public void OnBeforeSerialize()
{
#if UNITY_EDITOR
m_RuntimeSettings.settingsList.Clear();
if (BuildPipeline.isBuildingPlayer) // Same behaviour as transfer.IsSerializingForGameRelease
RenderPipelineGraphicsSettingsStripper.PerformStripping(m_SettingsList.settingsList, m_RuntimeSettings.settingsList);
#endif
}
/// <summary>
/// On After Deserialize callback, nothing is implemented
/// </summary>
public void OnAfterDeserialize()
{
#if UNITY_EDITOR
m_RuntimeSettings.settingsList.Clear();
#endif
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a457613483325e44f9323e681f6ea59d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,16 @@
namespace UnityEngine.Rendering
{
/// <summary>
/// Base of resources assets in SRP
/// </summary>
[Icon("Packages/com.unity.render-pipelines.core/Editor/Icons/Processed/RenderPipelineResources Icon.asset")]
public abstract class RenderPipelineResources : ScriptableObject
{
/// <summary>
/// Utility to add Reload All button at the end of your asset inspector.
/// It will provide your package path that you misu override in child class.
/// </summary>
protected virtual string packagePath => null;
internal string packagePath_Internal => packagePath;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b43eb475bb161a44f9da1fc2fd1fff41
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: