using System; using UnityEngine.Experimental.Rendering; using UnityEngine.Serialization; using UnityEngine.Rendering; namespace UnityEngine.Rendering.HighDefinition { /// /// A volume component that holds settings for the ambient occlusion. /// [Serializable, VolumeComponentMenu("Lighting/Ambient Occlusion")] [SupportedOnRenderPipeline(typeof(HDRenderPipelineAsset))] [HDRPHelpURL("Override-Ambient-Occlusion")] public sealed class ScreenSpaceAmbientOcclusion : VolumeComponentWithQuality { // WW1MOD added AO mode public enum AmbientOcclusionMode { Default, Cacao, HTRACE //Amplify, } /// /// Enable ray traced ambient occlusion. /// public BoolParameter rayTracing = new BoolParameter(false); /// /// Selects the AO implementation. /// public EnumParameter aoMode = new(AmbientOcclusionMode.Default); // WW1MOD added AO mode /// /// Controls the strength of the ambient occlusion effect. Increase this value to produce darker areas. /// public ClampedFloatParameter intensity = new ClampedFloatParameter(0f, 0f, 4f); /// /// Controls how much the ambient occlusion affects direct lighting. /// public ClampedFloatParameter directLightingStrength = new ClampedFloatParameter(0f, 0f, 1f); /// /// Sampling radius. Bigger the radius, wider AO will be achieved, risking to lose fine details and increasing cost of the effect due to increasing cache misses. /// public ClampedFloatParameter radius = new ClampedFloatParameter(2.0f, 0.25f, 5.0f); /// /// Shadow multiplier value for FidelityFX CACAO. /// public ClampedFloatParameter shadowMultiplier = new ClampedFloatParameter(1.0f, 0.0f, 5.0f); // WW1MOD added CACAO /// /// Horizon angle threshold value for FidelityFX CACAO. /// public ClampedFloatParameter horizonAngleThreshold = new ClampedFloatParameter(0.06f, 0.0f, 0.2f); // WW1MOD added CACAO /// /// Detail shadow strength value for FidelityFX CACAO. /// public ClampedFloatParameter detailShadowStrength = new ClampedFloatParameter(0.5f, 0f, 5f); // WW1MOD added CACAO /// /// Moving this factor closer to 0 will increase the amount of accepted samples during temporal accumulation, increasing the ghosting, but reducing the temporal noise. /// public ClampedFloatParameter spatialBilateralAggressiveness = new ClampedFloatParameter(0.15f, 0.0f, 1.0f); /// /// Whether the results are accumulated over time or not. This can get higher quality results at a cheaper cost, but it can lead to temporal artifacts such as ghosting. /// public BoolParameter temporalAccumulation = new BoolParameter(true); // Temporal only parameters /// /// Moving this factor closer to 0 will increase the amount of accepted samples during temporal accumulation, increasing the ghosting, but reducing the temporal noise. /// public ClampedFloatParameter ghostingReduction = new ClampedFloatParameter(0.5f, 0.0f, 1.0f); // Non-temporal only parameters /// /// Modify the non-temporal blur to change how sharp features are preserved. Lower values leads to blurrier/softer results, higher values gets a sharper result, but with the risk of noise. /// public ClampedFloatParameter blurSharpness = new ClampedFloatParameter(0.1f, 0.0f, 1.0f); // Ray tracing parameters /// /// Defines the layers that ray traced ambient occlusion should include. /// public LayerMaskParameter layerMask = new LayerMaskParameter(-1); /// /// Controls the influence of the ambient occlusion on the specular occlusion. /// [AdditionalProperty] public ClampedFloatParameter specularOcclusion = new ClampedFloatParameter(0.5f, 0.0f, 1.0f); /// /// Controls the length of ray traced ambient occlusion rays. /// public float rayLength { get { if (!UsesQualitySettings()) return m_RayLength.value; else return GetLightingQualitySettings().RTAORayLength[(int)quality.value]; } set { m_RayLength.value = value; } } /// /// Number of samples for evaluating the effect. /// public int sampleCount { get { if (!UsesQualitySettings()) return m_SampleCount.value; else return GetLightingQualitySettings().RTAOSampleCount[(int)quality.value]; } set { m_SampleCount.value = value; } } /// /// Defines if the ray traced ambient occlusion should be denoised. /// public bool denoise { get { if (!UsesQualitySettings()) return m_Denoise.value; else return GetLightingQualitySettings().RTAODenoise[(int)quality.value]; } set { m_Denoise.value = value; } } /// /// Controls the radius of the ray traced ambient occlusion denoiser. /// public float denoiserRadius { get { if (!UsesQualitySettings()) return m_DenoiserRadius.value; else return GetLightingQualitySettings().RTAODenoiserRadius[(int)quality.value]; } set { m_DenoiserRadius.value = value; } } /// /// Number of steps to take along one signed direction during horizon search (this is the number of steps in positive and negative direction). Increasing the value can lead to detection /// of finer details, but is not a guarantee of higher quality otherwise. Also note that increasing this value will lead to higher cost. /// public int stepCount { get { if (!UsesQualitySettings()) return m_StepCount.value; else return GetLightingQualitySettings().AOStepCount[(int)quality.value]; } set { m_StepCount.value = value; } } /// /// If this option is set to true, the effect runs at full resolution. This will increases quality, but also decreases performance significantly. /// public bool fullResolution { get { if (!UsesQualitySettings()) return m_FullResolution.value; else return GetLightingQualitySettings().AOFullRes[(int)quality.value]; } set { m_FullResolution.value = value; } } /// /// This field imposes a maximum radius in pixels that will be considered. It is very important to keep this as tight as possible to preserve good performance. /// Note that the pixel value specified for this field is the value used for 1080p when *not* running the effect at full resolution, it will be scaled accordingly /// for other resolutions. /// public int maximumRadiusInPixels { get { if (!UsesQualitySettings()) return m_MaximumRadiusInPixels.value; else return GetLightingQualitySettings().AOMaximumRadiusPixels[(int)quality.value]; } set { m_MaximumRadiusInPixels.value = value; } } /// /// This upsample method preserves sharp edges better, however may result in visible aliasing and it is slightly more expensive. /// public bool bilateralUpsample { get { if (!UsesQualitySettings()) return m_BilateralUpsample.value; else return GetLightingQualitySettings().AOBilateralUpsample[(int)quality.value]; } set { m_BilateralUpsample.value = value; } } /// /// Number of directions searched for occlusion at each each pixel when temporal accumulation is disabled. /// public int directionCount { get { if (!UsesQualitySettings()) return m_DirectionCount.value; else return GetLightingQualitySettings().AODirectionCount[(int)quality.value]; } set { m_DirectionCount.value = value; } } /// /// When enabled, ambient occlusion generated by moving objects will not be accumulated, generating less ghosting but introducing additional noise. /// [AdditionalProperty] public BoolParameter occluderMotionRejection = new BoolParameter(true); /// /// When enabled, ambient occlusion generated on moving objects will not be accumulated, generating less ghosting but introducing additional noise. /// [AdditionalProperty] public BoolParameter receiverMotionRejection = new BoolParameter(true); // SSAO [SerializeField, FormerlySerializedAs("stepCount")] private ClampedIntParameter m_StepCount = new ClampedIntParameter(6, 2, 32); [SerializeField, FormerlySerializedAs("fullResolution")] private BoolParameter m_FullResolution = new BoolParameter(false); [SerializeField, FormerlySerializedAs("maximumRadiusInPixels")] private ClampedIntParameter m_MaximumRadiusInPixels = new ClampedIntParameter(40, 16, 256); // Temporal only parameter [AdditionalProperty] [SerializeField, FormerlySerializedAs("bilateralUpsample")] private BoolParameter m_BilateralUpsample = new BoolParameter(true); // Non-temporal only parameters [SerializeField, FormerlySerializedAs("directionCount")] private ClampedIntParameter m_DirectionCount = new ClampedIntParameter(2, 1, 6); // RTAO [SerializeField, FormerlySerializedAs("rayLength")] private MinFloatParameter m_RayLength = new MinFloatParameter(50.0f, 0.01f); [SerializeField, FormerlySerializedAs("sampleCount")] private ClampedIntParameter m_SampleCount = new ClampedIntParameter(1, 1, 64); [SerializeField, FormerlySerializedAs("denoise")] private BoolParameter m_Denoise = new BoolParameter(true); [SerializeField, FormerlySerializedAs("denoiserRadius")] private ClampedFloatParameter m_DenoiserRadius = new ClampedFloatParameter(1.0f, 0.001f, 1.0f); } }