using System; namespace UnityEngine.Rendering.Universal { /// /// A volume component that holds settings for the Split Toning effect. /// /// /// You can add to a in the Editor to apply a Split Toning post-processing effect. /// /// /// This sample code shows how settings can be retrieved and modified in runtime: /// /// using System; /// using UnityEngine; /// using UnityEngine.Rendering; /// using UnityEngine.Rendering.Universal; /// /// public class ModifyVolumeComponent : MonoBehaviour /// { /// [SerializeField] VolumeProfile volumeProfile; /// [SerializeField] VolumeSettings volumeSettings; /// /// private bool m_HasRetrievedVolumeComponent; /// private SplitToning m_VolumeComponent; /// /// [Serializable] /// private struct VolumeSettings /// { /// public bool active; /// public ColorParameter shadows; /// public ColorParameter highlights; /// public ClampedFloatParameter balance; /// /// /// public void SetVolumeComponentSettings(ref SplitToning volumeComponent) /// { /// volumeComponent.active = active; /// volumeComponent.shadows = shadows; /// volumeComponent.highlights = highlights; /// volumeComponent.balance = balance; /// } /// /// public void GetVolumeComponentSettings(ref SplitToning volumeComponent) /// { /// active = volumeComponent.active; /// shadows = volumeComponent.shadows; /// highlights = volumeComponent.highlights; /// balance = volumeComponent.balance; /// } /// } /// /// private void Start() /// { /// m_HasRetrievedVolumeComponent = GetVolumeComponent(in volumeProfile, ref m_VolumeComponent); /// if (m_HasRetrievedVolumeComponent) /// volumeSettings.GetVolumeComponentSettings(ref m_VolumeComponent); /// } /// /// private void Update() /// { /// if (!m_HasRetrievedVolumeComponent) /// return; /// /// volumeSettings.SetVolumeComponentSettings(ref m_VolumeComponent); /// } /// /// private static bool GetVolumeComponent(in VolumeProfile volumeProfile, ref SplitToning volumeComponent) /// { /// if (volumeComponent != null) /// return true; /// /// if (volumeProfile == null) /// { /// Debug.LogError("ModifyVolumeComponent.GetVolumeComponent():\nvolumeProfile has not been assigned."); /// return false; /// } /// /// volumeProfile.TryGet(out SplitToning component); /// if (component == null) /// { /// Debug.LogError($"ModifyVolumeComponent.GetVolumeComponent():\nMissing component in the \"{volumeProfile.name}\" VolumeProfile "); /// return false; /// } /// /// volumeComponent = component; /// return true; /// } /// } /// /// /// /// /// /// /// /// [Serializable, VolumeComponentMenu("Post-processing/Split Toning")] [SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))] [URPHelpURL("Post-Processing-Split-Toning")] public sealed class SplitToning : VolumeComponent, IPostProcessComponent { /// /// The color to use for shadows. /// [Tooltip("The color to use for shadows.")] public ColorParameter shadows = new ColorParameter(Color.grey, false, false, true); /// /// The color to use for highlights. /// [Tooltip("The color to use for highlights.")] public ColorParameter highlights = new ColorParameter(Color.grey, false, false, true); /// /// Balance between the colors in the highlights and shadows. /// [Tooltip("Balance between the colors in the highlights and shadows.")] public ClampedFloatParameter balance = new ClampedFloatParameter(0f, -100f, 100f); /// /// Tells if the post process needs to be rendered or not. /// /// true if the effect should be rendered, false otherwise. public bool IsActive() => shadows != Color.grey || highlights != Color.grey; /// /// Tells if the post process can run the effect on-tile or if it needs a full pass. /// /// true if it can run on-tile, false otherwise. [Obsolete("Unused #from(2023.1)", false)] public bool IsTileCompatible() => true; } }