using System; using UnityEngine.Serialization; namespace UnityEngine.Rendering.HighDefinition { /// /// The resolution at which HDRP processes the bloom effect. /// /// public enum BloomResolution : int { /// /// Quarter resolution. Faster than but can result in aliasing artifacts. /// It is recommended to use this mode when targetting high-DPI displays. /// Quarter = 4, /// /// Half resolution. /// Half = 2 } /// /// A volume component that holds settings for the Bloom effect. /// [Serializable, VolumeComponentMenu("Post-processing/Bloom")] [HelpURL(Documentation.baseURL + Documentation.version + Documentation.subURL + "Post-Processing-Bloom" + Documentation.endURL)] public sealed class Bloom : VolumeComponentWithQuality, IPostProcessComponent { /// /// Set the level of brightness to filter out pixels under this level. This value is expressed in gamma-space. A value above 0 will disregard energy conservation rules. /// [Tooltip("Set the level of brightness to filter out pixels under this level. This value is expressed in gamma-space. A value above 0 will disregard energy conservation rules.")] public MinFloatParameter threshold = new MinFloatParameter(0f, 0f); /// /// Controls the strength of the bloom filter. /// [Tooltip("Controls the strength of the bloom filter.")] public ClampedFloatParameter intensity = new ClampedFloatParameter(0f, 0f, 1f); /// /// Controls the extent of the veiling effect. /// [Tooltip("Controls the extent of the veiling effect.")] public ClampedFloatParameter scatter = new ClampedFloatParameter(0.7f, 0f, 1f); /// /// Specifies the tint of the bloom filter. /// [Tooltip("Specifies the tint of the bloom filter.")] public ColorParameter tint = new ColorParameter(Color.white, false, false, true); /// /// Specifies a Texture to add smudges or dust to the bloom effect. /// [Tooltip("Specifies a Texture to add smudges or dust to the bloom effect.")] public TextureParameter dirtTexture = new TextureParameter(null); /// /// Controls the strength of the lens dirt. /// [Tooltip("Controls the strength of the lens dirt.")] public MinFloatParameter dirtIntensity = new MinFloatParameter(0f, 0f); /// /// When enabled, bloom stretches horizontally depending on the current physical Camera's Anamorphism property value. /// [Tooltip("When enabled, bloom stretches horizontally depending on the current physical Camera's Anamorphism property value.")] [AdditionalProperty] public BoolParameter anamorphic = new BoolParameter(true); /// /// Specifies the resolution at which HDRP processes the effect. /// /// public BloomResolution resolution { get { if (!UsesQualitySettings()) { return m_Resolution.value; } else { int qualityLevel = (int)quality.levelAndOverride.level; return GetPostProcessingQualitySettings().BloomRes[qualityLevel]; } } set { m_Resolution.value = value; } } /// /// When enabled, bloom uses multiple bilinear samples for the prefiltering pass. /// public bool highQualityPrefiltering { get { if (!UsesQualitySettings()) { return m_HighQualityPrefiltering.value; } else { int qualityLevel = (int)quality.levelAndOverride.level; return GetPostProcessingQualitySettings().BloomHighQualityPrefiltering[qualityLevel]; } } set { m_HighQualityPrefiltering.value = value; } } /// /// When enabled, bloom uses bicubic sampling instead of bilinear sampling for the upsampling passes. /// public bool highQualityFiltering { get { if (!UsesQualitySettings()) { return m_HighQualityFiltering.value; } else { int qualityLevel = (int)quality.levelAndOverride.level; return GetPostProcessingQualitySettings().BloomHighQualityFiltering[qualityLevel]; } } set { m_HighQualityFiltering.value = value; } } [AdditionalProperty] [Tooltip("Specifies the resolution at which HDRP processes the effect. Quarter resolution is less resource intensive but can result in aliasing artifacts.")] [SerializeField, FormerlySerializedAs("resolution")] private BloomResolutionParameter m_Resolution = new BloomResolutionParameter(BloomResolution.Half); [AdditionalProperty] [Tooltip("When enabled, bloom uses multiple bilinear samples for the prefiltering pass.")] [SerializeField] private BoolParameter m_HighQualityPrefiltering = new BoolParameter(false); [AdditionalProperty] [Tooltip("When enabled, bloom uses bicubic sampling instead of bilinear sampling for the upsampling passes.")] [SerializeField, FormerlySerializedAs("highQualityFiltering")] private BoolParameter m_HighQualityFiltering = new BoolParameter(true); /// /// Tells if the effect needs to be rendered or not. /// /// true if the effect should be rendered, false otherwise. public bool IsActive() { return intensity.value > 0f; } } /// /// A that holds a value. /// [Serializable] public sealed class BloomResolutionParameter : VolumeParameter { /// /// Creates a new instance. /// /// The initial value to store in the parameter. /// The initial override state for the parameter. public BloomResolutionParameter(BloomResolution value, bool overrideState = false) : base(value, overrideState) {} } }