using System;
namespace UnityEngine.Rendering.HighDefinition
{
///
/// The mode HDRP uses to display the vignette effect.
///
///
public enum VignetteMode
{
///
/// Controls the position, shape, and intensity of the vignette.
///
Procedural,
///
/// Uses a texture mask to create a custom, irregular vignette effect.
///
Masked
}
///
/// A volume component that holds settings for the Vignette effect.
///
[Serializable, VolumeComponentMenu("Post-processing/Vignette")]
[SupportedOnRenderPipeline(typeof(HDRenderPipelineAsset))]
[HDRPHelpURL("Post-Processing-Vignette")]
public sealed class Vignette : VolumeComponent, IPostProcessComponent
{
///
/// Specifies the mode HDRP uses to display the vignette effect.
///
///
[Tooltip("Specifies the mode HDRP uses to display the vignette effect.")]
public VignetteModeParameter mode = new VignetteModeParameter(VignetteMode.Procedural);
///
/// Specifies the color of the vignette.
///
[Tooltip("Specifies the color of the vignette.")]
public ColorParameter color = new ColorParameter(Color.black, false, false, true);
///
/// Sets the center point for the vignette.
///
[Tooltip("Sets the center point for the vignette.")]
public Vector2Parameter center = new Vector2Parameter(new Vector2(0.5f, 0.5f));
///
/// Controls the strength of the vignette effect.
///
[Tooltip("Use the slider to set the strength of the Vignette effect.")]
public ClampedFloatParameter intensity = new ClampedFloatParameter(0f, 0f, 1f);
///
/// Controls the smoothness of the vignette borders.
///
[Tooltip("Controls the smoothness of the vignette borders.")]
public ClampedFloatParameter smoothness = new ClampedFloatParameter(0.2f, 0.01f, 1f);
///
/// Controls how round the vignette is, lower values result in a more square vignette.
///
[Tooltip("Controls how round the vignette is, lower values result in a more square vignette.")]
public ClampedFloatParameter roundness = new ClampedFloatParameter(1f, 0f, 1f);
///
/// When enabled, the vignette is perfectly round. When disabled, the vignette matches shape with the current aspect ratio.
///
[Tooltip("When enabled, the vignette is perfectly round. When disabled, the vignette matches shape with the current aspect ratio.")]
public BoolParameter rounded = new BoolParameter(false);
///
/// Specifies a black and white mask Texture to use as a vignette.
///
[Tooltip("Specifies a black and white mask Texture to use as a vignette.")]
public Texture2DParameter mask = new Texture2DParameter(null);
///
/// Controls the opacity of the mask vignette. Lower values result in a more transparent vignette.
///
[Range(0f, 1f), Tooltip("Controls the opacity of the mask vignette. Lower values result in a more transparent vignette.")]
public ClampedFloatParameter opacity = new ClampedFloatParameter(1f, 0f, 1f);
///
/// Tells if the effect needs to be rendered or not.
///
/// true if the effect should be rendered, false otherwise.
public bool IsActive()
{
return (mode.value == VignetteMode.Procedural && intensity.value > 0f)
|| (mode.value == VignetteMode.Masked && opacity.value > 0f && mask.value != null);
}
}
///
/// A that holds a value.
///
[Serializable]
public sealed class VignetteModeParameter : VolumeParameter
{
///
/// Creates a new instance.
///
/// The initial value to store in the parameter.
/// The initial override state for the parameter.
public VignetteModeParameter(VignetteMode value, bool overrideState = false) : base(value, overrideState) { }
}
}