using System; namespace UnityEngine.Rendering.Universal { /// /// Option to control motion blur Mode. /// public enum MotionBlurMode { /// /// Use this if you don't need object motion blur. /// CameraOnly, /// /// Use this if you need object motion blur. /// CameraAndObjects } /// /// Options to control the quality the motion blur effect. /// public enum MotionBlurQuality { /// /// Use this to select low motion blur quality. /// Low, /// /// Use this to select medium motion blur quality. /// Medium, /// /// Use this to select high motion blur quality. /// High } /// /// A volume component that holds settings for the Motion Blur effect. /// /// /// You can add to a in the Editor to apply a Motion Blur 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 MotionBlur m_VolumeComponent; /// /// [Serializable] /// private struct VolumeSettings /// { /// public bool active; /// public MotionBlurModeParameter mode; /// public MotionBlurQualityParameter quality; /// public ClampedFloatParameter intensity; /// public ClampedFloatParameter clamp; /// /// public void SetVolumeComponentSettings(ref MotionBlur volumeComponent) /// { /// volumeComponent.active = active; /// volumeComponent.mode = mode; /// volumeComponent.quality = quality; /// volumeComponent.intensity = intensity; /// volumeComponent.clamp = clamp; /// } /// /// public void GetVolumeComponentSettings(ref MotionBlur volumeComponent) /// { /// active = volumeComponent.active; /// mode = volumeComponent.mode; /// quality = volumeComponent.quality; /// intensity = volumeComponent.intensity; /// clamp = volumeComponent.clamp; /// } /// } /// /// 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 MotionBlur volumeComponent) /// { /// if (volumeComponent != null) /// return true; /// /// if (volumeProfile == null) /// { /// Debug.LogError("ModifyVolumeComponent.GetVolumeComponent():\nvolumeProfile has not been assigned."); /// return false; /// } /// /// volumeProfile.TryGet(out MotionBlur 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/Motion Blur")] [SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))] [URPHelpURL("Post-Processing-Motion-Blur")] public sealed class MotionBlur : VolumeComponent, IPostProcessComponent { /// /// The motion blur technique to use. If you don't need object motion blur, CameraOnly will result in better performance. /// [Tooltip("The motion blur technique to use. If you don't need object motion blur, CameraOnly will result in better performance.")] public MotionBlurModeParameter mode = new MotionBlurModeParameter(MotionBlurMode.CameraOnly); /// /// The quality of the effect. Lower presets will result in better performance at the expense of visual quality. /// [Tooltip("The quality of the effect. Lower presets will result in better performance at the expense of visual quality.")] public MotionBlurQualityParameter quality = new MotionBlurQualityParameter(MotionBlurQuality.Low); /// /// Sets the intensity of the motion blur effect. Acts as a multiplier for velocities. /// [Tooltip("The strength of the motion blur filter. Acts as a multiplier for velocities.")] public ClampedFloatParameter intensity = new ClampedFloatParameter(0f, 0f, 1f); /// /// Sets the maximum length, as a fraction of the screen's full resolution, that the velocity resulting from Camera rotation can have. /// Lower values will improve performance. /// [Tooltip("Sets the maximum length, as a fraction of the screen's full resolution, that the velocity resulting from Camera rotation can have. Lower values will improve performance.")] public ClampedFloatParameter clamp = new ClampedFloatParameter(0.05f, 0f, 0.2f); /// /// Tells if the post process needs to be rendered or not. /// /// true if the effect should be rendered, false otherwise. public bool IsActive() => intensity.value > 0f; /// /// 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() => false; } /// /// A that holds a value. /// [Serializable] public sealed class MotionBlurModeParameter : VolumeParameter { /// /// Creates a new instance. /// /// The initial value to store in the parameter. /// The initial override state for the parameter. public MotionBlurModeParameter(MotionBlurMode value, bool overrideState = false) : base(value, overrideState) { } } /// /// A that holds a value. /// [Serializable] public sealed class MotionBlurQualityParameter : VolumeParameter { /// /// Creates a new instance. /// /// The initial value to store in the parameter. /// The initial override state for the parameter. public MotionBlurQualityParameter(MotionBlurQuality value, bool overrideState = false) : base(value, overrideState) { } } }