Adaug proiectul Unity

This commit is contained in:
2026-11-01 23:39:55 +02:00
parent cb14d9d37d
commit 863eac8f2c
23463 changed files with 5412601 additions and 0 deletions
@@ -0,0 +1,282 @@
using System;
namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// This controls the size of the bloom texture.
/// </summary>
public enum BloomDownscaleMode
{
/// <summary>
/// Use this to select half size as the starting resolution.
/// </summary>
Half,
/// <summary>
/// Use this to select quarter size as the starting resolution.
/// </summary>
Quarter,
}
/// <summary>
/// This controls the filtering method of the bloom texture blur.
/// </summary>
public enum BloomFilterMode
{
/// <summary>
/// Gaussian blur on downsample and bilinear/bicubic on upsample. Best quality.
/// </summary>
[Tooltip("Best quality.")]
Gaussian,
/// <summary>
/// Dual blur combines Kawase like blur with downsampling and upsampling. It is faster than Gaussian but has worse quality. Dual can be faster than Kawase at high resolutions.
/// </summary>
[Tooltip("Balanced quality and speed.")]
Dual,
/// <summary>
/// Kawase blur uses a fixed size texture. It can be faster at lower resolutions while saving small amount of memory.
/// </summary>
[Tooltip("Lowest quality. Fastest at low resolutions. Saves memory.")]
Kawase
}
/// <summary>
/// A volume component that holds settings for the Bloom effect.
/// </summary>
/// <remarks>
/// You can add <see cref="VolumeComponent"/> to a <see cref="VolumeProfile"/> in the Editor to apply a Bloom post-processing effect.
/// </remarks>
/// <example>
/// <para>This sample code shows how settings can be retrieved and modified in runtime:</para>
/// <code>
/// 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 Bloom m_VolumeComponent;
///
/// [Serializable]
/// private struct VolumeSettings
/// {
/// public bool active;
/// public MinFloatParameter threshold;
/// public MinFloatParameter intensity;
/// public ClampedFloatParameter scatter;
/// public MinFloatParameter clamp;
/// public ColorParameter tint;
/// public BoolParameter highQualityFiltering;
/// public DownscaleParameter downscale;
/// public ClampedIntParameter maxIterations;
/// public TextureParameter dirtTexture;
/// public MinFloatParameter dirtIntensity;
///
/// public void SetVolumeComponentSettings(ref Bloom volumeComponent)
/// {
/// volumeComponent.active = active;
/// volumeComponent.threshold = threshold;
/// volumeComponent.intensity = intensity;
/// volumeComponent.scatter = scatter;
/// volumeComponent.clamp = clamp;
/// volumeComponent.tint = tint;
/// volumeComponent.highQualityFiltering = highQualityFiltering;
/// volumeComponent.downscale = downscale;
/// volumeComponent.maxIterations = maxIterations;
/// volumeComponent.dirtTexture = dirtTexture;
/// volumeComponent.dirtIntensity = dirtIntensity;
/// }
///
/// public void GetVolumeComponentSettings(ref Bloom volumeComponent)
/// {
/// active = volumeComponent.active;
/// threshold = volumeComponent.threshold;
/// intensity = volumeComponent.intensity;
/// scatter = volumeComponent.scatter;
/// clamp = volumeComponent.clamp;
/// tint = volumeComponent.tint;
/// highQualityFiltering = volumeComponent.highQualityFiltering;
/// downscale = volumeComponent.downscale;
/// maxIterations = volumeComponent.maxIterations;
/// dirtTexture = volumeComponent.dirtTexture;
/// dirtIntensity = volumeComponent.dirtIntensity;
/// }
/// }
///
/// 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 Bloom volumeComponent)
/// {
/// if (volumeComponent != null)
/// return true;
///
/// if (volumeProfile == null)
/// {
/// Debug.LogError("ModifyVolumeComponent.GetVolumeComponent():\nvolumeProfile has not been assigned.");
/// return false;
/// }
///
/// volumeProfile.TryGet(out Bloom component);
/// if (component == null)
/// {
/// Debug.LogError($"ModifyVolumeComponent.GetVolumeComponent():\nMissing component in the \"{volumeProfile.name}\" VolumeProfile ");
/// return false;
/// }
///
/// volumeComponent = component;
/// return true;
/// }
/// }
/// </code>
/// </example>
/// <seealso cref="VolumeProfile"/>
/// <seealso cref="VolumeComponent"/>
/// <seealso cref="IPostProcessComponent"/>
/// <seealso cref="VolumeParameter{T}"/>
/// <seealso cref="MinFloatParameter"/>
/// <seealso cref="ClampedFloatParameter"/>
/// <seealso cref="ColorParameter"/>
/// <seealso cref="BoolParameter"/>
/// <seealso cref="DownscaleParameter"/>
/// <seealso cref="BloomFilterModeParameter"/>
/// <seealso cref="ClampedIntParameter"/>
/// <seealso cref="TextureParameter"/>
[Serializable, VolumeComponentMenu("Post-processing/Bloom")]
[SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))]
[URPHelpURL("urp/post-processing-bloom")]
public sealed partial class Bloom : VolumeComponent, IPostProcessComponent
{
/// <summary>
/// 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.
/// </summary>
[Header("Bloom")]
[Tooltip("Filters out pixels under this level of brightness. Value is in gamma-space.")]
public MinFloatParameter threshold = new MinFloatParameter(0.9f, 0f);
/// <summary>
/// Controls the strength of the bloom filter.
/// </summary>
[Tooltip("Strength of the bloom filter.")]
public MinFloatParameter intensity = new MinFloatParameter(0f, 0f);
/// <summary>
/// Controls the extent of the veiling effect.
/// </summary>
[Tooltip("Set the radius of the bloom effect.")]
public ClampedFloatParameter scatter = new ClampedFloatParameter(0.7f, 0f, 1f);
/// <summary>
/// Set the maximum intensity that Unity uses to calculate Bloom.
/// If pixels in your Scene are more intense than this, URP renders them at their current intensity, but uses this intensity value for the purposes of Bloom calculations.
/// </summary>
[Tooltip("Set the maximum intensity that Unity uses to calculate Bloom. If pixels in your Scene are more intense than this, URP renders them at their current intensity, but uses this intensity value for the purposes of Bloom calculations.")]
public MinFloatParameter clamp = new MinFloatParameter(65472f, 0f);
/// <summary>
/// Specifies the tint of the bloom filter.
/// </summary>
[Tooltip("Use the color picker to select a color for the Bloom effect to tint to.")]
public ColorParameter tint = new ColorParameter(Color.white, false, false, true);
/// <summary>
/// Controls whether to use bicubic sampling instead of bilinear sampling for the upsampling passes.
/// This is slightly more expensive but helps getting smoother visuals.
/// </summary>
[Tooltip("Use bicubic sampling instead of bilinear sampling for the upsampling passes. This is slightly more expensive but helps getting smoother visuals.")]
public BoolParameter highQualityFiltering = new BoolParameter(false);
/// <summary>
/// Controls the filtering method used for the bloom downsampling and upsampling passes.
/// </summary>
[Tooltip("Set the filtering algorithm for the Bloom effect.")]
public BloomFilterModeParameter filter = new BloomFilterModeParameter(BloomFilterMode.Gaussian);
/// <summary>
/// Controls the starting resolution that this effect begins processing.
/// </summary>
[Tooltip("The starting resolution that this effect begins processing."), AdditionalProperty]
public DownscaleParameter downscale = new DownscaleParameter(BloomDownscaleMode.Half);
/// <summary>
/// Controls the maximum number of iterations in the effect processing sequence.
/// </summary>
[Tooltip("The maximum number of iterations in the effect processing sequence."), AdditionalProperty]
public ClampedIntParameter maxIterations = new ClampedIntParameter(6, 2, 8);
/// <summary>
/// Specifies a Texture to add smudges or dust to the bloom effect.
/// </summary>
[Header("Lens Dirt")]
[Tooltip("Dirtiness texture to add smudges or dust to the bloom effect.")]
public TextureParameter dirtTexture = new TextureParameter(null);
/// <summary>
/// Controls the strength of the lens dirt.
/// </summary>
[Tooltip("Amount of dirtiness.")]
public MinFloatParameter dirtIntensity = new MinFloatParameter(0f, 0f);
/// <summary>
/// Tells if the post process needs to be rendered or not.
/// </summary>
/// <returns><c>true</c> if the effect should be rendered, <c>false</c> otherwise.</returns>
public bool IsActive() => intensity.value > 0f;
/// <summary>
/// Tells if the post process can run the effect on-tile or if it needs a full pass.
/// </summary>
/// <returns><c>true</c> if it can run on-tile, <c>false</c> otherwise.</returns>
[Obsolete("Unused. #from(2023.1)")]
public bool IsTileCompatible() => false;
}
/// <summary>
/// A <see cref="VolumeParameter"/> that holds a <see cref="BloomDownscaleMode"/> value.
/// </summary>
[Serializable]
public sealed class DownscaleParameter : VolumeParameter<BloomDownscaleMode>
{
/// <summary>
/// Creates a new <see cref="DownscaleParameter"/> instance.
/// </summary>
/// <param name="value">The initial value to store in the parameter.</param>
/// <param name="overrideState">The initial override state for the parameter.</param>
public DownscaleParameter(BloomDownscaleMode value, bool overrideState = false) : base(value, overrideState) { }
}
/// <summary>
/// A <see cref="VolumeParameter"/> that holds a <see cref="BloomFilterMode"/> value.
/// </summary>
[Serializable]
public sealed class BloomFilterModeParameter : VolumeParameter<BloomFilterMode>
{
/// <summary>
/// Creates a new <see cref="BloomFilterModeParameter"/> instance.
/// </summary>
/// <param name="value">The initial value to store in the parameter.</param>
/// <param name="overrideState">The initial override state for the parameter.</param>
public BloomFilterModeParameter(BloomFilterMode value, bool overrideState = false) : base(value, overrideState) { }
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0b2db86121404754db890f4c8dfe81b2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,198 @@
using System;
namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// A volume component that holds settings for the Channel Mixer effect.
/// </summary>
/// <remarks>
/// You can add <see cref="VolumeComponent"/> to a <see cref="VolumeProfile"/> in the Editor to apply a Channel Mixer post-processing effect.
/// </remarks>
/// <example>
/// <para>This sample code shows how settings can be retrieved and modified in runtime:</para>
/// <code>
/// 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 ChannelMixer m_VolumeComponent;
///
/// [Serializable]
/// private struct VolumeSettings
/// {
/// public bool active;
/// public ClampedFloatParameter redOutRedIn;
/// public ClampedFloatParameter redOutGreenIn;
/// public ClampedFloatParameter redOutBlueIn;
/// public ClampedFloatParameter greenOutRedIn;
/// public ClampedFloatParameter greenOutGreenIn;
/// public ClampedFloatParameter greenOutBlueIn;
/// public ClampedFloatParameter blueOutRedIn;
/// public ClampedFloatParameter blueOutGreenIn;
/// public ClampedFloatParameter blueOutBlueIn;
///
/// public void SetVolumeComponentSettings(ref ChannelMixer volumeComponent)
/// {
/// volumeComponent.active = active;
/// volumeComponent.redOutRedIn = redOutRedIn;
/// volumeComponent.redOutGreenIn = redOutGreenIn;
/// volumeComponent.redOutBlueIn = redOutBlueIn;
/// volumeComponent.greenOutRedIn = greenOutRedIn;
/// volumeComponent.greenOutGreenIn = greenOutGreenIn;
/// volumeComponent.greenOutBlueIn = greenOutBlueIn;
/// volumeComponent.blueOutRedIn = blueOutRedIn;
/// volumeComponent.blueOutGreenIn = blueOutGreenIn;
/// volumeComponent.blueOutBlueIn = blueOutBlueIn;
/// }
///
/// public void GetVolumeComponentSettings(ref ChannelMixer volumeComponent)
/// {
/// active = volumeComponent.active;
/// redOutRedIn = volumeComponent.redOutRedIn;
/// redOutGreenIn = volumeComponent.redOutGreenIn;
/// redOutBlueIn = volumeComponent.redOutBlueIn;
/// greenOutRedIn = volumeComponent.greenOutRedIn;
/// greenOutGreenIn = volumeComponent.greenOutGreenIn;
/// greenOutBlueIn = volumeComponent.greenOutBlueIn;
/// blueOutRedIn = volumeComponent.blueOutRedIn;
/// blueOutGreenIn = volumeComponent.blueOutGreenIn;
/// blueOutBlueIn = volumeComponent.blueOutBlueIn;
/// }
/// }
///
/// 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 ChannelMixer volumeComponent)
/// {
/// if (volumeComponent != null)
/// return true;
///
/// if (volumeProfile == null)
/// {
/// Debug.LogError("ModifyVolumeComponent.GetVolumeComponent():\nvolumeProfile has not been assigned.");
/// return false;
/// }
///
/// volumeProfile.TryGet(out ChannelMixer component);
/// if (component == null)
/// {
/// Debug.LogError($"ModifyVolumeComponent.GetVolumeComponent():\nMissing component in the \"{volumeProfile.name}\" VolumeProfile ");
/// return false;
/// }
///
/// volumeComponent = component;
/// return true;
/// }
/// }
/// </code>
/// </example>
/// <seealso cref="VolumeProfile"/>
/// <seealso cref="VolumeComponent"/>
/// <seealso cref="IPostProcessComponent"/>
/// <seealso cref="VolumeParameter{T}"/>
/// <seealso cref="ClampedFloatParameter"/>
[Serializable, VolumeComponentMenu("Post-processing/Channel Mixer")]
[SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))]
[URPHelpURL("urp/Post-Processing-Channel-Mixer")]
public sealed class ChannelMixer : VolumeComponent, IPostProcessComponent
{
/// <summary>
/// Modify influence of the red channel in the overall mix.
/// </summary>
[Tooltip("Modify influence of the red channel in the overall mix.")]
public ClampedFloatParameter redOutRedIn = new ClampedFloatParameter(100f, -200f, 200f);
/// <summary>
/// Modify influence of the green channel in the overall mix.
/// </summary>
[Tooltip("Modify influence of the green channel in the overall mix.")]
public ClampedFloatParameter redOutGreenIn = new ClampedFloatParameter(0f, -200f, 200f);
/// <summary>
/// Modify influence of the blue channel in the overall mix.
/// </summary>
[Tooltip("Modify influence of the blue channel in the overall mix.")]
public ClampedFloatParameter redOutBlueIn = new ClampedFloatParameter(0f, -200f, 200f);
/// <summary>
/// Modify influence of the red channel in the overall mix.
/// </summary>
[Tooltip("Modify influence of the red channel in the overall mix.")]
public ClampedFloatParameter greenOutRedIn = new ClampedFloatParameter(0f, -200f, 200f);
/// <summary>
/// Modify influence of the green channel in the overall mix.
/// </summary>
[Tooltip("Modify influence of the green channel in the overall mix.")]
public ClampedFloatParameter greenOutGreenIn = new ClampedFloatParameter(100f, -200f, 200f);
/// <summary>
/// Modify influence of the blue channel in the overall mix.
/// </summary>
[Tooltip("Modify influence of the blue channel in the overall mix.")]
public ClampedFloatParameter greenOutBlueIn = new ClampedFloatParameter(0f, -200f, 200f);
/// <summary>
/// Modify influence of the red channel in the overall mix.
/// </summary>
[Tooltip("Modify influence of the red channel in the overall mix.")]
public ClampedFloatParameter blueOutRedIn = new ClampedFloatParameter(0f, -200f, 200f);
/// <summary>
/// Modify influence of the green channel in the overall mix.
/// </summary>
[Tooltip("Modify influence of the green channel in the overall mix.")]
public ClampedFloatParameter blueOutGreenIn = new ClampedFloatParameter(0f, -200f, 200f);
/// <summary>
/// Modify influence of the blue channel in the overall mix.
/// </summary>
[Tooltip("Modify influence of the blue channel in the overall mix.")]
public ClampedFloatParameter blueOutBlueIn = new ClampedFloatParameter(100f, -200f, 200f);
/// <summary>
/// Tells if the post process needs to be rendered or not.
/// </summary>
/// <returns><c>true</c> if the effect should be rendered, <c>false</c> otherwise.</returns>
public bool IsActive()
{
return redOutRedIn.value != 100f
|| redOutGreenIn.value != 0f
|| redOutBlueIn.value != 0f
|| greenOutRedIn.value != 0f
|| greenOutGreenIn.value != 100f
|| greenOutBlueIn.value != 0f
|| blueOutRedIn.value != 0f
|| blueOutGreenIn.value != 0f
|| blueOutBlueIn.value != 100f;
}
/// <summary>
/// Tells if the post process can run the effect on-tile or if it needs a full pass.
/// </summary>
/// <returns><c>true</c> if it can run on-tile, <c>false</c> otherwise.</returns>
[Obsolete("Unused. #from(2023.1)")]
public bool IsTileCompatible() => true;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cdfbdbb87d3286943a057f7791b43141
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,114 @@
using System;
namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// A volume component that holds settings for the Chromatic Aberration effect.
/// </summary>
/// <remarks>
/// You can add <see cref="VolumeComponent"/> to a <see cref="VolumeProfile"/> in the Editor to apply a Chromatic Aberration post-processing effect.
/// </remarks>
/// <example>
/// <para>This sample code shows how settings can be retrieved and modified in runtime:</para>
/// <code>
/// 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 ChromaticAberration m_VolumeComponent;
///
/// [Serializable]
/// private struct VolumeSettings
/// {
/// public bool active;
/// public ClampedFloatParameter intensity;
///
/// public void SetVolumeComponentSettings(ref ChromaticAberration volumeComponent)
/// {
/// volumeComponent.active = active;
/// volumeComponent.intensity = intensity;
/// }
///
/// public void GetVolumeComponentSettings(ref ChromaticAberration volumeComponent)
/// {
/// active = volumeComponent.active;
/// intensity = volumeComponent.intensity;
/// }
/// }
///
/// 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 ChromaticAberration volumeComponent)
/// {
/// if (volumeComponent != null)
/// return true;
///
/// if (volumeProfile == null)
/// {
/// Debug.LogError("ModifyVolumeComponent.GetVolumeComponent():\nvolumeProfile has not been assigned.");
/// return false;
/// }
///
/// volumeProfile.TryGet(out ChromaticAberration component);
/// if (component == null)
/// {
/// Debug.LogError($"ModifyVolumeComponent.GetVolumeComponent():\nMissing component in the \"{volumeProfile.name}\" VolumeProfile ");
/// return false;
/// }
///
/// volumeComponent = component;
/// return true;
/// }
/// }
/// </code>
/// </example>
/// <seealso cref="VolumeProfile"/>
/// <seealso cref="VolumeComponent"/>
/// <seealso cref="IPostProcessComponent"/>
/// <seealso cref="VolumeParameter{T}"/>
/// <seealso cref="ClampedFloatParameter"/>
[Serializable, VolumeComponentMenu("Post-processing/Chromatic Aberration")]
[SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))]
[URPHelpURL("urp/post-processing-chromatic-aberration")]
public sealed class ChromaticAberration : VolumeComponent, IPostProcessComponent
{
/// <summary>
/// Controls the strength of the chromatic aberration effect.
/// </summary>
[Tooltip("Use the slider to set the strength of the Chromatic Aberration effect.")]
public ClampedFloatParameter intensity = new ClampedFloatParameter(0f, 0f, 1f);
/// <summary>
/// Tells if the post process needs to be rendered or not.
/// </summary>
/// <returns><c>true</c> if the effect should be rendered, <c>false</c> otherwise.</returns>
public bool IsActive() => intensity.value > 0f;
/// <summary>
/// Tells if the post process can run the effect on-tile or if it needs a full pass.
/// </summary>
/// <returns><c>true</c> if it can run on-tile, <c>false</c> otherwise.</returns>
[Obsolete("Unused. #from(2023.1)")]
public bool IsTileCompatible() => false;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 81180773991d8724ab7f2d216912b564
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,160 @@
using System;
namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// A volume component that holds settings for the Color Adjustments effect.
/// </summary>
/// <remarks>
/// You can add <see cref="VolumeComponent"/> to a <see cref="VolumeProfile"/> in the Editor to apply a Color Adjustments post-processing effect.
/// </remarks>
/// <example>
/// <para>This sample code shows how settings can be retrieved and modified in runtime:</para>
/// <code>
/// 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 ColorAdjustments m_VolumeComponent;
///
/// [Serializable]
/// private struct VolumeSettings
/// {
/// public bool active;
/// public FloatParameter postExposure;
/// public ClampedFloatParameter contrast;
/// public ColorParameter colorFilter;
/// public ClampedFloatParameter hueShift;
/// public ClampedFloatParameter saturation;
///
/// public void SetVolumeComponentSettings(ref ColorAdjustments volumeComponent)
/// {
/// volumeComponent.active = active;
/// volumeComponent.postExposure = postExposure;
/// volumeComponent.contrast = contrast;
/// volumeComponent.colorFilter = colorFilter;
/// volumeComponent.hueShift = hueShift;
/// volumeComponent.saturation = saturation;
/// }
///
/// public void GetVolumeComponentSettings(ref ColorAdjustments volumeComponent)
/// {
/// active = volumeComponent.active;
/// postExposure = volumeComponent.postExposure;
/// contrast = volumeComponent.contrast;
/// colorFilter = volumeComponent.colorFilter;
/// hueShift = volumeComponent.hueShift;
/// saturation = volumeComponent.saturation;
/// }
/// }
///
/// 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 ColorAdjustments volumeComponent)
/// {
/// if (volumeComponent != null)
/// return true;
///
/// if (volumeProfile == null)
/// {
/// Debug.LogError("ModifyVolumeComponent.GetVolumeComponent():\nvolumeProfile has not been assigned.");
/// return false;
/// }
///
/// volumeProfile.TryGet(out ColorAdjustments component);
/// if (component == null)
/// {
/// Debug.LogError($"ModifyVolumeComponent.GetVolumeComponent():\nMissing component in the \"{volumeProfile.name}\" VolumeProfile ");
/// return false;
/// }
///
/// volumeComponent = component;
/// return true;
/// }
/// }
/// </code>
/// </example>
/// <seealso cref="VolumeProfile"/>
/// <seealso cref="VolumeComponent"/>
/// <seealso cref="IPostProcessComponent"/>
/// <seealso cref="VolumeParameter{T}"/>
/// <seealso cref="FloatParameter"/>
/// <seealso cref="ClampedFloatParameter"/>
/// <seealso cref="ColorParameter"/>
[Serializable, VolumeComponentMenu("Post-processing/Color Adjustments")]
[SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))]
[URPHelpURL("urp/Post-Processing-Color-Adjustments")]
public sealed class ColorAdjustments : VolumeComponent, IPostProcessComponent
{
/// <summary>
/// Adjusts the overall exposure of the scene in EV100.
/// This is applied after HDR effect and right before tonemapping so it won't affect previous effects in the chain.
/// </summary>
[Tooltip("Adjusts the overall exposure of the scene in EV100. This is applied after HDR effect and right before tonemapping so it won't affect previous effects in the chain.")]
public FloatParameter postExposure = new FloatParameter(0f);
/// <summary>
/// Controls the overall range of the tonal values.
/// </summary>
[Tooltip("Expands or shrinks the overall range of tonal values.")]
public ClampedFloatParameter contrast = new ClampedFloatParameter(0f, -100f, 100f);
/// <summary>
/// Specifies the color that URP tints the render to.
/// </summary>
[Tooltip("Tint the render by multiplying a color.")]
public ColorParameter colorFilter = new ColorParameter(Color.white, true, false, true);
/// <summary>
/// Controls the hue of all colors in the render.
/// </summary>
[Tooltip("Shift the hue of all colors.")]
public ClampedFloatParameter hueShift = new ClampedFloatParameter(0f, -180f, 180f);
/// <summary>
/// Controls the intensity of all colors in the render.
/// </summary>
[Tooltip("Pushes the intensity of all colors.")]
public ClampedFloatParameter saturation = new ClampedFloatParameter(0f, -100f, 100f);
/// <summary>
/// Tells if the post process needs to be rendered or not.
/// </summary>
/// <returns><c>true</c> if the effect should be rendered, <c>false</c> otherwise.</returns>
public bool IsActive()
{
return postExposure.value != 0f
|| contrast.value != 0f
|| colorFilter != Color.white
|| hueShift != 0f
|| saturation != 0f;
}
/// <summary>
/// Tells if the post process can run the effect on-tile or if it needs a full pass.
/// </summary>
/// <returns><c>true</c> if it can run on-tile, <c>false</c> otherwise.</returns>
[Obsolete("Unused. #from(2023.1)")]
public bool IsTileCompatible() => true;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 66f335fb1ffd8684294ad653bf1c7564
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,177 @@
using System;
namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// A volume component that holds settings for the Color Curves effect.
/// </summary>
/// <remarks>
/// You can add <see cref="VolumeComponent"/> to a <see cref="VolumeProfile"/> in the Editor to apply a Color Curves post-processing effect.
/// </remarks>
/// <example>
/// <para>This sample code shows how settings can be retrieved and modified in runtime:</para>
/// <code>
/// 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 ColorCurves m_VolumeComponent;
///
/// [Serializable]
/// private struct VolumeSettings
/// {
/// public bool active;
/// public TextureCurveParameter master;
/// public TextureCurveParameter red;
/// public TextureCurveParameter green;
/// public TextureCurveParameter blue;
/// public TextureCurveParameter hueVsHue;
/// public TextureCurveParameter hueVsSat;
/// public TextureCurveParameter satVsSat;
/// public TextureCurveParameter lumVsSat;
///
/// public void SetVolumeComponentSettings(ref ColorCurves volumeComponent)
/// {
/// volumeComponent.active = active;
/// volumeComponent.master = master;
/// volumeComponent.red = red;
/// volumeComponent.green = green;
/// volumeComponent.blue = blue;
/// volumeComponent.hueVsHue = hueVsHue;
/// volumeComponent.hueVsSat = hueVsSat;
/// volumeComponent.satVsSat = satVsSat;
/// volumeComponent.lumVsSat = lumVsSat;
/// }
///
/// public void GetVolumeComponentSettings(ref ColorCurves volumeComponent)
/// {
/// active = volumeComponent.active;
/// master = volumeComponent.master;
/// red = volumeComponent.red;
/// green = volumeComponent.green;
/// blue = volumeComponent.blue;
/// hueVsHue = volumeComponent.hueVsHue;
/// hueVsSat = volumeComponent.hueVsSat;
/// satVsSat = volumeComponent.satVsSat;
/// lumVsSat = volumeComponent.lumVsSat;
/// }
/// }
///
/// 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 ColorCurves volumeComponent)
/// {
/// if (volumeComponent != null)
/// return true;
///
/// if (volumeProfile == null)
/// {
/// Debug.LogError("ModifyVolumeComponent.GetVolumeComponent():\nvolumeProfile has not been assigned.");
/// return false;
/// }
///
/// volumeProfile.TryGet(out ColorCurves component);
/// if (component == null)
/// {
/// Debug.LogError($"ModifyVolumeComponent.GetVolumeComponent():\nMissing component in the \"{volumeProfile.name}\" VolumeProfile ");
/// return false;
/// }
///
/// volumeComponent = component;
/// return true;
/// }
/// }
/// </code>
/// </example>
/// <seealso cref="VolumeProfile"/>
/// <seealso cref="VolumeComponent"/>
/// <seealso cref="IPostProcessComponent"/>
/// <seealso cref="VolumeParameter{T}"/>
/// <seealso cref="TextureCurveParameter"/>
[Serializable, VolumeComponentMenu("Post-processing/Color Curves")]
[SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))]
[URPHelpURL("urp/Post-Processing-Color-Curves")]
public sealed class ColorCurves : VolumeComponent, IPostProcessComponent
{
/// <summary>
/// Affects the luminance across the whole image.
/// </summary>
[Tooltip("Affects the luminance across the whole image.")]
public TextureCurveParameter master = new TextureCurveParameter(new TextureCurve(new[] { new Keyframe(0f, 0f, 1f, 1f), new Keyframe(1f, 1f, 1f, 1f) }, 0f, false, new Vector2(0f, 1f)));
/// <summary>
/// Affects the red channel intensity across the whole image.
/// </summary>
[Tooltip("Affects the red channel intensity across the whole image.")]
public TextureCurveParameter red = new TextureCurveParameter(new TextureCurve(new[] { new Keyframe(0f, 0f, 1f, 1f), new Keyframe(1f, 1f, 1f, 1f) }, 0f, false, new Vector2(0f, 1f)));
/// <summary>
/// Affects the green channel intensity across the whole image.
/// </summary>
[Tooltip("Affects the green channel intensity across the whole image.")]
public TextureCurveParameter green = new TextureCurveParameter(new TextureCurve(new[] { new Keyframe(0f, 0f, 1f, 1f), new Keyframe(1f, 1f, 1f, 1f) }, 0f, false, new Vector2(0f, 1f)));
/// <summary>
/// Affects the blue channel intensity across the whole image.
/// </summary>
[Tooltip("Affects the blue channel intensity across the whole image.")]
public TextureCurveParameter blue = new TextureCurveParameter(new TextureCurve(new[] { new Keyframe(0f, 0f, 1f, 1f), new Keyframe(1f, 1f, 1f, 1f) }, 0f, false, new Vector2(0f, 1f)));
/// <summary>
/// Shifts the input hue (x-axis) according to the output hue (y-axis).
/// </summary>
[Tooltip("Shifts the input hue (x-axis) according to the output hue (y-axis).")]
public TextureCurveParameter hueVsHue = new TextureCurveParameter(new TextureCurve(new Keyframe[] { }, 0.5f, true, new Vector2(0f, 1f)));
/// <summary>
/// Adjusts saturation (y-axis) according to the input hue (x-axis).
/// </summary>
[Tooltip("Adjusts saturation (y-axis) according to the input hue (x-axis).")]
public TextureCurveParameter hueVsSat = new TextureCurveParameter(new TextureCurve(new Keyframe[] { }, 0.5f, true, new Vector2(0f, 1f)));
/// <summary>
/// Adjusts saturation (y-axis) according to the input saturation (x-axis).
/// </summary>
[Tooltip("Adjusts saturation (y-axis) according to the input saturation (x-axis).")]
public TextureCurveParameter satVsSat = new TextureCurveParameter(new TextureCurve(new Keyframe[] { }, 0.5f, false, new Vector2(0f, 1f)));
/// <summary>
/// Adjusts saturation (y-axis) according to the input luminance (x-axis).
/// </summary>
[Tooltip("Adjusts saturation (y-axis) according to the input luminance (x-axis).")]
public TextureCurveParameter lumVsSat = new TextureCurveParameter(new TextureCurve(new Keyframe[] { }, 0.5f, false, new Vector2(0f, 1f)));
/// <summary>
/// Tells if the post process needs to be rendered or not.
/// </summary>
/// <returns><c>true</c> if the effect should be rendered, <c>false</c> otherwise.</returns>
public bool IsActive() => true;
/// <summary>
/// Tells if the post process can run the effect on-tile or if it needs a full pass.
/// </summary>
/// <returns><c>true</c> if it can run on-tile, <c>false</c> otherwise.</returns>
[Obsolete("Unused. #from(2023.1)")]
public bool IsTileCompatible() => true;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3eb4b772797da9440885e8bd939e9560
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,157 @@
using System;
using UnityEngine.Experimental.Rendering;
namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// A volume component that holds settings for the Color Lookup effect.
/// </summary>
/// <remarks>
/// You can add <see cref="VolumeComponent"/> to a <see cref="VolumeProfile"/> in the Editor to apply a Color Lookup post-processing effect.
/// </remarks>
/// <example>
/// <para>This sample code shows how settings can be retrieved and modified in runtime:</para>
/// <code>
/// 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 ColorLookup m_VolumeComponent;
///
/// [Serializable]
/// private struct VolumeSettings
/// {
/// public bool active;
/// public TextureParameter texture;
/// public ClampedFloatParameter contribution;
///
/// public void SetVolumeComponentSettings(ref ColorLookup volumeComponent)
/// {
/// volumeComponent.active = active;
/// volumeComponent.texture = texture;
/// volumeComponent.contribution = contribution;
/// }
///
/// public void GetVolumeComponentSettings(ref ColorLookup volumeComponent)
/// {
/// active = volumeComponent.active;
/// texture = volumeComponent.texture;
/// contribution = volumeComponent.contribution;
/// }
/// }
///
/// 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 ColorLookup volumeComponent)
/// {
/// if (volumeComponent != null)
/// return true;
///
/// if (volumeProfile == null)
/// {
/// Debug.LogError("ModifyVolumeComponent.GetVolumeComponent():\nvolumeProfile has not been assigned.");
/// return false;
/// }
///
/// volumeProfile.TryGet(out ColorLookup component);
/// if (component == null)
/// {
/// Debug.LogError($"ModifyVolumeComponent.GetVolumeComponent():\nMissing component in the \"{volumeProfile.name}\" VolumeProfile ");
/// return false;
/// }
///
/// volumeComponent = component;
/// return true;
/// }
/// }
/// </code>
/// </example>
/// <seealso cref="VolumeProfile"/>
/// <seealso cref="VolumeComponent"/>
/// <seealso cref="IPostProcessComponent"/>
/// <seealso cref="VolumeParameter{T}"/>
/// <seealso cref="TextureParameter"/>
/// <seealso cref="ClampedFloatParameter"/>
[Serializable, VolumeComponentMenu("Post-processing/Color Lookup")]
[SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))]
[URPHelpURL("urp/integration-with-post-processing")]
public sealed class ColorLookup : VolumeComponent, IPostProcessComponent
{
/// <summary>
/// A 2D Lookup Texture (LUT) to use for color grading.
/// </summary>
[Tooltip("A 2D Lookup Texture (LUT) to use for color grading.")]
public TextureParameter texture = new TextureParameter(null);
/// <summary>
/// Controls how much of the lookup texture will contribute to the color grading effect.
/// </summary>
[Tooltip("How much of the lookup texture will contribute to the color grading effect.")]
public ClampedFloatParameter contribution = new ClampedFloatParameter(0f, 0f, 1f);
/// <summary>
/// Tells if the post process needs to be rendered or not.
/// </summary>
/// <returns><c>true</c> if the effect should be rendered, <c>false</c> otherwise.</returns>
public bool IsActive() => contribution.value > 0f && ValidateLUT();
/// <summary>
/// Tells if the post process can run the effect on-tile or if it needs a full pass.
/// </summary>
/// <returns><c>true</c> if it can run on-tile, <c>false</c> otherwise.</returns>
[Obsolete("Unused. #from(2023.1)")]
public bool IsTileCompatible() => true;
/// <summary>
/// Validates the lookup texture assigned to the volume component.
/// </summary>
/// <returns>True if the texture is valid, false otherwise.</returns>
public bool ValidateLUT()
{
var asset = UniversalRenderPipeline.asset;
if (asset == null || texture.value == null)
return false;
int lutSize = asset.colorGradingLutSize;
if (texture.value.height != lutSize)
return false;
bool valid = false;
switch (texture.value)
{
case Texture2D t:
valid |= t.width == lutSize * lutSize
&& !GraphicsFormatUtility.IsSRGBFormat(t.graphicsFormat);
break;
case RenderTexture rt:
valid |= rt.dimension == TextureDimension.Tex2D
&& rt.width == lutSize * lutSize
&& !rt.sRGB;
break;
}
return valid;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e021b4c809a781e468c2988c016ebbea
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,250 @@
using System;
namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// Focusing modes for the depth of field effect.
/// </summary>
public enum DepthOfFieldMode
{
/// <summary>
/// Disables depth of field.
/// </summary>
Off,
/// <summary>
/// Use this for faster but non physical depth of field.
/// </summary>
Gaussian, // Non physical, fast, small radius, far blur only
/// <summary>
/// Use this for a more realistic but slower depth of field.
/// </summary>
Bokeh
}
/// <summary>
/// A volume component that holds settings for the Depth Of Field effect.
/// </summary>
/// <remarks>
/// You can add <see cref="VolumeComponent"/> to a <see cref="VolumeProfile"/> in the Editor to apply a Depth Of Field post-processing effect.
/// </remarks>
/// <example>
/// <para>This sample code shows how settings can be retrieved and modified in runtime:</para>
/// <code>
/// 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 DepthOfField m_VolumeComponent;
///
/// [Serializable]
/// private struct VolumeSettings
/// {
/// public bool active;
/// public DepthOfFieldModeParameter mode;
/// public MinFloatParameter gaussianStart;
/// public MinFloatParameter gaussianEnd;
/// public ClampedFloatParameter gaussianMaxRadius;
/// public BoolParameter highQualitySampling;
/// public MinFloatParameter focusDistance;
/// public ClampedFloatParameter aperture;
/// public ClampedFloatParameter focalLength;
/// public ClampedIntParameter bladeCount;
/// public ClampedFloatParameter bladeCurvature;
/// public ClampedFloatParameter bladeRotation;
///
///
/// public void SetVolumeComponentSettings(ref DepthOfField volumeComponent)
/// {
/// volumeComponent.active = active;
/// volumeComponent.mode = mode;
/// volumeComponent.gaussianStart = gaussianStart;
/// volumeComponent.gaussianEnd = gaussianEnd;
/// volumeComponent.gaussianMaxRadius = gaussianMaxRadius;
/// volumeComponent.highQualitySampling = highQualitySampling;
/// volumeComponent.focusDistance = focusDistance;
/// volumeComponent.aperture = aperture;
/// volumeComponent.focalLength = focalLength;
/// volumeComponent.bladeCount = bladeCount;
/// volumeComponent.bladeCurvature = bladeCurvature;
/// volumeComponent.bladeRotation = bladeRotation;
/// }
///
/// public void GetVolumeComponentSettings(ref DepthOfField volumeComponent)
/// {
/// active = volumeComponent.active;
/// mode = volumeComponent.mode;
/// gaussianStart = volumeComponent.gaussianStart;
/// gaussianEnd = volumeComponent.gaussianEnd;
/// gaussianMaxRadius = volumeComponent.gaussianMaxRadius;
/// highQualitySampling = volumeComponent.highQualitySampling;
/// focusDistance = volumeComponent.focusDistance;
/// aperture = volumeComponent.aperture;
/// focalLength = volumeComponent.focalLength;
/// bladeCount = volumeComponent.bladeCount;
/// bladeCurvature = volumeComponent.bladeCurvature;
/// bladeRotation = volumeComponent.bladeRotation;
/// }
/// }
///
/// 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 DepthOfField volumeComponent)
/// {
/// if (volumeComponent != null)
/// return true;
///
/// if (volumeProfile == null)
/// {
/// Debug.LogError("ModifyVolumeComponent.GetVolumeComponent():\nvolumeProfile has not been assigned.");
/// return false;
/// }
///
/// volumeProfile.TryGet(out DepthOfField component);
/// if (component == null)
/// {
/// Debug.LogError($"ModifyVolumeComponent.GetVolumeComponent():\nMissing component in the \"{volumeProfile.name}\" VolumeProfile ");
/// return false;
/// }
///
/// volumeComponent = component;
/// return true;
/// }
/// }
/// </code>
/// </example>
/// <seealso cref="VolumeProfile"/>
/// <seealso cref="VolumeComponent"/>
/// <seealso cref="IPostProcessComponent"/>
/// <seealso cref="VolumeParameter{T}"/>
/// <seealso cref="DepthOfFieldModeParameter"/>
/// <seealso cref="MinFloatParameter"/>
/// <seealso cref="ClampedFloatParameter"/>
/// <seealso cref="BoolParameter"/>
/// <seealso cref="ClampedIntParameter"/>
[Serializable, VolumeComponentMenu("Post-processing/Depth Of Field")]
[SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))]
[URPHelpURL("urp/depth-of-field-volume-override-reference")]
public sealed class DepthOfField : VolumeComponent, IPostProcessComponent
{
/// <summary>
/// Use this to select Focusing modes for the depth of field effect.
/// </summary>
[Tooltip("Use \"Gaussian\" for a faster but non physical depth of field; \"Bokeh\" for a more realistic but slower depth of field.")]
public DepthOfFieldModeParameter mode = new DepthOfFieldModeParameter(DepthOfFieldMode.Off);
/// <summary>
/// The distance at which the blurring will start.
/// </summary>
[Tooltip("The distance at which the blurring will start.")]
public MinFloatParameter gaussianStart = new MinFloatParameter(10f, 0f);
/// <summary>
/// The distance at which the blurring will reach its maximum radius.
/// </summary>
[Tooltip("The distance at which the blurring will reach its maximum radius.")]
public MinFloatParameter gaussianEnd = new MinFloatParameter(30f, 0f);
/// <summary>
/// The maximum radius of the gaussian blur. Values above 1 may show under-sampling artifacts.
/// </summary>
[Tooltip("The maximum radius of the gaussian blur. Values above 1 may show under-sampling artifacts.")]
public ClampedFloatParameter gaussianMaxRadius = new ClampedFloatParameter(1f, 0.5f, 1.5f);
/// <summary>
/// Use higher quality sampling to reduce flickering and improve the overall blur smoothness.
/// </summary>
[Tooltip("Use higher quality sampling to reduce flickering and improve the overall blur smoothness.")]
public BoolParameter highQualitySampling = new BoolParameter(false);
/// <summary>
/// The distance to the point of focus.
/// </summary>
[Tooltip("The distance to the point of focus.")]
public MinFloatParameter focusDistance = new MinFloatParameter(10f, 0.1f);
/// <summary>
/// The ratio of aperture (known as f-stop or f-number). The smaller the value is, the shallower the depth of field is.
/// </summary>
[Tooltip("The ratio of aperture (known as f-stop or f-number). The smaller the value is, the shallower the depth of field is.")]
public ClampedFloatParameter aperture = new ClampedFloatParameter(5.6f, 1f, 32f);
/// <summary>
/// The distance between the lens and the film. The larger the value is, the shallower the depth of field is.
/// </summary>
[Tooltip("The distance between the lens and the film. The larger the value is, the shallower the depth of field is.")]
public ClampedFloatParameter focalLength = new ClampedFloatParameter(50f, 1f, 300f);
/// <summary>
/// The number of aperture blades.
/// </summary>
[Tooltip("The number of aperture blades.")]
public ClampedIntParameter bladeCount = new ClampedIntParameter(5, 3, 9);
/// <summary>
/// The curvature of aperture blades. The smaller the value is, the more visible aperture blades are. A value of 1 will make the bokeh perfectly circular.
/// </summary>
[Tooltip("The curvature of aperture blades. The smaller the value is, the more visible aperture blades are. A value of 1 will make the bokeh perfectly circular.")]
public ClampedFloatParameter bladeCurvature = new ClampedFloatParameter(1f, 0f, 1f);
/// <summary>
/// The rotation of aperture blades in degrees.
/// </summary>
[Tooltip("The rotation of aperture blades in degrees.")]
public ClampedFloatParameter bladeRotation = new ClampedFloatParameter(0f, -180f, 180f);
/// <summary>
/// Tells if the post process needs to be rendered or not.
/// </summary>
/// <returns><c>true</c> if the effect should be rendered, <c>false</c> otherwise.</returns>
public bool IsActive()
{
if (mode.value == DepthOfFieldMode.Off || SystemInfo.graphicsShaderLevel < 35)
return false;
return mode.value != DepthOfFieldMode.Gaussian || SystemInfo.supportedRenderTargetCount > 1;
}
/// <summary>
/// Tells if the post process can run the effect on-tile or if it needs a full pass.
/// </summary>
/// <returns><c>true</c> if it can run on-tile, <c>false</c> otherwise.</returns>
[Obsolete("Unused. #from(2023.1)")]
public bool IsTileCompatible() => false;
}
/// <summary>
/// A <see cref="VolumeParameter"/> that holds a <see cref="DepthOfFieldMode"/> value.
/// </summary>
[Serializable]
public sealed class DepthOfFieldModeParameter : VolumeParameter<DepthOfFieldMode>
{
/// <summary>
/// Creates a new <see cref="DepthOfFieldModeParameter"/> instance.
/// </summary>
/// <param name="value">The initial value to store in the parameter.</param>
/// <param name="overrideState">The initial override state for the parameter.</param>
public DepthOfFieldModeParameter(DepthOfFieldMode value, bool overrideState = false) : base(value, overrideState) { }
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c01700fd266d6914ababb731e09af2eb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,219 @@
using System;
namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// Presets for the <see cref="FilmGrain"/> effect.
/// </summary>
public enum FilmGrainLookup
{
/// <summary>
/// Thin grain preset.
/// </summary>
Thin1,
/// <summary>
/// Thin grain preset.
/// </summary>
Thin2,
/// <summary>
/// Medium grain preset.
/// </summary>
Medium1,
/// <summary>
/// Medium grain preset.
/// </summary>
Medium2,
/// <summary>
/// Medium grain preset.
/// </summary>
Medium3,
/// <summary>
/// Medium grain preset.
/// </summary>
Medium4,
/// <summary>
/// Medium grain preset.
/// </summary>
Medium5,
/// <summary>
/// Medium grain preset.
/// </summary>
Medium6,
/// <summary>
/// Large grain preset.
/// </summary>
Large01,
/// <summary>
/// Large grain preset.
/// </summary>
Large02,
/// <summary>
/// Custom grain preset.
/// </summary>
/// <seealso cref="FilmGrain.texture"/>
Custom
}
/// <summary>
/// A volume component that holds settings for the Film Grain effect.
/// </summary>
/// <remarks>
/// You can add <see cref="VolumeComponent"/> to a <see cref="VolumeProfile"/> in the Editor to apply a Film Grain post-processing effect.
/// </remarks>
/// <example>
/// <para>This sample code shows how settings can be retrieved and modified in runtime:</para>
/// <code>
/// 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 FilmGrain m_VolumeComponent;
///
/// [Serializable]
/// private struct VolumeSettings
/// {
/// public bool active;
/// public FilmGrainLookupParameter type;
/// public ClampedFloatParameter intensity;
/// public ClampedFloatParameter response;
/// public NoInterpTextureParameter texture;
///
/// public void SetVolumeComponentSettings(ref FilmGrain volumeComponent)
/// {
/// volumeComponent.active = active;
/// volumeComponent.type = type;
/// volumeComponent.intensity = intensity;
/// volumeComponent.response = response;
/// volumeComponent.texture = texture;
/// }
///
/// public void GetVolumeComponentSettings(ref FilmGrain volumeComponent)
/// {
/// active = volumeComponent.active;
/// type = volumeComponent.type;
/// intensity = volumeComponent.intensity;
/// response = volumeComponent.response;
/// texture = volumeComponent.texture;
/// }
/// }
///
/// 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 FilmGrain volumeComponent)
/// {
/// if (volumeComponent != null)
/// return true;
///
/// if (volumeProfile == null)
/// {
/// Debug.LogError("ModifyVolumeComponent.GetVolumeComponent():\nvolumeProfile has not been assigned.");
/// return false;
/// }
///
/// volumeProfile.TryGet(out FilmGrain component);
/// if (component == null)
/// {
/// Debug.LogError($"ModifyVolumeComponent.GetVolumeComponent():\nMissing component in the \"{volumeProfile.name}\" VolumeProfile ");
/// return false;
/// }
///
/// volumeComponent = component;
/// return true;
/// }
/// }
/// </code>
/// </example>
/// <seealso cref="VolumeProfile"/>
/// <seealso cref="VolumeComponent"/>
/// <seealso cref="IPostProcessComponent"/>
/// <seealso cref="VolumeParameter{T}"/>
/// <seealso cref="FilmGrainLookupParameter"/>
/// <seealso cref="ClampedFloatParameter"/>
/// <seealso cref="NoInterpTextureParameter"/>
[Serializable, VolumeComponentMenu("Post-processing/Film Grain")]
[SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))]
[URPHelpURL("urp/Post-Processing-Film-Grain")]
public sealed class FilmGrain : VolumeComponent, IPostProcessComponent
{
/// <summary>
/// The type of grain to use. You can select a preset or provide your own texture by selecting Custom.
/// </summary>
[Tooltip("The type of grain to use. You can select a preset or provide your own texture by selecting Custom.")]
public FilmGrainLookupParameter type = new FilmGrainLookupParameter(FilmGrainLookup.Thin1);
/// <summary>
/// Use this to set the strength of the Film Grain effect.
/// </summary>
[Tooltip("Use the slider to set the strength of the Film Grain effect.")]
public ClampedFloatParameter intensity = new ClampedFloatParameter(0f, 0f, 1f);
/// <summary>
/// Controls the noisiness response curve based on scene luminance. Higher values mean less noise in light areas.
/// </summary>
[Tooltip("Controls the noisiness response curve based on scene luminance. Higher values mean less noise in light areas.")]
public ClampedFloatParameter response = new ClampedFloatParameter(0.8f, 0f, 1f);
/// <summary>
/// A tileable texture to use for the grain. The neutral value is 0.5 where no grain is applied
/// </summary>
[Tooltip("A tileable texture to use for the grain. The neutral value is 0.5 where no grain is applied.")]
public NoInterpTextureParameter texture = new NoInterpTextureParameter(null);
/// <summary>
/// Tells if the post process needs to be rendered or not.
/// </summary>
/// <returns><c>true</c> if the effect should be rendered, <c>false</c> otherwise.</returns>
public bool IsActive() => intensity.value > 0f && (type.value != FilmGrainLookup.Custom || texture.value != null);
/// <summary>
/// Tells if the post process can run the effect on-tile or if it needs a full pass.
/// </summary>
/// <returns><c>true</c> if it can run on-tile, <c>false</c> otherwise.</returns>
[Obsolete("Unused. #from(2023.1)")]
public bool IsTileCompatible() => true;
}
/// <summary>
/// A <see cref="VolumeParameter"/> that holds a <see cref="FilmGrainLookup"/> value.
/// </summary>
[Serializable]
public sealed class FilmGrainLookupParameter : VolumeParameter<FilmGrainLookup>
{
/// <summary>
/// Creates a new <see cref="FilmGrainLookupParameter"/> instance.
/// </summary>
/// <param name="value">The initial value to store in the parameter.</param>
/// <param name="overrideState">The initial override state for the parameter.</param>
public FilmGrainLookupParameter(FilmGrainLookup value, bool overrideState = false) : base(value, overrideState) { }
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 29fa0085f50d5e54f8144f766051a691
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,155 @@
using System;
namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// A volume component that holds settings for the Lens Distortion effect.
/// </summary>
/// <remarks>
/// You can add <see cref="VolumeComponent"/> to a <see cref="VolumeProfile"/> in the Editor to apply a Lens Distortion post-processing effect.
/// </remarks>
/// <example>
/// <para>This sample code shows how settings can be retrieved and modified in runtime:</para>
/// <code>
/// 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 LensDistortion m_VolumeComponent;
///
/// [Serializable]
/// private struct VolumeSettings
/// {
/// public bool active;
/// public ClampedFloatParameter intensity;
/// public ClampedFloatParameter xMultiplier;
/// public ClampedFloatParameter yMultiplier;
/// public Vector2Parameter center;
/// public ClampedFloatParameter scale;
///
/// public void SetVolumeComponentSettings(ref LensDistortion volumeComponent)
/// {
/// volumeComponent.active = active;
/// volumeComponent.intensity = intensity;
/// volumeComponent.xMultiplier = xMultiplier;
/// volumeComponent.yMultiplier = yMultiplier;
/// volumeComponent.center = center;
/// volumeComponent.scale = scale;
/// }
///
/// public void GetVolumeComponentSettings(ref LensDistortion volumeComponent)
/// {
/// active = volumeComponent.active;
/// intensity = volumeComponent.intensity;
/// xMultiplier = volumeComponent.xMultiplier;
/// yMultiplier = volumeComponent.yMultiplier;
/// center = volumeComponent.center;
/// scale = volumeComponent.scale;
/// }
/// }
///
/// 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 LensDistortion volumeComponent)
/// {
/// if (volumeComponent != null)
/// return true;
///
/// if (volumeProfile == null)
/// {
/// Debug.LogError("ModifyVolumeComponent.GetVolumeComponent():\nvolumeProfile has not been assigned.");
/// return false;
/// }
///
/// volumeProfile.TryGet(out LensDistortion component);
/// if (component == null)
/// {
/// Debug.LogError($"ModifyVolumeComponent.GetVolumeComponent():\nMissing component in the \"{volumeProfile.name}\" VolumeProfile ");
/// return false;
/// }
///
/// volumeComponent = component;
/// return true;
/// }
/// }
/// </code>
/// </example>
/// <seealso cref="VolumeProfile"/>
/// <seealso cref="VolumeComponent"/>
/// <seealso cref="IPostProcessComponent"/>
/// <seealso cref="VolumeParameter{T}"/>
/// <seealso cref="ClampedFloatParameter"/>
/// <seealso cref="Vector2Parameter"/>
[Serializable, VolumeComponentMenu("Post-processing/Lens Distortion")]
[SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))]
[URPHelpURL("urp/Post-Processing-Lens-Distortion")]
public sealed class LensDistortion : VolumeComponent, IPostProcessComponent
{
/// <summary>
/// Total distortion amount.
/// </summary>
[Tooltip("Total distortion amount.")]
public ClampedFloatParameter intensity = new ClampedFloatParameter(0f, -1f, 1f);
/// <summary>
/// Intensity multiplier on X axis. Set it to 0 to disable distortion on this axis.
/// </summary>
[Tooltip("Intensity multiplier on X axis. Set it to 0 to disable distortion on this axis.")]
public ClampedFloatParameter xMultiplier = new ClampedFloatParameter(1f, 0f, 1f);
/// <summary>
/// Intensity multiplier on Y axis. Set it to 0 to disable distortion on this axis.
/// </summary>
[Tooltip("Intensity multiplier on Y axis. Set it to 0 to disable distortion on this axis.")]
public ClampedFloatParameter yMultiplier = new ClampedFloatParameter(1f, 0f, 1f);
/// <summary>
/// Distortion center point. 0.5,0.5 is center of the screen
/// </summary>
[Tooltip("Distortion center point. 0.5,0.5 is center of the screen.")]
public Vector2Parameter center = new Vector2Parameter(new Vector2(0.5f, 0.5f));
/// <summary>
/// Controls global screen scaling for the distortion effect. Use this to hide the screen borders when using high \"Intensity.\"
/// </summary>
[Tooltip("Controls global screen scaling for the distortion effect. Use this to hide the screen borders when using high \"Intensity.\"")]
public ClampedFloatParameter scale = new ClampedFloatParameter(1f, 0.01f, 5f);
/// <summary>
/// Tells if the post process needs to be rendered or not.
/// </summary>
/// <returns><c>true</c> if the effect should be rendered, <c>false</c> otherwise.</returns>
public bool IsActive()
{
return Mathf.Abs(intensity.value) > 0
&& (xMultiplier.value > 0f || yMultiplier.value > 0f);
}
/// <summary>
/// Tells if the post process can run the effect on-tile or if it needs a full pass.
/// </summary>
/// <returns><c>true</c> if it can run on-tile, <c>false</c> otherwise.</returns>
[Obsolete("Unused. #from(2023.1)")]
public bool IsTileCompatible() => false;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c5e1dc532bcb41949b58bc4f2abfbb7e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,135 @@
using System;
namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// A volume component that holds settings for the Lift-Gamma-Gain effect.
/// </summary>
/// <remarks>
/// You can add <see cref="VolumeComponent"/> to a <see cref="VolumeProfile"/> in the Editor to apply a Lift-Gamma-Gain post-processing effect.
/// </remarks>
/// <example>
/// <para>This sample code shows how settings can be retrieved and modified in runtime:</para>
/// <code>
/// 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 LiftGammaGain m_VolumeComponent;
///
/// [Serializable]
/// private struct VolumeSettings
/// {
/// public bool active;
/// public Vector4Parameter lift;
/// public Vector4Parameter gamma;
/// public Vector4Parameter gain;
///
/// public void SetVolumeComponentSettings(ref LiftGammaGain volumeComponent)
/// {
/// volumeComponent.active = active;
/// volumeComponent.lift = lift;
/// volumeComponent.gamma = gamma;
/// volumeComponent.gain = gain;
/// }
///
/// public void GetVolumeComponentSettings(ref LiftGammaGain volumeComponent)
/// {
/// active = volumeComponent.active;
/// lift = volumeComponent.lift;
/// gamma = volumeComponent.gamma;
/// gain = volumeComponent.gain;
/// }
/// }
///
/// 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 LiftGammaGain volumeComponent)
/// {
/// if (volumeComponent != null)
/// return true;
///
/// if (volumeProfile == null)
/// {
/// Debug.LogError("ModifyVolumeComponent.GetVolumeComponent():\nvolumeProfile has not been assigned.");
/// return false;
/// }
///
/// volumeProfile.TryGet(out LiftGammaGain component);
/// if (component == null)
/// {
/// Debug.LogError($"ModifyVolumeComponent.GetVolumeComponent():\nMissing component in the \"{volumeProfile.name}\" VolumeProfile ");
/// return false;
/// }
///
/// volumeComponent = component;
/// return true;
/// }
/// }
/// </code>
/// </example>
/// <seealso cref="VolumeProfile"/>
/// <seealso cref="VolumeComponent"/>
/// <seealso cref="IPostProcessComponent"/>
/// <seealso cref="VolumeParameter{T}"/>
/// <seealso cref="Vector4Parameter"/>
[Serializable, VolumeComponentMenu("Post-processing/Lift, Gamma, Gain")]
[SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))]
[URPHelpURL("urp/Post-Processing-Lift-Gamma-Gain")]
public sealed class LiftGammaGain : VolumeComponent, IPostProcessComponent
{
/// <summary>
/// Use this to control and apply a hue to the dark tones. This has a more exaggerated effect on shadows.
/// </summary>
public Vector4Parameter lift = new Vector4Parameter(new Vector4(1f, 1f, 1f, 0f));
/// <summary>
/// Use this to control and apply a hue to the mid-range tones with a power function.
/// </summary>
public Vector4Parameter gamma = new Vector4Parameter(new Vector4(1f, 1f, 1f, 0f));
/// <summary>
/// Use this to increase and apply a hue to the signal and make highlights brighter.
/// </summary>
public Vector4Parameter gain = new Vector4Parameter(new Vector4(1f, 1f, 1f, 0f));
/// <summary>
/// Tells if the post process needs to be rendered or not.
/// </summary>
/// <returns><c>true</c> if the effect should be rendered, <c>false</c> otherwise.</returns>
public bool IsActive()
{
var defaultState = new Vector4(1f, 1f, 1f, 0f);
return lift != defaultState
|| gamma != defaultState
|| gain != defaultState;
}
/// <summary>
/// Tells if the post process can run the effect on-tile or if it needs a full pass.
/// </summary>
/// <returns><c>true</c> if it can run on-tile, <c>false</c> otherwise.</returns>
[Obsolete("Unused. #from(2023.1)")]
public bool IsTileCompatible() => true;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5485954d14dfb9a4c8ead8edb0ded5b1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,209 @@
using System;
namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// Option to control motion blur Mode.
/// </summary>
public enum MotionBlurMode
{
/// <summary>
/// Use this if you don't need object motion blur.
/// </summary>
CameraOnly,
/// <summary>
/// Use this if you need object motion blur.
/// </summary>
CameraAndObjects
}
/// <summary>
/// Options to control the quality the motion blur effect.
/// </summary>
public enum MotionBlurQuality
{
/// <summary>
/// Use this to select low motion blur quality.
/// </summary>
Low,
/// <summary>
/// Use this to select medium motion blur quality.
/// </summary>
Medium,
/// <summary>
/// Use this to select high motion blur quality.
/// </summary>
High
}
/// <summary>
/// A volume component that holds settings for the Motion Blur effect.
/// </summary>
/// <remarks>
/// You can add <see cref="VolumeComponent"/> to a <see cref="VolumeProfile"/> in the Editor to apply a Motion Blur post-processing effect.
/// </remarks>
/// <example>
/// <para>This sample code shows how settings can be retrieved and modified in runtime:</para>
/// <code>
/// 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;
/// }
/// }
/// </code>
/// </example>
/// <seealso cref="VolumeProfile"/>
/// <seealso cref="VolumeComponent"/>
/// <seealso cref="IPostProcessComponent"/>
/// <seealso cref="VolumeParameter{T}"/>
/// <seealso cref="MotionBlurModeParameter"/>
/// <seealso cref="MotionBlurQualityParameter"/>
/// <seealso cref="ClampedFloatParameter"/>
[Serializable, VolumeComponentMenu("Post-processing/Motion Blur")]
[SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))]
[URPHelpURL("urp/Post-Processing-Motion-Blur")]
public sealed class MotionBlur : VolumeComponent, IPostProcessComponent
{
/// <summary>
/// The motion blur technique to use. If you don't need object motion blur, CameraOnly will result in better performance.
/// </summary>
[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);
/// <summary>
/// The quality of the effect. Lower presets will result in better performance at the expense of visual quality.
/// </summary>
[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);
/// <summary>
/// Sets the intensity of the motion blur effect. Acts as a multiplier for velocities.
/// </summary>
[Tooltip("The strength of the motion blur filter. Acts as a multiplier for velocities.")]
public ClampedFloatParameter intensity = new ClampedFloatParameter(0f, 0f, 1f);
/// <summary>
/// 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.
/// </summary>
[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);
/// <summary>
/// Tells if the post process needs to be rendered or not.
/// </summary>
/// <returns><c>true</c> if the effect should be rendered, <c>false</c> otherwise.</returns>
public bool IsActive() => intensity.value > 0f;
/// <summary>
/// Tells if the post process can run the effect on-tile or if it needs a full pass.
/// </summary>
/// <returns><c>true</c> if it can run on-tile, <c>false</c> otherwise.</returns>
[Obsolete("Unused. #from(2023.1)")]
public bool IsTileCompatible() => false;
}
/// <summary>
/// A <see cref="VolumeParameter"/> that holds a <see cref="MotionBlurMode"/> value.
/// </summary>
[Serializable]
public sealed class MotionBlurModeParameter : VolumeParameter<MotionBlurMode>
{
/// <summary>
/// Creates a new <see cref="MotionBlurModeParameter"/> instance.
/// </summary>
/// <param name="value">The initial value to store in the parameter.</param>
/// <param name="overrideState">The initial override state for the parameter.</param>
public MotionBlurModeParameter(MotionBlurMode value, bool overrideState = false) : base(value, overrideState) { }
}
/// <summary>
/// A <see cref="VolumeParameter"/> that holds a <see cref="MotionBlurQuality"/> value.
/// </summary>
[Serializable]
public sealed class MotionBlurQualityParameter : VolumeParameter<MotionBlurQuality>
{
/// <summary>
/// Creates a new <see cref="MotionBlurQualityParameter"/> instance.
/// </summary>
/// <param name="value">The initial value to store in the parameter.</param>
/// <param name="overrideState">The initial override state for the parameter.</param>
public MotionBlurQualityParameter(MotionBlurQuality value, bool overrideState = false) : base(value, overrideState) { }
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ccf1aba9553839d41ae37dd52e9ebcce
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,123 @@
using System;
namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// A volume component that holds settings for the Panini Projection effect.
/// </summary>
/// <remarks>
/// You can add <see cref="VolumeComponent"/> to a <see cref="VolumeProfile"/> in the Editor to apply a Panini Projection post-processing effect.
/// </remarks>
/// <example>
/// <para>This sample code shows how settings can be retrieved and modified in runtime:</para>
/// <code>
/// 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 PaniniProjection m_VolumeComponent;
///
/// [Serializable]
/// private struct VolumeSettings
/// {
/// public bool active;
/// public ClampedFloatParameter distance;
/// public ClampedFloatParameter cropToFit;
///
/// public void SetVolumeComponentSettings(ref PaniniProjection volumeComponent)
/// {
/// volumeComponent.active = active;
/// volumeComponent.distance = distance;
/// volumeComponent.cropToFit = cropToFit;
/// }
///
/// public void GetVolumeComponentSettings(ref PaniniProjection volumeComponent)
/// {
/// active = volumeComponent.active;
/// distance = volumeComponent.distance;
/// cropToFit = volumeComponent.cropToFit;
/// }
/// }
///
/// 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 PaniniProjection volumeComponent)
/// {
/// if (volumeComponent != null)
/// return true;
///
/// if (volumeProfile == null)
/// {
/// Debug.LogError("ModifyVolumeComponent.GetVolumeComponent():\nvolumeProfile has not been assigned.");
/// return false;
/// }
///
/// volumeProfile.TryGet(out PaniniProjection component);
/// if (component == null)
/// {
/// Debug.LogError($"ModifyVolumeComponent.GetVolumeComponent():\nMissing component in the \"{volumeProfile.name}\" VolumeProfile ");
/// return false;
/// }
///
/// volumeComponent = component;
/// return true;
/// }
/// }
/// </code>
/// </example>
/// <seealso cref="VolumeProfile"/>
/// <seealso cref="VolumeComponent"/>
/// <seealso cref="IPostProcessComponent"/>
/// <seealso cref="VolumeParameter{T}"/>
/// <seealso cref="ClampedFloatParameter"/>
[Serializable, VolumeComponentMenu("Post-processing/Panini Projection")]
[SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))]
[URPHelpURL("urp/Post-Processing-Panini-Projection")]
public sealed class PaniniProjection : VolumeComponent, IPostProcessComponent
{
/// <summary>
/// Controls the panini projection distance. This controls the strength of the distorion.
/// </summary>
[Tooltip("Panini projection distance.")]
public ClampedFloatParameter distance = new ClampedFloatParameter(0f, 0f, 1f);
/// <summary>
/// Controls how much cropping HDRP applies to the screen with the panini projection effect. A value of 1 crops the distortion to the edge of the screen.
/// </summary>
[Tooltip("Panini projection crop to fit.")]
public ClampedFloatParameter cropToFit = new ClampedFloatParameter(1f, 0f, 1f);
/// <summary>
/// Tells if the post process needs to be rendered or not.
/// </summary>
/// <returns><c>true</c> if the effect should be rendered, <c>false</c> otherwise.</returns>
public bool IsActive() => distance.value > 0f;
/// <summary>
/// Tells if the post process can run the effect on-tile or if it needs a full pass.
/// </summary>
/// <returns><c>true</c> if it can run on-tile, <c>false</c> otherwise.</returns>
[Obsolete("Unused. #from(2023.1)")]
public bool IsTileCompatible() => false;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: fb60a22f311433c4c962b888d1393f88
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,692 @@
#if MODERN_SSAO
using System;
namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// Ambient occlusion rendering modes.
/// </summary>
public enum ScreenSpaceAmbientOcclusionMode
{
/// <summary>
/// Disables Screen Space Ambient Occlusion.
/// </summary>
[InspectorName("None")]
None = 0,
/// <summary>
/// Standard SSAO algorithm - Alchemy method with configurable noise and blur.
/// </summary>
[InspectorName("Standard")]
Standard = 1,
/// <summary>
/// Ground Truth Ambient Occlusion.
/// </summary>
[InspectorName("GTAO")]
GTAO = 2,
}
/// <summary>
/// Noise method for ambient occlusion sampling.
/// </summary>
public enum ScreenSpaceAmbientOcclusionNoiseMethod
{
/// <summary>
/// Blue noise based sampling - reduces visible patterns.
/// </summary>
[InspectorName("Blue Noise")]
BlueNoise = 0,
/// <summary>
/// Interleaved gradient noise based sampling - better performance.
/// </summary>
[InspectorName("Interleaved Gradient")]
InterleavedGradient = 1
}
/// <summary>
/// Quality presets for ambient occlusion sampling.
/// </summary>
public enum ScreenSpaceAmbientOcclusionSampleCount
{
/// <summary>
/// Low quality preset - 4 samples in Standard mode. 2 iterations in fragment GTAO.
/// </summary>
[InspectorName("Low")]
Low = 0,
/// <summary>
/// Medium quality - 8 samples in Standard mode, 8 iterations in fragment GTAO.
/// </summary>
[InspectorName("Medium")]
Medium = 1,
/// <summary>
/// High quality - 12 samples in Standard mode, 16 iterations in fragment GTAO.
/// </summary>
[InspectorName("High")]
High = 2
}
/// <summary>
/// Depth and normal data source for ambient occlusion.
/// </summary>
public enum ScreenSpaceAmbientOcclusionDepthSource
{
/// <summary>
/// Depth buffer only - normals reconstructed from depth.
/// </summary>
[InspectorName("Depth")]
Depth = 0,
/// <summary>
/// Depth and normals from the depth-normals prepass - more accurate.
/// </summary>
[InspectorName("Depth Normals")]
DepthNormals = 1
}
/// <summary>
/// Normal reconstruction quality when computing normals from depth.
/// </summary>
public enum ScreenSpaceAmbientOcclusionNormalQuality
{
/// <summary>
/// Low quality - fewer samples, faster reconstruction.
/// </summary>
[InspectorName("Low")]
Low = 0,
/// <summary>
/// Medium quality - balanced reconstruction (default).
/// </summary>
[InspectorName("Medium")]
Medium = 1,
/// <summary>
/// High quality - more samples, better accuracy.
/// </summary>
[InspectorName("High")]
High = 2
}
/// <summary>
/// Blur quality for the ambient occlusion texture.
/// </summary>
public enum ScreenSpaceAmbientOcclusionBlurQuality
{
/// <summary>
/// Low quality - Kawase blur, best performance.
/// </summary>
[InspectorName("Low (Kawase)")]
Low = 0,
/// <summary>
/// Medium quality - Gaussian blur, balanced performance.
/// </summary>
[InspectorName("Medium (Gaussian)")]
Medium = 1,
/// <summary>
/// High quality - bilateral blur for edge-preserving smoothing.
/// </summary>
[InspectorName("High (Bilateral)")]
High = 2
}
/// <summary>
/// Spatial filter for GTAO compute path.
/// </summary>
public enum ScreenSpaceAmbientOcclusionSpatialFilter
{
/// <summary>
/// Two-pass normal-guided bilateral filter.
/// </summary>
[InspectorName("Bilateral")]
Bilateral = 0,
/// <summary>
/// Normal-guided box filter with tangent-plane depth rejection.
/// </summary>
[InspectorName("Box")]
Box = 1
}
/// <summary>
/// Quality presets for ambient occlusion settings.
/// </summary>
public enum ScreenSpaceAmbientOcclusionQuality
{
/// <summary>
/// Low quality preset - better performance, lower accuracy.
/// </summary>
[InspectorName("Low")]
Low = 0,
/// <summary>
/// Medium quality preset - balanced quality and performance (default).
/// </summary>
[InspectorName("Medium")]
Medium = 1,
/// <summary>
/// High quality preset - best visual quality with increased cost.
/// </summary>
[InspectorName("High")]
High = 2,
/// <summary>
/// Custom quality - user-defined parameters.
/// </summary>
[InspectorName("Custom")]
Custom = 3
}
/// <summary>
/// A volume component that holds settings for the Screen Space Ambient Occlusion effect.
/// </summary>
[Serializable, VolumeComponentMenu("Lighting/Screen Space Ambient Occlusion")]
[DisplayInfo(name = "Screen Space Ambient Occlusion")]
[SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))]
[VolumeRequiresRendererFeatures(typeof(ScreenSpaceAmbientOcclusion))]
[URPHelpURL("urp/post-processing-ssao")]
public sealed class ScreenSpaceAmbientOcclusionVolumeOverride : VolumeComponent, IPostProcessComponent
{
/// <summary>
/// Ambient occlusion rendering mode.
/// </summary>
public ScreenSpaceAmbientOcclusionMode mode
{
get => m_Mode.value;
set => m_Mode.value = value;
}
[Tooltip("The ambient occlusion algorithm to use. Standard uses the Alchemy SSAO method. GTAO (Ground Truth Ambient Occlusion) provides higher quality.")]
[SerializeField]
private ScreenSpaceAmbientOcclusionModeParameter m_Mode = new ScreenSpaceAmbientOcclusionModeParameter(ScreenSpaceAmbientOcclusionMode.None);
/// <summary>
/// Quality preset for ambient occlusion. Selecting a preset automatically configures all quality-related parameters.
/// Select Custom to manually adjust individual parameters.
/// </summary>
public ScreenSpaceAmbientOcclusionQuality quality
{
get => m_Quality.value;
set => m_Quality.value = value;
}
[Tooltip("Quality preset for ambient occlusion. Custom allows manual adjustment of all parameters.")]
[SerializeField]
private ScreenSpaceAmbientOcclusionQualityParameter m_Quality = new ScreenSpaceAmbientOcclusionQualityParameter(ScreenSpaceAmbientOcclusionQuality.Medium);
// ====================
// Common Parameters
// ====================
/// <summary>
/// Intensity of the ambient occlusion effect. Higher values produce darker occlusion.
/// </summary>
public float intensity
{
get => m_Intensity.value;
set => m_Intensity.value = value;
}
[Tooltip("Controls the strength of the ambient occlusion effect. Increase this value to produce darker areas.")]
[SerializeField]
private ClampedFloatParameter m_Intensity = new ClampedFloatParameter(1f, 0f, 5f);
/// <summary>
/// Radius around each point for ambient occlusion calculation.
/// </summary>
public float radius
{
get => m_Radius.value;
set => m_Radius.value = value;
}
[Tooltip("The radius around a given point where Unity calculates and applies the effect. Larger values cover more area but may reduce performance due to increased texture sampling.")]
[SerializeField]
private ClampedFloatParameter m_Radius = new ClampedFloatParameter(0.3f, 0.01f, 5f);
/// <summary>
/// Controls how much the ambient occlusion affects direct lighting.
/// </summary>
public float directLightingStrength
{
get => m_DirectLightingStrength.value;
set => m_DirectLightingStrength.value = value;
}
[Tooltip("Controls how visible the ambient occlusion effect is on surfaces lit by direct light sources. Higher values apply occlusion more uniformly across all lighting, not just in shadowed areas.")]
[SerializeField]
private ClampedFloatParameter m_DirectLightingStrength = new ClampedFloatParameter(0f, 0f, 1f);
/// <summary>
/// Distance from the camera beyond which ambient occlusion fades out.
/// </summary>
public float falloffDistance
{
get => m_FalloffDistance.value;
set => m_FalloffDistance.value = value;
}
[Tooltip("The distance from the camera where Ambient Occlusion should be visible. Beyond this distance, AO will fade out.")]
[SerializeField]
private MinFloatParameter m_FalloffDistance = new MinFloatParameter(100f, 0f);
/// <summary>
/// Sample count for ambient occlusion. Higher values improve quality at performance cost.
/// </summary>
public ScreenSpaceAmbientOcclusionSampleCount sampleCount
{
get
{
var q = m_Quality.value;
return q == ScreenSpaceAmbientOcclusionQuality.Custom ? m_SampleCount.value : GetPresetSampleCount(q);
}
set => m_SampleCount.value = value;
}
[Tooltip("The quality of the ambient occlusion sampling. Higher quality uses more samples/steps but provides better results.")]
[SerializeField]
private ScreenSpaceAmbientOcclusionSampleCountParameter m_SampleCount = new ScreenSpaceAmbientOcclusionSampleCountParameter(ScreenSpaceAmbientOcclusionSampleCount.Medium);
/// <summary>
/// Enable downsampling of the SSAO texture to improve performance.
/// </summary>
public bool downsample
{
get
{
var q = m_Quality.value;
return q == ScreenSpaceAmbientOcclusionQuality.Custom ? m_Downsample.value : GetPresetDownsample(q);
}
set => m_Downsample.value = value;
}
[Tooltip("With this option enabled, Unity downsamples the SSAO effect texture to improve performance.")]
[SerializeField]
private BoolParameter m_Downsample = new BoolParameter(false);
/// <summary>
/// Apply SSAO after the opaque pass. Can improve performance on mobile and tiled GPUs.
/// </summary>
public bool afterOpaque
{
get => m_AfterOpaque.value;
set => m_AfterOpaque.value = value;
}
[Tooltip("When enabled, SSAO is applied as a multiply on the final opaque image after rendering. This can improve performance on tiled GPUs but may produce slightly different visual results compared to applying SSAO during lighting.")]
[SerializeField]
private BoolParameter m_AfterOpaque = new BoolParameter(false);
/// <summary>
/// Blur quality for the ambient occlusion texture. Higher quality reduces noise at performance cost.
/// </summary>
public ScreenSpaceAmbientOcclusionBlurQuality blurQuality
{
get
{
var q = m_Quality.value;
return q == ScreenSpaceAmbientOcclusionQuality.Custom ? m_BlurQuality.value : GetPresetBlurQuality(q);
}
set => m_BlurQuality.value = value;
}
[Tooltip("The blur quality to apply to the ambient occlusion texture. Higher quality reduces noise but is more expensive.")]
[SerializeField]
private ScreenSpaceAmbientOcclusionBlurQualityParameter m_BlurQuality = new ScreenSpaceAmbientOcclusionBlurQualityParameter(ScreenSpaceAmbientOcclusionBlurQuality.High);
// ====================
// Default Mode Parameters
// ====================
/// <summary>
/// Noise method for ambient occlusion sampling.
/// </summary>
public ScreenSpaceAmbientOcclusionNoiseMethod method
{
get => m_Method.value;
set => m_Method.value = value;
}
[Tooltip("'Interleaved Gradient Noise' generates static SSAO and is more performant. 'Blue Noise' generates dynamic SSAO at a slightly higher cost, producing a more subtle effect when the camera is in motion.")]
[SerializeField]
private ScreenSpaceAmbientOcclusionNoiseMethodParameter m_Method = new ScreenSpaceAmbientOcclusionNoiseMethodParameter(ScreenSpaceAmbientOcclusionNoiseMethod.InterleavedGradient);
/// <summary>
/// Source of depth and normal data for ambient occlusion.
/// </summary>
public ScreenSpaceAmbientOcclusionDepthSource depthSource
{
get
{
var q = m_Quality.value;
return q == ScreenSpaceAmbientOcclusionQuality.Custom ? m_DepthSource.value : GetPresetDepthSource(q);
}
set => m_DepthSource.value = value;
}
[Tooltip("The source of the depth and normal data. Depth Normals is more accurate but requires the depth-normals prepass.")]
[SerializeField]
private ScreenSpaceAmbientOcclusionDepthSourceParameter m_DepthSource = new ScreenSpaceAmbientOcclusionDepthSourceParameter(ScreenSpaceAmbientOcclusionDepthSource.DepthNormals);
/// <summary>
/// Normal reconstruction quality when computing normals from depth.
/// Only used when depth source is set to Depth.
/// </summary>
public ScreenSpaceAmbientOcclusionNormalQuality normalQuality
{
get
{
var q = m_Quality.value;
return q == ScreenSpaceAmbientOcclusionQuality.Custom ? m_NormalQuality.value : GetPresetNormalQuality(q);
}
set => m_NormalQuality.value = value;
}
[Tooltip("The number of depth texture samples that Unity takes when computing normals from depth. Only used when Depth Source is set to Depth.")]
[SerializeField]
private ScreenSpaceAmbientOcclusionNormalQualityParameter m_NormalQuality = new ScreenSpaceAmbientOcclusionNormalQualityParameter(ScreenSpaceAmbientOcclusionNormalQuality.Medium);
// ====================
// GTAO Mode Parameters
// ====================
/// <summary>
/// Minimum radius in pixels for GTAO sampling. Acts as a screen-space floor on the projected world-space <see cref="radius"/> so the effect does not vanish at a distance.
/// </summary>
public int minimumRadiusInPixels
{
get => m_MinimumRadiusInPixels.value;
set => m_MinimumRadiusInPixels.value = value;
}
[Tooltip("Minimum radius in pixels guaranteed by GTAO. Acts as a screen-space floor on the world-space Radius so the effect remains visible at a distance.")]
[SerializeField]
private ClampedIntParameter m_MinimumRadiusInPixels = new ClampedIntParameter(40, 1, 256);
/// <summary>
/// When enabled, uses compute shaders for GTAO calculation.
/// Provides temporal filtering support and configurable direction/step counts.
/// </summary>
public bool useComputeShader
{
get => m_UseComputeShader.value;
set => m_UseComputeShader.value = value;
}
[Tooltip("When enabled, uses compute shaders for GTAO calculation. Provides temporal filtering support and configurable direction/step counts.")]
[SerializeField]
private BoolParameter m_UseComputeShader = new BoolParameter(false);
/// <summary>
/// Spatial filter used by the GTAO compute path.
/// </summary>
public ScreenSpaceAmbientOcclusionSpatialFilter spatialFilter
{
get => m_SpatialFilter.value;
set => m_SpatialFilter.value = value;
}
[Tooltip("Spatial filter used by the GTAO compute path.")]
[SerializeField]
private ScreenSpaceAmbientOcclusionSpatialFilterParameter m_SpatialFilter = new ScreenSpaceAmbientOcclusionSpatialFilterParameter(ScreenSpaceAmbientOcclusionSpatialFilter.Bilateral);
// ============================
// Temporal Filter Parameters
// ============================
/// <summary>
/// Enable temporal filtering for noise reduction and temporal stability.
/// When enabled, sample rotation and offsets vary over time.
/// </summary>
public bool temporalFilter
{
get => m_TemporalFilter.value;
set => m_TemporalFilter.value = value;
}
[Tooltip("Enable temporal filtering to reduce noise and improve stability over time. Requires Motion Vectors.")]
[SerializeField]
private BoolParameter m_TemporalFilter = new BoolParameter(false);
/// <summary>
/// Controls how aggressively temporal accumulation reduces ghosting.
/// Higher values reject more history, reducing ghosting at the cost of temporal stability.
/// </summary>
public float ghostingMitigation
{
get => m_GhostingMitigation.value;
set => m_GhostingMitigation.value = value;
}
[Tooltip("Controls how aggressively temporal accumulation reduces ghosting. Higher values reject more history but can increase noise.")]
[SerializeField]
private ClampedFloatParameter m_GhostingMitigation = new ClampedFloatParameter(0.5f, 0.0f, 1.0f);
/// <summary>
/// Length of the temporal history used by temporal accumulation.
/// Higher values accumulate more frames for smoother, more stable results.
/// </summary>
public float historyLength
{
get => m_HistoryLength.value;
set => m_HistoryLength.value = value;
}
[Tooltip("Controls the length of the temporal history. Higher values produce smoother, more stable results but can increase ghosting.")]
[SerializeField]
private ClampedFloatParameter m_HistoryLength = new ClampedFloatParameter(0.9f, 0.0f, 1.0f);
// ============================
// GTAO Compute Parameters
// ============================
/// <summary>
/// Number of directions to sample for GTAO. More directions improve quality but increase cost.
/// </summary>
public int directionCount
{
get
{
var q = m_Quality.value;
return q == ScreenSpaceAmbientOcclusionQuality.Custom ? m_DirectionCount.value : GetPresetDirectionCount(q);
}
set => m_DirectionCount.value = value;
}
[Tooltip("Number of directions to sample for GTAO. More directions improve quality but increase cost.")]
[SerializeField]
private ClampedIntParameter m_DirectionCount = new ClampedIntParameter(2, 1, 8);
/// <summary>
/// Number of steps per direction for GTAO. More steps improve quality but increase cost.
/// </summary>
public int stepCount
{
get
{
var q = m_Quality.value;
return q == ScreenSpaceAmbientOcclusionQuality.Custom ? m_StepCount.value : GetPresetStepCount(q);
}
set => m_StepCount.value = value;
}
[Tooltip("Number of steps per direction for GTAO. More steps improve quality but increase cost.")]
[SerializeField]
private ClampedIntParameter m_StepCount = new ClampedIntParameter(4, 1, 16);
// ============================
// Quality Preset Lookups
// ============================
internal static bool GetPresetDownsample(ScreenSpaceAmbientOcclusionQuality q) => q switch
{
ScreenSpaceAmbientOcclusionQuality.Low => true,
ScreenSpaceAmbientOcclusionQuality.Medium => true,
_ => false, // High
};
internal static ScreenSpaceAmbientOcclusionSampleCount GetPresetSampleCount(ScreenSpaceAmbientOcclusionQuality q) => q switch
{
ScreenSpaceAmbientOcclusionQuality.Low => ScreenSpaceAmbientOcclusionSampleCount.Low,
ScreenSpaceAmbientOcclusionQuality.Medium => ScreenSpaceAmbientOcclusionSampleCount.Medium,
_ => ScreenSpaceAmbientOcclusionSampleCount.High,
};
internal static ScreenSpaceAmbientOcclusionBlurQuality GetPresetBlurQuality(ScreenSpaceAmbientOcclusionQuality q) => q switch
{
ScreenSpaceAmbientOcclusionQuality.Low => ScreenSpaceAmbientOcclusionBlurQuality.Low,
ScreenSpaceAmbientOcclusionQuality.Medium => ScreenSpaceAmbientOcclusionBlurQuality.Medium,
_ => ScreenSpaceAmbientOcclusionBlurQuality.High,
};
internal static ScreenSpaceAmbientOcclusionDepthSource GetPresetDepthSource(ScreenSpaceAmbientOcclusionQuality q) => q switch
{
ScreenSpaceAmbientOcclusionQuality.Low => ScreenSpaceAmbientOcclusionDepthSource.Depth,
ScreenSpaceAmbientOcclusionQuality.Medium => ScreenSpaceAmbientOcclusionDepthSource.DepthNormals,
_ => ScreenSpaceAmbientOcclusionDepthSource.DepthNormals, // High
};
internal static ScreenSpaceAmbientOcclusionNormalQuality GetPresetNormalQuality(ScreenSpaceAmbientOcclusionQuality q) => q switch
{
ScreenSpaceAmbientOcclusionQuality.Low => ScreenSpaceAmbientOcclusionNormalQuality.Low,
ScreenSpaceAmbientOcclusionQuality.Medium => ScreenSpaceAmbientOcclusionNormalQuality.Medium,
_ => ScreenSpaceAmbientOcclusionNormalQuality.High,
};
internal static int GetPresetDirectionCount(ScreenSpaceAmbientOcclusionQuality q) => q switch
{
ScreenSpaceAmbientOcclusionQuality.Low => 1,
ScreenSpaceAmbientOcclusionQuality.Medium => 2,
_ => 4, // High
};
internal static int GetPresetStepCount(ScreenSpaceAmbientOcclusionQuality q) => q switch
{
ScreenSpaceAmbientOcclusionQuality.Low => 2,
ScreenSpaceAmbientOcclusionQuality.Medium => 4,
_ => 6, // High
};
/// <summary>
/// Query if the effect is active and should be rendered.
/// </summary>
/// <returns><c>true</c> if the effect should be rendered, <c>false</c> otherwise.</returns>
public bool IsActive() => m_Mode.value != ScreenSpaceAmbientOcclusionMode.None && m_Intensity.value > 0f && m_Radius.value > 0f && m_FalloffDistance.value > 0f;
/// <summary>
/// Query if the effect is using the Standard SSAO mode.
/// </summary>
/// <returns><c>true</c> if using Standard mode, <c>false</c> otherwise.</returns>
public bool IsStandardMode() => m_Mode.value == ScreenSpaceAmbientOcclusionMode.Standard;
/// <summary>
/// Query if blue noise sampling is enabled.
/// </summary>
/// <returns><c>true</c> if blue noise sampling is enabled, <c>false</c> otherwise.</returns>
public bool IsBlueNoiseEnabled() => m_Method.value == ScreenSpaceAmbientOcclusionNoiseMethod.BlueNoise;
}
// ============================
// Volume Parameter Types
// ============================
/// <summary>
/// A <see cref="VolumeParameter"/> that holds a <see cref="ScreenSpaceAmbientOcclusionMode"/> value.
/// </summary>
[Serializable]
public sealed class ScreenSpaceAmbientOcclusionModeParameter : VolumeParameter<ScreenSpaceAmbientOcclusionMode>
{
/// <summary>
/// Creates a new <see cref="ScreenSpaceAmbientOcclusionModeParameter"/> instance.
/// </summary>
/// <param name="value">The initial value to store in the parameter.</param>
/// <param name="overrideState">The initial override state for the parameter.</param>
public ScreenSpaceAmbientOcclusionModeParameter(ScreenSpaceAmbientOcclusionMode value, bool overrideState = false) : base(value, overrideState) { }
}
/// <summary>
/// A <see cref="VolumeParameter"/> that holds a <see cref="ScreenSpaceAmbientOcclusionNoiseMethod"/> value.
/// </summary>
[Serializable]
public sealed class ScreenSpaceAmbientOcclusionNoiseMethodParameter : VolumeParameter<ScreenSpaceAmbientOcclusionNoiseMethod>
{
/// <summary>
/// Creates a new <see cref="ScreenSpaceAmbientOcclusionNoiseMethodParameter"/> instance.
/// </summary>
/// <param name="value">The initial value to store in the parameter.</param>
/// <param name="overrideState">The initial override state for the parameter.</param>
public ScreenSpaceAmbientOcclusionNoiseMethodParameter(ScreenSpaceAmbientOcclusionNoiseMethod value, bool overrideState = false) : base(value, overrideState) { }
}
/// <summary>
/// A <see cref="VolumeParameter"/> that holds a <see cref="ScreenSpaceAmbientOcclusionSampleCount"/> value.
/// </summary>
[Serializable]
public sealed class ScreenSpaceAmbientOcclusionSampleCountParameter : VolumeParameter<ScreenSpaceAmbientOcclusionSampleCount>
{
/// <summary>
/// Creates a new <see cref="ScreenSpaceAmbientOcclusionSampleCountParameter"/> instance.
/// </summary>
/// <param name="value">The initial value to store in the parameter.</param>
/// <param name="overrideState">The initial override state for the parameter.</param>
public ScreenSpaceAmbientOcclusionSampleCountParameter(ScreenSpaceAmbientOcclusionSampleCount value, bool overrideState = false) : base(value, overrideState) { }
}
/// <summary>
/// A <see cref="VolumeParameter"/> that holds a <see cref="ScreenSpaceAmbientOcclusionDepthSource"/> value.
/// </summary>
[Serializable]
public sealed class ScreenSpaceAmbientOcclusionDepthSourceParameter : VolumeParameter<ScreenSpaceAmbientOcclusionDepthSource>
{
/// <summary>
/// Creates a new <see cref="ScreenSpaceAmbientOcclusionDepthSourceParameter"/> instance.
/// </summary>
/// <param name="value">The initial value to store in the parameter.</param>
/// <param name="overrideState">The initial override state for the parameter.</param>
public ScreenSpaceAmbientOcclusionDepthSourceParameter(ScreenSpaceAmbientOcclusionDepthSource value, bool overrideState = false) : base(value, overrideState) { }
}
/// <summary>
/// A <see cref="VolumeParameter"/> that holds a <see cref="ScreenSpaceAmbientOcclusionNormalQuality"/> value.
/// </summary>
[Serializable]
public sealed class ScreenSpaceAmbientOcclusionNormalQualityParameter : VolumeParameter<ScreenSpaceAmbientOcclusionNormalQuality>
{
/// <summary>
/// Creates a new <see cref="ScreenSpaceAmbientOcclusionNormalQualityParameter"/> instance.
/// </summary>
/// <param name="value">The initial value to store in the parameter.</param>
/// <param name="overrideState">The initial override state for the parameter.</param>
public ScreenSpaceAmbientOcclusionNormalQualityParameter(ScreenSpaceAmbientOcclusionNormalQuality value, bool overrideState = false) : base(value, overrideState) { }
}
/// <summary>
/// A <see cref="VolumeParameter"/> that holds a <see cref="ScreenSpaceAmbientOcclusionBlurQuality"/> value.
/// </summary>
[Serializable]
public sealed class ScreenSpaceAmbientOcclusionBlurQualityParameter : VolumeParameter<ScreenSpaceAmbientOcclusionBlurQuality>
{
/// <summary>
/// Creates a new <see cref="ScreenSpaceAmbientOcclusionBlurQualityParameter"/> instance.
/// </summary>
/// <param name="value">The initial value to store in the parameter.</param>
/// <param name="overrideState">The initial override state for the parameter.</param>
public ScreenSpaceAmbientOcclusionBlurQualityParameter(ScreenSpaceAmbientOcclusionBlurQuality value, bool overrideState = false) : base(value, overrideState) { }
}
/// <summary>
/// A <see cref="VolumeParameter"/> that holds a <see cref="ScreenSpaceAmbientOcclusionSpatialFilter"/> value.
/// </summary>
[Serializable]
public sealed class ScreenSpaceAmbientOcclusionSpatialFilterParameter : VolumeParameter<ScreenSpaceAmbientOcclusionSpatialFilter>
{
/// <summary>
/// Creates a new <see cref="ScreenSpaceAmbientOcclusionSpatialFilterParameter"/> instance.
/// </summary>
/// <param name="value">The initial value to store in the parameter.</param>
/// <param name="overrideState">The initial override state for the parameter.</param>
public ScreenSpaceAmbientOcclusionSpatialFilterParameter(ScreenSpaceAmbientOcclusionSpatialFilter value, bool overrideState = false) : base(value, overrideState) { }
}
/// <summary>
/// A <see cref="VolumeParameter"/> that holds a <see cref="ScreenSpaceAmbientOcclusionQuality"/> value.
/// </summary>
[Serializable]
public sealed class ScreenSpaceAmbientOcclusionQualityParameter : VolumeParameter<ScreenSpaceAmbientOcclusionQuality>
{
/// <summary>
/// Creates a new <see cref="ScreenSpaceAmbientOcclusionQualityParameter"/> instance.
/// </summary>
/// <param name="value">The initial value to store in the parameter.</param>
/// <param name="overrideState">The initial override state for the parameter.</param>
public ScreenSpaceAmbientOcclusionQualityParameter(ScreenSpaceAmbientOcclusionQuality value, bool overrideState = false) : base(value, overrideState) { }
}
}
#endif
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 5182da28fcdc1ac41a47126f0d404cf8
@@ -0,0 +1,291 @@
using System;
namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// The resolution at which URP computes the Screen Space Lens Flare effect.
/// </summary>
public enum ScreenSpaceLensFlareResolution : int
{
/// <summary>
/// Half Resolution.
/// </summary>
Half = 2,
/// <summary>
/// Quarter Resolution.
/// </summary>
Quarter = 4,
/// <summary>
/// Eigtht Resolution.
/// </summary>
Eighth = 8
}
/// <summary>
/// A volume component that holds settings for the Screen Space Lens Flare effect.
/// </summary>
/// <remarks>
/// You can add <see cref="VolumeComponent"/> to a <see cref="VolumeProfile"/> in the Editor to apply a Screen Space Lens Flare post-processing effect.
/// </remarks>
/// <example>
/// <para>This sample code shows how settings can be retrieved and modified in runtime:</para>
/// <code>
/// 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 ScreenSpaceLensFlare m_VolumeComponent;
///
/// [Serializable]
/// private struct VolumeSettings
/// {
/// public bool active;
/// public MinFloatParameter intensity;
/// public ColorParameter tintColor;
/// public ClampedIntParameter bloomMip;
/// public MinFloatParameter firstFlareIntensity;
/// public MinFloatParameter secondaryFlareIntensity;
/// public MinFloatParameter warpedFlareIntensity;
/// public Vector2Parameter warpedFlareScale;
/// public ClampedIntParameter samples;
/// public ClampedFloatParameter sampleDimmer;
/// public ClampedFloatParameter vignetteEffect;
/// public ClampedFloatParameter startingPosition;
/// public ClampedFloatParameter scale;
/// public MinFloatParameter streaksIntensity;
/// public ClampedFloatParameter streaksLength;
/// public FloatParameter streaksOrientation;
/// public ClampedFloatParameter streaksThreshold;
/// public ScreenSpaceLensFlareResolutionParameter resolution;
/// public ClampedFloatParameter chromaticAbberationIntensity;
///
///
/// public void SetVolumeComponentSettings(ref ScreenSpaceLensFlare volumeComponent)
/// {
/// volumeComponent.active = active;
/// volumeComponent.firstFlareIntensity = firstFlareIntensity;
/// volumeComponent.secondaryFlareIntensity = secondaryFlareIntensity;
/// volumeComponent.warpedFlareIntensity = warpedFlareIntensity;
/// volumeComponent.warpedFlareScale = warpedFlareScale;
/// volumeComponent.samples = samples;
/// volumeComponent.sampleDimmer = sampleDimmer;
/// volumeComponent.vignetteEffect = vignetteEffect;
/// volumeComponent.startingPosition = startingPosition;
/// volumeComponent.scale = scale;
/// volumeComponent.streaksIntensity = streaksIntensity;
/// volumeComponent.streaksLength = streaksLength;
/// volumeComponent.streaksOrientation = streaksOrientation;
/// volumeComponent.streaksThreshold = streaksThreshold;
/// volumeComponent.resolution = resolution;
/// volumeComponent.chromaticAbberationIntensity = chromaticAbberationIntensity;
/// }
///
/// public void GetVolumeComponentSettings(ref ScreenSpaceLensFlare volumeComponent)
/// {
/// active = volumeComponent.active;
/// firstFlareIntensity = volumeComponent.firstFlareIntensity;
/// secondaryFlareIntensity = volumeComponent.secondaryFlareIntensity;
/// warpedFlareIntensity = volumeComponent.warpedFlareIntensity;
/// warpedFlareScale = volumeComponent.warpedFlareScale;
/// samples = volumeComponent.samples;
/// sampleDimmer = volumeComponent.sampleDimmer;
/// vignetteEffect = volumeComponent.vignetteEffect;
/// startingPosition = volumeComponent.startingPosition;
/// scale = volumeComponent.scale;
/// streaksIntensity = volumeComponent.streaksIntensity;
/// streaksLength = volumeComponent.streaksLength;
/// streaksOrientation = volumeComponent.streaksOrientation;
/// streaksThreshold = volumeComponent.streaksThreshold;
/// resolution = volumeComponent.resolution;
/// chromaticAbberationIntensity = volumeComponent.chromaticAbberationIntensity;
/// }
/// }
///
/// 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 ScreenSpaceLensFlare volumeComponent)
/// {
/// if (volumeComponent != null)
/// return true;
///
/// if (volumeProfile == null)
/// {
/// Debug.LogError("ModifyVolumeComponent.GetVolumeComponent():\nvolumeProfile has not been assigned.");
/// return false;
/// }
///
/// volumeProfile.TryGet(out ScreenSpaceLensFlare component);
/// if (component == null)
/// {
/// Debug.LogError($"ModifyVolumeComponent.GetVolumeComponent():\nMissing component in the \"{volumeProfile.name}\" VolumeProfile ");
/// return false;
/// }
///
/// volumeComponent = component;
/// return true;
/// }
/// }
/// </code>
/// </example>
/// <seealso cref="VolumeProfile"/>
/// <seealso cref="VolumeComponent"/>
/// <seealso cref="IPostProcessComponent"/>
/// <seealso cref="VolumeParameter{T}"/>
/// <seealso cref="MinFloatParameter"/>
/// <seealso cref="ColorParameter"/>
/// <seealso cref="ClampedIntParameter"/>
/// <seealso cref="Vector2Parameter"/>
/// <seealso cref="ClampedFloatParameter"/>
/// <seealso cref="FloatParameter"/>
/// <seealso cref="ScreenSpaceLensFlareResolutionParameter"/>
[Serializable, VolumeComponentMenu("Post-processing/Screen Space Lens Flare")]
[SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))]
[URPHelpURL("urp/shared/lens-flare/lens-flare-component")]
[DisplayInfo(name = "Screen Space Lens Flare")]
public class ScreenSpaceLensFlare : VolumeComponent, IPostProcessComponent
{
/// <summary>
/// Sets the global intensity of the Screen Space Lens Flare effect. When set to 0, the pass is skipped.
/// </summary>
public MinFloatParameter intensity = new MinFloatParameter(0f, 0f);
/// <summary>
/// Sets the color used to tint all the flares.
/// </summary>
public ColorParameter tintColor = new ColorParameter(Color.white);
/// <summary>
/// Controls the bloom Mip used as a source for the Lens Flare effect. A high value will result in a blurrier result for all flares.
/// </summary>
[AdditionalProperty]
public ClampedIntParameter bloomMip = new ClampedIntParameter(1, 0, 5);
/// <summary>
/// Controls the intensity of the Regular Flare sample. Those flares are sampled using scaled screen coordinates.
/// </summary>
[Header("Flares")]
public MinFloatParameter firstFlareIntensity = new MinFloatParameter(1f, 0f);
/// <summary>
/// Controls the intensity of the Reversed Flare sample. Those flares are sampled using scaled and flipped screen coordinates.
/// </summary>
public MinFloatParameter secondaryFlareIntensity = new MinFloatParameter(1f, 0f);
/// <summary>
/// Controls the intensity of the Warped Flare sample. Those flares are sampled using polar screen coordinates.
/// </summary>
public MinFloatParameter warpedFlareIntensity = new MinFloatParameter(1f, 0f);
/// <summary>
/// Sets the scale of the warped flare. A value of 1,1 will keep this flare circular.
/// </summary>
[AdditionalProperty]
public Vector2Parameter warpedFlareScale = new Vector2Parameter(new Vector2(1f, 1f));
/// <summary>
/// Controls the number of times the flare effect is repeated for each flare type (first, second, warped). This parameter has a strong impact on performance.
/// </summary>
public ClampedIntParameter samples = new ClampedIntParameter(1, 1, 3);
/// <summary>
/// Controls the value by which each additional sample is multiplied. A value of 1 keep the same intensities for all samples. A value of 0.7 multiplies the first sample by 1 (0.7 power 0), the second sample by 0.7 (0.7 power 1) and the third sample by 0.49 (0.7 power 2).
/// </summary>
[AdditionalProperty]
public ClampedFloatParameter sampleDimmer = new ClampedFloatParameter(0.5f, 0.1f, 1f);
/// <summary>
/// Controls the intensity of the vignette effect to occlude the Lens Flare effect at the center of the screen.
/// </summary>
public ClampedFloatParameter vignetteEffect = new ClampedFloatParameter(1f, 0f, 1f);
/// <summary>
/// Controls the starting position of the flares in screen space relative to their source.
/// </summary>
public ClampedFloatParameter startingPosition = new ClampedFloatParameter(1.25f, 1f, 3f);
/// <summary>
/// Controls the scale at which the flare effect is sampled.
/// </summary>
public ClampedFloatParameter scale = new ClampedFloatParameter(1.5f, 1f, 4f);
/// <summary>
/// Controls the intensity of streaks effect. This effect has an impact on performance when above zero. When this intensity is zero, this effect is not evaluated to save costs.
/// </summary>
[Header("Streaks")]
public MinFloatParameter streaksIntensity = new MinFloatParameter(0f, 0f);
/// <summary>
/// Controls the length of streaks effect. A value of one creates streaks about the width of the screen.
/// </summary>
public ClampedFloatParameter streaksLength = new ClampedFloatParameter(0.5f, 0f, 1f);
/// <summary>
/// Controls the orientation of streaks effect in degrees. A value of 0 produces horizontal streaks.
/// </summary>
public FloatParameter streaksOrientation = new FloatParameter(0f);
/// <summary>
/// Controls the threshold of horizontal streak effect. A high value makes the effect more localised on the high intensity areas of the screen.
/// </summary>
public ClampedFloatParameter streaksThreshold = new ClampedFloatParameter(0.25f, 0f, 1f);
/// <summary>
/// Specifies the resolution at which the streak effect is evaluated.
/// </summary>
[SerializeField]
[AdditionalProperty]
public ScreenSpaceLensFlareResolutionParameter resolution = new ScreenSpaceLensFlareResolutionParameter(ScreenSpaceLensFlareResolution.Quarter);
/// <summary>
/// Controls the strength of the Chromatic Aberration effect. The higher the value, the more light is dispersed on the sides of the screen
/// </summary>
[Header("Chromatic Abberation")]
public ClampedFloatParameter chromaticAbberationIntensity = new ClampedFloatParameter(0.5f, 0f, 1f);
/// <summary>
/// Tells if the post process needs to be rendered or not.
/// </summary>
/// <returns><c>true</c> if the effect should be rendered, <c>false</c> otherwise.</returns>
public bool IsActive()
{
return intensity.value > 0;
}
/// <summary>
/// Returns true is streakIntensity is above zero.
/// </summary>
/// <returns></returns>
public bool IsStreaksActive()
{
return streaksIntensity.value > 0;
}
/// <summary>
/// Tells if the post process can run the effect on-tile or if it needs a full pass.
/// </summary>
/// <returns><c>true</c> if it can run on-tile, <c>false</c> otherwise.</returns>
[Obsolete("Unused. #from(2023.1)")]
public bool IsTileCompatible() => false;
}
/// <summary>
/// A <see cref="VolumeParameter"/> that holds a <see cref="ScreenSpaceLensFlareResolution"/> value.
/// </summary>
[Serializable]
public sealed class ScreenSpaceLensFlareResolutionParameter : VolumeParameter<ScreenSpaceLensFlareResolution>
{
/// <summary>
/// Creates a new <see cref="ScreenSpaceLensFlareResolutionParameter"/> instance.
/// </summary>
/// <param name="value">The initial value to store in the parameter.</param>
/// <param name="overrideState">The initial override state for the parameter.</param>
public ScreenSpaceLensFlareResolutionParameter(ScreenSpaceLensFlareResolution value, bool overrideState = false) : base(value, overrideState) { }
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 06437c1ff663d574d9447842ba0a72e4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,175 @@
using System;
namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// A volume component that holds settings for the Shadows, Midtones, Highlights effect.
/// </summary>
/// <remarks>
/// You can add <see cref="VolumeComponent"/> to a <see cref="VolumeProfile"/> in the Editor to apply a Shadows, Midtones, Highlights post-processing effect.
/// </remarks>
/// <example>
/// <para>This sample code shows how settings can be retrieved and modified in runtime:</para>
/// <code>
/// 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 ShadowsMidtonesHighlights m_VolumeComponent;
///
/// [Serializable]
/// private struct VolumeSettings
/// {
/// public bool active;
/// public Vector4Parameter shadows;
/// public Vector4Parameter midtones;
/// public Vector4Parameter highlights;
/// public MinFloatParameter shadowsStart;
/// public MinFloatParameter shadowsEnd;
/// public MinFloatParameter highlightsStart;
/// public MinFloatParameter highlightsEnd;
///
///
/// public void SetVolumeComponentSettings(ref ShadowsMidtonesHighlights volumeComponent)
/// {
/// volumeComponent.active = active;
/// volumeComponent.shadows = shadows;
/// volumeComponent.midtones = midtones;
/// volumeComponent.highlights = highlights;
/// volumeComponent.shadowsStart = shadowsStart;
/// volumeComponent.shadowsEnd = shadowsEnd;
/// volumeComponent.highlightsStart = highlightsStart;
/// volumeComponent.highlightsEnd = highlightsEnd;
/// }
///
/// public void GetVolumeComponentSettings(ref ShadowsMidtonesHighlights volumeComponent)
/// {
/// active = volumeComponent.active;
/// shadows = volumeComponent.shadows;
/// midtones = volumeComponent.midtones;
/// highlights = volumeComponent.highlights;
/// shadowsStart = volumeComponent.shadowsStart;
/// shadowsEnd = volumeComponent.shadowsEnd;
/// highlightsStart = volumeComponent.highlightsStart;
/// highlightsEnd = volumeComponent.highlightsEnd;
/// }
/// }
///
/// 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 ShadowsMidtonesHighlights volumeComponent)
/// {
/// if (volumeComponent != null)
/// return true;
///
/// if (volumeProfile == null)
/// {
/// Debug.LogError("ModifyVolumeComponent.GetVolumeComponent():\nvolumeProfile has not been assigned.");
/// return false;
/// }
///
/// volumeProfile.TryGet(out ShadowsMidtonesHighlights component);
/// if (component == null)
/// {
/// Debug.LogError($"ModifyVolumeComponent.GetVolumeComponent():\nMissing component in the \"{volumeProfile.name}\" VolumeProfile ");
/// return false;
/// }
///
/// volumeComponent = component;
/// return true;
/// }
/// }
/// </code>
/// </example>
/// <seealso cref="VolumeProfile"/>
/// <seealso cref="VolumeComponent"/>
/// <seealso cref="IPostProcessComponent"/>
/// <seealso cref="VolumeParameter{T}"/>
/// <seealso cref="Vector4Parameter"/>
/// <seealso cref="MinFloatParameter"/>
[Serializable, VolumeComponentMenu("Post-processing/Shadows, Midtones, Highlights")]
[SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))]
[URPHelpURL("urp/Post-Processing-Shadows-Midtones-Highlights")]
public sealed class ShadowsMidtonesHighlights : VolumeComponent, IPostProcessComponent
{
/// <summary>
/// Use this to control and apply a hue to the shadows.
/// </summary>
public Vector4Parameter shadows = new Vector4Parameter(new Vector4(1f, 1f, 1f, 0f));
/// <summary>
/// Use this to control and apply a hue to the midtones.
/// </summary>
public Vector4Parameter midtones = new Vector4Parameter(new Vector4(1f, 1f, 1f, 0f));
/// <summary>
/// Use this to control and apply a hue to the highlights.
/// </summary>
public Vector4Parameter highlights = new Vector4Parameter(new Vector4(1f, 1f, 1f, 0f));
/// <summary>
/// Start point of the transition between shadows and midtones.
/// </summary>
[Header("Shadow Limits")]
[Tooltip("Start point of the transition between shadows and midtones.")]
public MinFloatParameter shadowsStart = new MinFloatParameter(0f, 0f);
/// <summary>
/// End point of the transition between shadows and midtones.
/// </summary>
[Tooltip("End point of the transition between shadows and midtones.")]
public MinFloatParameter shadowsEnd = new MinFloatParameter(0.3f, 0f);
/// <summary>
/// Start point of the transition between midtones and highlights
/// </summary>
[Header("Highlight Limits")]
[Tooltip("Start point of the transition between midtones and highlights.")]
public MinFloatParameter highlightsStart = new MinFloatParameter(0.55f, 0f);
/// <summary>
/// End point of the transition between midtones and highlights.
/// </summary>
[Tooltip("End point of the transition between midtones and highlights.")]
public MinFloatParameter highlightsEnd = new MinFloatParameter(1f, 0f);
/// <summary>
/// Tells if the post process needs to be rendered or not.
/// </summary>
/// <returns><c>true</c> if the effect should be rendered, <c>false</c> otherwise.</returns>
public bool IsActive()
{
var defaultState = new Vector4(1f, 1f, 1f, 0f);
return shadows != defaultState
|| midtones != defaultState
|| highlights != defaultState;
}
/// <summary>
/// Tells if the post process can run the effect on-tile or if it needs a full pass.
/// </summary>
/// <returns><c>true</c> if it can run on-tile, <c>false</c> otherwise.</returns>
[Obsolete("Unused. #from(2023.1)")]
public bool IsTileCompatible() => true;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 558a8e2b6826cf840aae193990ba9f2e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,134 @@
using System;
namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// A volume component that holds settings for the Split Toning effect.
/// </summary>
/// <remarks>
/// You can add <see cref="VolumeComponent"/> to a <see cref="VolumeProfile"/> in the Editor to apply a Split Toning post-processing effect.
/// </remarks>
/// <example>
/// <para>This sample code shows how settings can be retrieved and modified in runtime:</para>
/// <code>
/// 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;
/// }
/// }
/// </code>
/// </example>
/// <seealso cref="VolumeProfile"/>
/// <seealso cref="VolumeComponent"/>
/// <seealso cref="IPostProcessComponent"/>
/// <seealso cref="VolumeParameter{T}"/>
/// <seealso cref="ColorParameter"/>
/// <seealso cref="ClampedFloatParameter"/>
[Serializable, VolumeComponentMenu("Post-processing/Split Toning")]
[SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))]
[URPHelpURL("urp/Post-Processing-Split-Toning")]
public sealed class SplitToning : VolumeComponent, IPostProcessComponent
{
/// <summary>
/// The color to use for shadows.
/// </summary>
[Tooltip("The color to use for shadows.")]
public ColorParameter shadows = new ColorParameter(Color.grey, false, false, true);
/// <summary>
/// The color to use for highlights.
/// </summary>
[Tooltip("The color to use for highlights.")]
public ColorParameter highlights = new ColorParameter(Color.grey, false, false, true);
/// <summary>
/// Balance between the colors in the highlights and shadows.
/// </summary>
[Tooltip("Balance between the colors in the highlights and shadows.")]
public ClampedFloatParameter balance = new ClampedFloatParameter(0f, -100f, 100f);
/// <summary>
/// Tells if the post process needs to be rendered or not.
/// </summary>
/// <returns><c>true</c> if the effect should be rendered, <c>false</c> otherwise.</returns>
public bool IsActive() => shadows != Color.grey || highlights != Color.grey;
/// <summary>
/// Tells if the post process can run the effect on-tile or if it needs a full pass.
/// </summary>
/// <returns><c>true</c> if it can run on-tile, <c>false</c> otherwise.</returns>
[Obsolete("Unused. #from(2023.1)")]
public bool IsTileCompatible() => true;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 70afe9e12c7a7ed47911bb608a23a8ff
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,306 @@
#if SURFACE_CACHE
using System;
namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// A volume component that holds settings for the Surface Cache Global Illumination feature.
/// </summary>
[Serializable, VolumeComponentMenu("Lighting/Surface Cache Global Illumination")]
[SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))]
public class SurfaceCacheGIVolumeOverride : VolumeComponent
{
const PresetQuality k_defaultPresetQuality = PresetQuality.Medium;
/// <summary>
/// Enables or disables Surface Cache Global Illumination. When disabled, the feature
/// performs no work and contributes no indirect lighting.
/// </summary>
[Tooltip("Enables Surface Cache Global Illumination. When disabled, the feature performs no work.")]
public BoolParameter enabled = new BoolParameter(true);
// ====================
// Sampling Parameters
// ====================
/// <summary>
/// Enable multi-bounce global illumination.
/// </summary>
[Tooltip("Enable multi-bounce global illumination for more accurate light propagation.")]
public BoolParameter multiBounce = new BoolParameter(k_Presets[(int)k_defaultPresetQuality].multiBounce);
/// <summary>
/// Bounce Patch Allocation. When enabled, new patches are allocated at ray hit locations when multi-bounce cache lookups fail.
/// </summary>
[Tooltip("When enabled, new patches are allocated at ray hit locations when multi-bounce cache lookups fail.")]
public BoolParameter bouncePatchAllocation = new BoolParameter(k_Presets[(int)k_defaultPresetQuality].bouncePatchAllocation);
/// <summary>
/// Number of samples used for GI estimation. Higher values improve quality at performance cost.
/// </summary>
public ClampedIntParameter sampleCount = new ClampedIntParameter(k_Presets[(int)k_defaultPresetQuality].sampleCount, 1, 32);
// ============================
// Patch Filtering Parameters
// ============================
/// <summary>
/// Temporal smoothing factor for patch data. Higher values produce more stable results but slower response to lighting changes.
/// </summary>
public ClampedFloatParameter temporalSmoothing = new ClampedFloatParameter(k_Presets[(int)k_defaultPresetQuality].temporalSmoothing, 0.0f, 1.0f);
/// <summary>
/// Enable spatial filtering for patch data.
/// </summary>
public BoolParameter spatialFilterEnabled = new BoolParameter(k_Presets[(int)k_defaultPresetQuality].spatialFilterEnabled);
/// <summary>
/// Number of samples for spatial filtering. Higher values improve quality at performance cost.
/// </summary>
public ClampedIntParameter spatialSampleCount = new ClampedIntParameter(k_Presets[(int)k_defaultPresetQuality].spatialSampleCount, 1, 8);
/// <summary>
/// Radius for spatial filtering in world units.
/// </summary>
public ClampedFloatParameter spatialRadius = new ClampedFloatParameter(k_Presets[(int)k_defaultPresetQuality].spatialRadius, 0.1f, 4.0f);
/// <summary>
/// Enable temporal post-filtering for additional image stability.
/// </summary>
public BoolParameter temporalPostFilter = new BoolParameter(k_Presets[(int)k_defaultPresetQuality].temporalPostFilter);
// ============================
// Screen Filtering Parameters
// ============================
/// <summary>
/// Number of samples for screen-space lookups.
/// </summary>
public ClampedIntParameter lookupSampleCount = new ClampedIntParameter(k_Presets[(int)k_defaultPresetQuality].lookupSampleCount, 0, 8);
/// <summary>
/// Kernel size for upsampling filtering.
/// </summary>
public ClampedFloatParameter upsamplingKernelSize = new ClampedFloatParameter(k_Presets[(int)k_defaultPresetQuality].upsamplingKernelSize, 0.0f, 8.0f);
/// <summary>
/// Number of samples for upsampling. Higher values improve quality at performance cost.
/// </summary>
public ClampedIntParameter upsamplingSampleCount = new ClampedIntParameter(k_Presets[(int)k_defaultPresetQuality].upsamplingSampleCount, 1, 16);
// =======================
// Volume Configuration
// =======================
/// <summary>
/// Size of the surface cache volume in world units.
/// This can be changed per-scene without causing a performance hitch.
/// </summary>
public MinFloatParameter volumeSize = new MinFloatParameter(128.0f, 1.0f);
/// <summary>
/// Spatial resolution of the surface cache volume. Higher values improve spatial detail but use more memory.
/// Changing this at runtime can cause a performance hitch as internal buffers are reallocated (BVH is preserved).
/// </summary>
public ClampedIntParameter volumeResolution = new ClampedIntParameter(32, 16, 128);
/// <summary>
/// Number of cascades for the surface cache volume. More cascades extend the volume's reach.
/// Changing this at runtime can cause a performance hitch as internal buffers are reallocated (BVH is preserved).
/// </summary>
public ClampedIntParameter volumeCascadeCount = new ClampedIntParameter(4, 1, 8);
// =======================
// Volume Behavior
// =======================
/// <summary>
/// Enable volume cascades to follow the camera.
/// </summary>
public BoolParameter cascadeMovement = new BoolParameter(true);
// =======================
// Advanced Properties
// =======================
/// <summary>
/// Number of surface cache patches to defragment per frame.
/// </summary>
[AdditionalProperty]
public ClampedIntParameter defragCount = new ClampedIntParameter(2, 1, 32);
/// <summary>
/// Only renderers whose Rendering Layer Mask intersects this mask contribute to Surface Cache Global Illumination.
/// </summary>
[AdditionalProperty]
[Tooltip("Only renderers whose Rendering Layer Mask intersects this mask contribute to Surface Cache Global Illumination.")]
public RenderingLayerMaskParameter renderingLayerMask = new RenderingLayerMaskParameter(0xFFFFFFFF);
// =======================
// Preset Utility
// =======================
/// <summary>
/// Quality presets for Surface Cache Global Illumination.
/// </summary>
public enum PresetQuality
{
/// <summary>
/// Low quality preset - minimal samples, maximum performance.
/// </summary>
Low,
/// <summary>
/// Medium quality preset - balanced quality and performance (default).
/// </summary>
Medium,
/// <summary>
/// High quality preset - higher quality with increased cost.
/// </summary>
High,
/// <summary>
/// Ultra quality preset - maximum quality, highest cost.
/// </summary>
Ultra,
/// <summary>
/// Custom quality - user-defined parameters.
/// </summary>
Custom
}
struct Preset
{
public bool multiBounce;
public bool bouncePatchAllocation;
public int sampleCount;
public float temporalSmoothing;
public bool spatialFilterEnabled;
public int spatialSampleCount;
public float spatialRadius;
public bool temporalPostFilter;
public int lookupSampleCount;
public float upsamplingKernelSize;
public int upsamplingSampleCount;
}
// Quality preset definitions; indexed by Quality (Low=0, Medium=1, High=2, Ultra=3).
static readonly Preset[] k_Presets =
{
// Low
new Preset
{
multiBounce = false, bouncePatchAllocation = false, sampleCount = 1,
temporalSmoothing = 0.9f, spatialFilterEnabled = false, spatialSampleCount = 4, spatialRadius = 1.0f, temporalPostFilter = false,
lookupSampleCount = 4, upsamplingKernelSize = 2.0f, upsamplingSampleCount = 1,
},
// Medium
new Preset
{
multiBounce = true, bouncePatchAllocation = true, sampleCount = 2,
temporalSmoothing = 0.8f, spatialFilterEnabled = true, spatialSampleCount = 4, spatialRadius = 1.0f, temporalPostFilter = true,
lookupSampleCount = 6, upsamplingKernelSize = 4.0f, upsamplingSampleCount = 2,
},
// High
new Preset
{
multiBounce = true, bouncePatchAllocation = true, sampleCount = 4,
temporalSmoothing = 0.7f, spatialFilterEnabled = true, spatialSampleCount = 6, spatialRadius = 1.5f, temporalPostFilter = true,
lookupSampleCount = 8, upsamplingKernelSize = 5.0f, upsamplingSampleCount = 4,
},
// Ultra
new Preset
{
multiBounce = true, bouncePatchAllocation = true, sampleCount = 8,
temporalSmoothing = 0.6f, spatialFilterEnabled = true, spatialSampleCount = 8, spatialRadius = 2.0f, temporalPostFilter = true,
lookupSampleCount = 8, upsamplingKernelSize = 7.0f, upsamplingSampleCount = 8,
},
};
// Writes preset values into the backing serialized fields so users can inspect them
// and use them as a starting point when switching to Custom.
public void ApplyPreset(PresetQuality quality)
{
if (quality == PresetQuality.Custom) return;
ref readonly var settings = ref k_Presets[(int)quality];
multiBounce.value = settings.multiBounce;
multiBounce.overrideState = true;
bouncePatchAllocation.value = settings.bouncePatchAllocation;
bouncePatchAllocation.overrideState = true;
sampleCount.value = settings.sampleCount;
sampleCount.overrideState = true;
temporalSmoothing.value = settings.temporalSmoothing;
temporalSmoothing.overrideState = true;
spatialFilterEnabled.value = settings.spatialFilterEnabled;
spatialFilterEnabled.overrideState = true;
spatialSampleCount.value = settings.spatialSampleCount;
spatialSampleCount.overrideState = true;
spatialRadius.value = settings.spatialRadius;
spatialRadius.overrideState = true;
temporalPostFilter.value = settings.temporalPostFilter;
temporalPostFilter.overrideState = true;
lookupSampleCount.value = settings.lookupSampleCount;
lookupSampleCount.overrideState = true;
upsamplingKernelSize.value = settings.upsamplingKernelSize;
upsamplingKernelSize.overrideState = true;
upsamplingSampleCount.value = settings.upsamplingSampleCount;
upsamplingSampleCount.overrideState = true;
}
public PresetQuality GetPresetQuality()
{
if(HasPresetOverridesEnabled())
{
if (HasPresetQualityValues (PresetQuality.Low)) return PresetQuality.Low;
if (HasPresetQualityValues (PresetQuality.Medium)) return PresetQuality.Medium;
if (HasPresetQualityValues (PresetQuality.High)) return PresetQuality.High;
if (HasPresetQualityValues(PresetQuality.Ultra)) return PresetQuality.Ultra;
}
return PresetQuality.Custom;
}
public bool HasPresetOverridesEnabled()
{
return multiBounce.overrideState == true
&& bouncePatchAllocation.overrideState == true
&& sampleCount.overrideState == true
&& temporalSmoothing.overrideState == true
&& spatialFilterEnabled.overrideState == true
&& spatialSampleCount.overrideState == true
&& spatialRadius.overrideState == true
&& temporalPostFilter.overrideState == true
&& lookupSampleCount.overrideState == true
&& upsamplingKernelSize.overrideState == true
&& upsamplingSampleCount.overrideState == true;
}
public bool HasPresetQualityValues(PresetQuality quality)
{
if (quality == PresetQuality.Custom) return true;
ref readonly var preset = ref k_Presets[(int)quality];
return multiBounce.value == preset.multiBounce
&& bouncePatchAllocation.value == preset.bouncePatchAllocation
&& sampleCount.value == preset.sampleCount
&& temporalSmoothing.value == preset.temporalSmoothing
&& spatialFilterEnabled.value == preset.spatialFilterEnabled
&& spatialSampleCount.value == preset.spatialSampleCount
&& spatialRadius.value == preset.spatialRadius
&& temporalPostFilter.value == preset.temporalPostFilter
&& lookupSampleCount.value == preset.lookupSampleCount
&& upsamplingKernelSize.value == preset.upsamplingKernelSize
&& upsamplingSampleCount.value == preset.upsamplingSampleCount;
}
#if UNITY_EDITOR
internal event Action propertyChanged;
private void OnValidate() => propertyChanged?.Invoke();
#endif
}
}
#endif
@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: ac1e685d8f7565142b879339cd471764
@@ -0,0 +1,294 @@
using System;
namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// Options to select a tonemapping algorithm to use for color grading.
/// </summary>
public enum TonemappingMode
{
/// <summary>
/// Use this option if you do not want to apply tonemapping
/// </summary>
None,
/// <summary>
/// Use this option if you only want range-remapping with minimal impact on color hue and saturation.
/// It is generally a great starting point for extensive color grading.
/// </summary>
Neutral, // Neutral tonemapper
/// <summary>
/// Use this option to apply a close approximation of the reference ACES tonemapper for a more filmic look.
/// It is more contrasted than Neutral and has an effect on actual color hue and saturation.
/// Note that if you use this tonemapper all the grading operations will be done in the ACES color spaces for optimal precision and results.
/// </summary>
ACES, // ACES Filmic reference tonemapper (custom approximation)
}
/// <summary>
/// Available options for when HDR Output is enabled and Tonemap is set to Neutral.
/// </summary>
public enum NeutralRangeReductionMode
{
/// <summary>
/// Simple Reinhard tonemapping curve.
/// </summary>
Reinhard = HDRRangeReduction.Reinhard,
/// <summary>
/// Range reduction curve as specified in the BT.2390 standard.
/// </summary>
BT2390 = HDRRangeReduction.BT2390
}
/// <summary>
/// Preset used when selecting ACES tonemapping for HDR displays.
/// </summary>
public enum HDRACESPreset
{
/// <summary>
/// Preset for a display with a maximum range of 1000 nits.
/// </summary>
ACES1000Nits = HDRRangeReduction.ACES1000Nits,
/// <summary>
/// Preset for a display with a maximum range of 2000 nits.
/// </summary>
ACES2000Nits = HDRRangeReduction.ACES2000Nits,
/// <summary>
/// Preset for a display with a maximum range of 4000 nits.
/// </summary>
ACES4000Nits = HDRRangeReduction.ACES4000Nits,
}
/// <summary>
/// A volume component that holds settings for the tonemapping effect.
/// </summary>
/// <remarks>
/// You can add <see cref="VolumeComponent"/> to a <see cref="VolumeProfile"/> in the Editor to apply a tonemapping post-processing effect.
/// </remarks>
/// <example>
/// <para>This sample code shows how settings can be retrieved and modified in runtime:</para>
/// <code>
/// 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 Tonemapping m_VolumeComponent;
///
/// [Serializable]
/// private struct VolumeSettings
/// {
/// public bool active;
/// public TonemappingModeParameter mode;
/// public NeutralRangeReductionModeParameter neutralHDRRangeReductionMode;
/// public HDRACESPresetParameter acesPreset;
/// public ClampedFloatParameter hueShiftAmount;
/// public BoolParameter detectPaperWhite;
/// public ClampedFloatParameter paperWhite;
/// public BoolParameter detectBrightnessLimits;
/// public ClampedFloatParameter minNits;
/// public ClampedFloatParameter maxNits;
///
///
/// public void SetVolumeComponentSettings(ref Tonemapping volumeComponent)
/// {
/// volumeComponent.active = active;
/// volumeComponent.mode = mode;
/// volumeComponent.neutralHDRRangeReductionMode = neutralHDRRangeReductionMode;
/// volumeComponent.acesPreset = acesPreset;
/// volumeComponent.hueShiftAmount = hueShiftAmount;
/// volumeComponent.detectPaperWhite = detectPaperWhite;
/// volumeComponent.paperWhite = paperWhite;
/// volumeComponent.detectBrightnessLimits = detectBrightnessLimits;
/// volumeComponent.minNits = minNits;
/// volumeComponent.maxNits = maxNits;
/// }
///
/// public void GetVolumeComponentSettings(ref Tonemapping volumeComponent)
/// {
/// active = volumeComponent.active;
/// mode = volumeComponent.mode;
/// neutralHDRRangeReductionMode = volumeComponent.neutralHDRRangeReductionMode;
/// acesPreset = volumeComponent.acesPreset;
/// hueShiftAmount = volumeComponent.hueShiftAmount;
/// detectPaperWhite = volumeComponent.detectPaperWhite;
/// paperWhite = volumeComponent.paperWhite;
/// detectBrightnessLimits = volumeComponent.detectBrightnessLimits;
/// minNits = volumeComponent.minNits;
/// maxNits = volumeComponent.maxNits;
/// }
/// }
///
/// 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 Tonemapping volumeComponent)
/// {
/// if (volumeComponent != null)
/// return true;
///
/// if (volumeProfile == null)
/// {
/// Debug.LogError("ModifyVolumeComponent.GetVolumeComponent():\nvolumeProfile has not been assigned.");
/// return false;
/// }
///
/// volumeProfile.TryGet(out Tonemapping component);
/// if (component == null)
/// {
/// Debug.LogError($"ModifyVolumeComponent.GetVolumeComponent():\nMissing component in the \"{volumeProfile.name}\" VolumeProfile ");
/// return false;
/// }
///
/// volumeComponent = component;
/// return true;
/// }
/// }
/// </code>
/// </example>
/// <seealso cref="VolumeProfile"/>
/// <seealso cref="VolumeComponent"/>
/// <seealso cref="IPostProcessComponent"/>
/// <seealso cref="VolumeParameter{T}"/>
/// <seealso cref="TonemappingModeParameter"/>
/// <seealso cref="NeutralRangeReductionModeParameter"/>
/// <seealso cref="HDRACESPresetParameter"/>
/// <seealso cref="ClampedFloatParameter"/>
/// <seealso cref="BoolParameter"/>
[Serializable, VolumeComponentMenu("Post-processing/Tonemapping")]
[SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))]
[URPHelpURL("urp/post-processing-tonemapping")]
public sealed class Tonemapping : VolumeComponent, IPostProcessComponent
{
/// <summary>
/// Use this to select a tonemapping algorithm to use for color grading.
/// </summary>
[Tooltip("Select a tonemapping algorithm to use for the color grading process.")]
public TonemappingModeParameter mode = new TonemappingModeParameter(TonemappingMode.None);
// -- HDR Output options --
/// <summary>
/// Specifies the range reduction mode used when HDR output is enabled and Neutral tonemapping is enabled.
/// </summary>
[AdditionalProperty]
[Tooltip("Specifies the range reduction mode used when HDR output is enabled and Neutral tonemapping is enabled.")]
public NeutralRangeReductionModeParameter neutralHDRRangeReductionMode = new NeutralRangeReductionModeParameter(NeutralRangeReductionMode.BT2390);
/// <summary>
/// Specifies the preset for HDR displays.
/// </summary>
[Tooltip("Use the ACES preset for HDR displays.")]
public HDRACESPresetParameter acesPreset = new HDRACESPresetParameter(HDRACESPreset.ACES1000Nits);
/// <summary>
/// Specify how much hue to preserve. Values closer to 0 are likely to preserve hue. As values get closer to 1, Unity doesn't correct hue shifts.
/// </summary>
[Tooltip("Specify how much hue to preserve. Values closer to 0 are likely to preserve hue. As values get closer to 1, Unity doesn't correct hue shifts.")]
public ClampedFloatParameter hueShiftAmount = new ClampedFloatParameter(0.0f, 0.0f, 1.0f);
/// <summary>
/// Enable to use values detected from the output device as paper white. When enabled, output images might differ between SDR and HDR. For best accuracy, set this value manually.
/// </summary>
[Tooltip("Enable to use values detected from the output device as paper white. When enabled, output images might differ between SDR and HDR. For best accuracy, set this value manually.")]
public BoolParameter detectPaperWhite = new BoolParameter(false);
/// <summary>
/// The reference brightness of a paper white surface. This property determines the maximum brightness of UI. The brightness of the scene is scaled relative to this value. The value is in nits.
/// </summary>
[Tooltip("The reference brightness of a paper white surface. This property determines the maximum brightness of UI. The brightness of the scene is scaled relative to this value. The value is in nits.")]
public ClampedFloatParameter paperWhite = new ClampedFloatParameter(300.0f, 0.0f, 400.0f);
/// <summary>
/// Enable to use the minimum and maximum brightness values detected from the output device. For best accuracy, considering calibrating these values manually.
/// </summary>
[Tooltip("Enable to use the minimum and maximum brightness values detected from the output device. For best accuracy, considering calibrating these values manually.")]
public BoolParameter detectBrightnessLimits = new BoolParameter(true);
/// <summary>
/// The minimum brightness of the screen (in nits). This value is assumed to be 0.005f with ACES Tonemap.
/// </summary>
[Tooltip("The minimum brightness of the screen (in nits). This value is assumed to be 0.005f with ACES Tonemap.")]
public ClampedFloatParameter minNits = new ClampedFloatParameter(0.005f, 0.0f, 50.0f);
/// <summary>
/// The maximum brightness of the screen (in nits). This value is defined by the preset when using ACES Tonemap.
/// </summary>
[Tooltip("The maximum brightness of the screen (in nits). This value is defined by the preset when using ACES Tonemap.")]
public ClampedFloatParameter maxNits = new ClampedFloatParameter(1000.0f, 0.0f, 5000.0f);
/// <summary>
/// Tells if the post process needs to be rendered or not.
/// </summary>
/// <returns><c>true</c> if the effect should be rendered, <c>false</c> otherwise.</returns>
public bool IsActive() => mode.value != TonemappingMode.None;
/// <summary>
/// Tells if the post process can run the effect on-tile or if it needs a full pass.
/// </summary>
/// <returns><c>true</c> if it can run on-tile, <c>false</c> otherwise.</returns>
[Obsolete("Unused. #from(2023.1)")]
public bool IsTileCompatible() => true;
}
/// <summary>
/// A <see cref="VolumeParameter"/> that holds a <see cref="TonemappingMode"/> value.
/// </summary>
[Serializable]
public sealed class TonemappingModeParameter : VolumeParameter<TonemappingMode>
{
/// <summary>
/// Creates a new <see cref="TonemappingModeParameter"/> instance.
/// </summary>
/// <param name="value">The initial value to store in the parameter.</param>
/// <param name="overrideState">The initial override state for the parameter.</param>
public TonemappingModeParameter(TonemappingMode value, bool overrideState = false) : base(value, overrideState) { }
}
/// <summary>
/// A <see cref="VolumeParameter"/> that contains a <see cref="NeutralRangeReductionMode"/> value.
/// </summary>
[Serializable]
public sealed class NeutralRangeReductionModeParameter : VolumeParameter<NeutralRangeReductionMode>
{
/// <summary>
/// Creates a new <see cref="NeutralRangeReductionModeParameter"/> instance.
/// </summary>
/// <param name="value">The initial value to store in the parameter.</param>
/// <param name="overrideState">The initial override state for the parameter.</param>
public NeutralRangeReductionModeParameter(NeutralRangeReductionMode value, bool overrideState = false) : base(value, overrideState) { }
}
/// <summary>
/// A <see cref="VolumeParameter"/> that contains a <see cref="HDRACESPreset"/> value.
/// </summary>
[Serializable]
public sealed class HDRACESPresetParameter : VolumeParameter<HDRACESPreset>
{
/// <summary>
/// Creates a new <see cref="HDRACESPresetParameter"/> instance.
/// </summary>
/// <param name="value">The initial value to store in the parameter.</param>
/// <param name="overrideState">The initial override state for the parameter.</param>
public HDRACESPresetParameter(HDRACESPreset value, bool overrideState = false) : base(value, overrideState) { }
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 97c23e3b12dc18c42a140437e53d3951
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,154 @@
using System;
namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// A volume component that holds settings for the Vignette effect.
/// </summary>
/// <remarks>
/// You can add <see cref="VolumeComponent"/> to a <see cref="VolumeProfile"/> in the Editor to apply a Vignette post-processing effect.
/// </remarks>
/// <example>
/// <para>This sample code shows how settings can be retrieved and modified in runtime:</para>
/// <code>
/// 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 Vignette m_VolumeComponent;
///
/// [Serializable]
/// private struct VolumeSettings
/// {
/// public bool active;
/// public ColorParameter color;
/// public Vector2Parameter center;
/// public ClampedFloatParameter intensity;
/// public ClampedFloatParameter smoothness;
/// public BoolParameter rounded;
///
///
/// public void SetVolumeComponentSettings(ref Vignette volumeComponent)
/// {
/// volumeComponent.active = active;
/// volumeComponent.color = color;
/// volumeComponent.center = center;
/// volumeComponent.intensity = intensity;
/// volumeComponent.smoothness = smoothness;
/// volumeComponent.rounded = rounded;
/// }
///
/// public void GetVolumeComponentSettings(ref Vignette volumeComponent)
/// {
/// active = volumeComponent.active;
/// color = volumeComponent.color;
/// center = volumeComponent.center;
/// intensity = volumeComponent.intensity;
/// smoothness = volumeComponent.smoothness;
/// rounded = volumeComponent.rounded;
/// }
/// }
///
/// 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 Vignette volumeComponent)
/// {
/// if (volumeComponent != null)
/// return true;
///
/// if (volumeProfile == null)
/// {
/// Debug.LogError("ModifyVolumeComponent.GetVolumeComponent():\nvolumeProfile has not been assigned.");
/// return false;
/// }
///
/// volumeProfile.TryGet(out Vignette component);
/// if (component == null)
/// {
/// Debug.LogError($"ModifyVolumeComponent.GetVolumeComponent():\nMissing component in the \"{volumeProfile.name}\" VolumeProfile ");
/// return false;
/// }
///
/// volumeComponent = component;
/// return true;
/// }
/// }
/// </code>
/// </example>
/// <seealso cref="VolumeProfile"/>
/// <seealso cref="VolumeComponent"/>
/// <seealso cref="IPostProcessComponent"/>
/// <seealso cref="VolumeParameter{T}"/>
/// <seealso cref="ColorParameter"/>
/// <seealso cref="BoolParameter"/>
/// <seealso cref="ClampedFloatParameter"/>
/// <seealso cref="Vector2Parameter"/>
[Serializable, VolumeComponentMenu("Post-processing/Vignette")]
[SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))]
[URPHelpURL("urp/post-processing-vignette")]
public sealed class Vignette : VolumeComponent, IPostProcessComponent
{
/// <summary>
/// Specifies the color of the vignette.
/// </summary>
[Tooltip("Vignette color.")]
public ColorParameter color = new ColorParameter(Color.black, false, false, true);
/// <summary>
/// Sets the center point for the vignette.
/// </summary>
[Tooltip("Sets the vignette center point (screen center is [0.5,0.5]).")]
public Vector2Parameter center = new Vector2Parameter(new Vector2(0.5f, 0.5f));
/// <summary>
/// Controls the strength of the vignette effect.
/// </summary>
[Tooltip("Use the slider to set the strength of the Vignette effect.")]
public ClampedFloatParameter intensity = new ClampedFloatParameter(0f, 0f, 1f);
/// <summary>
/// Controls the smoothness of the vignette borders.
/// </summary>
[Tooltip("Smoothness of the vignette borders.")]
public ClampedFloatParameter smoothness = new ClampedFloatParameter(0.2f, 0.01f, 1f);
/// <summary>
/// Controls how round the vignette is, lower values result in a more square vignette.
/// </summary>
[Tooltip("Should the vignette be perfectly round or be dependent on the current aspect ratio?")]
public BoolParameter rounded = new BoolParameter(false);
/// <summary>
/// Tells if the post process needs to be rendered or not.
/// </summary>
/// <returns><c>true</c> if the effect should be rendered, <c>false</c> otherwise.</returns>
public bool IsActive() => intensity.value > 0f;
/// <summary>
/// Tells if the post process can run the effect on-tile or if it needs a full pass.
/// </summary>
/// <returns><c>true</c> if it can run on-tile, <c>false</c> otherwise.</returns>
[Obsolete("Unused. #from(2023.1)")]
public bool IsTileCompatible() => true;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 899c54efeace73346a0a16faa3afe726
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,123 @@
using System;
namespace UnityEngine.Rendering.Universal
{
/// <summary>
/// A volume component that holds settings for the White Balance effect.
/// </summary>
/// <remarks>
/// You can add <see cref="VolumeComponent"/> to a <see cref="VolumeProfile"/> in the Editor to apply a White Balance post-processing effect.
/// </remarks>
/// <example>
/// <para>This sample code shows how settings can be retrieved and modified in runtime:</para>
/// <code>
/// 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 WhiteBalance m_VolumeComponent;
///
/// [Serializable]
/// private struct VolumeSettings
/// {
/// public bool active;
/// public ClampedFloatParameter temperature;
/// public ClampedFloatParameter tint;
///
/// public void SetVolumeComponentSettings(ref WhiteBalance volumeComponent)
/// {
/// volumeComponent.active = active;
/// volumeComponent.temperature = temperature;
/// volumeComponent.tint = tint;
/// }
///
/// public void GetVolumeComponentSettings(ref WhiteBalance volumeComponent)
/// {
/// active = volumeComponent.active;
/// temperature = volumeComponent.temperature;
/// tint = volumeComponent.tint;
/// }
/// }
///
/// 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 WhiteBalance volumeComponent)
/// {
/// if (volumeComponent != null)
/// return true;
///
/// if (volumeProfile == null)
/// {
/// Debug.LogError("ModifyVolumeComponent.GetVolumeComponent():\nvolumeProfile has not been assigned.");
/// return false;
/// }
///
/// volumeProfile.TryGet(out WhiteBalance component);
/// if (component == null)
/// {
/// Debug.LogError($"ModifyVolumeComponent.GetVolumeComponent():\nMissing component in the \"{volumeProfile.name}\" VolumeProfile ");
/// return false;
/// }
///
/// volumeComponent = component;
/// return true;
/// }
/// }
/// </code>
/// </example>
/// <seealso cref="VolumeProfile"/>
/// <seealso cref="VolumeComponent"/>
/// <seealso cref="IPostProcessComponent"/>
/// <seealso cref="VolumeParameter{T}"/>
/// <seealso cref="ClampedFloatParameter"/>
[Serializable, VolumeComponentMenu("Post-processing/White Balance")]
[SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))]
[URPHelpURL("urp/Post-Processing-White-Balance")]
public sealed class WhiteBalance : VolumeComponent, IPostProcessComponent
{
/// <summary>
/// Controls the color temperature URP uses for white balancing.
/// </summary>
[Tooltip("Sets the white balance to a custom color temperature.")]
public ClampedFloatParameter temperature = new ClampedFloatParameter(0f, -100, 100f);
/// <summary>
/// Controls the white balance color to compensate for a green or magenta tint.
/// </summary>
[Tooltip("Sets the white balance to compensate for a green or magenta tint.")]
public ClampedFloatParameter tint = new ClampedFloatParameter(0f, -100, 100f);
/// <summary>
/// Tells if the post process needs to be rendered or not.
/// </summary>
/// <returns><c>true</c> if the effect should be rendered, <c>false</c> otherwise.</returns>
public bool IsActive() => temperature.value != 0f || tint.value != 0f;
/// <summary>
/// Tells if the post process can run the effect on-tile or if it needs a full pass.
/// </summary>
/// <returns><c>true</c> if it can run on-tile, <c>false</c> otherwise.</returns>
[Obsolete("Unused. #from(2023.1)")]
public bool IsTileCompatible() => true;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 221518ef91623a7438a71fef23660601
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: