using System;
namespace UnityEngine.Rendering.Universal
{
///
/// Options to select a tonemapping algorithm to use for color grading.
///
public enum TonemappingMode
{
///
/// Use this option if you do not want to apply tonemapping
///
None,
///
/// 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.
///
Neutral, // Neutral tonemapper
///
/// 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.
///
ACES, // ACES Filmic reference tonemapper (custom approximation)
}
///
/// Available options for when HDR Output is enabled and Tonemap is set to Neutral.
///
public enum NeutralRangeReductionMode
{
///
/// Simple Reinhard tonemapping curve.
///
Reinhard = HDRRangeReduction.Reinhard,
///
/// Range reduction curve as specified in the BT.2390 standard.
///
BT2390 = HDRRangeReduction.BT2390
}
///
/// Preset used when selecting ACES tonemapping for HDR displays.
///
public enum HDRACESPreset
{
///
/// Preset for a display with a maximum range of 1000 nits.
///
ACES1000Nits = HDRRangeReduction.ACES1000Nits,
///
/// Preset for a display with a maximum range of 2000 nits.
///
ACES2000Nits = HDRRangeReduction.ACES2000Nits,
///
/// Preset for a display with a maximum range of 4000 nits.
///
ACES4000Nits = HDRRangeReduction.ACES4000Nits,
}
///
/// A volume component that holds settings for the tonemapping effect.
///
[Serializable, VolumeComponentMenu("Post-processing/Tonemapping")]
[SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))]
[URPHelpURL("post-processing-tonemapping")]
public sealed class Tonemapping : VolumeComponent, IPostProcessComponent
{
///
/// Use this to select a tonemapping algorithm to use for color grading.
///
[Tooltip("Select a tonemapping algorithm to use for the color grading process.")]
public TonemappingModeParameter mode = new TonemappingModeParameter(TonemappingMode.None);
// -- HDR Output options --
///
/// Specifies the range reduction mode used when HDR output is enabled and Neutral tonemapping is enabled.
///
[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);
///
/// Specifies the preset for HDR displays.
///
[Tooltip("Use the ACES preset for HDR displays.")]
public HDRACESPresetParameter acesPreset = new HDRACESPresetParameter(HDRACESPreset.ACES1000Nits);
///
/// 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.
///
[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);
///
/// 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.
///
[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);
///
/// 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.
///
[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);
///
/// Enable to use the minimum and maximum brightness values detected from the output device. For best accuracy, considering calibrating these values manually.
///
[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);
///
/// The minimum brightness of the screen (in nits). This value is assumed to be 0.005f with ACES Tonemap.
///
[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);
///
/// The maximum brightness of the screen (in nits). This value is defined by the preset when using ACES Tonemap.
///
[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);
///
public bool IsActive() => mode.value != TonemappingMode.None;
///
[Obsolete("Unused #from(2023.1)", false)]
public bool IsTileCompatible() => true;
}
///
/// A that holds a value.
///
[Serializable]
public sealed class TonemappingModeParameter : VolumeParameter
{
///
/// Creates a new instance.
///
/// The initial value to store in the parameter.
/// The initial override state for the parameter.
public TonemappingModeParameter(TonemappingMode value, bool overrideState = false) : base(value, overrideState) { }
}
///
/// A that contains a value.
///
[Serializable]
public sealed class NeutralRangeReductionModeParameter : VolumeParameter
{
///
/// Creates a new instance.
///
/// The initial value to store in the parameter.
/// The initial override state for the parameter.
public NeutralRangeReductionModeParameter(NeutralRangeReductionMode value, bool overrideState = false) : base(value, overrideState) { }
}
///
/// A that contains a value.
///
[Serializable]
public sealed class HDRACESPresetParameter : VolumeParameter
{
///
/// Creates a new instance.
///
/// The initial value to store in the parameter.
/// The initial override state for the parameter.
public HDRACESPresetParameter(HDRACESPreset value, bool overrideState = false) : base(value, overrideState) { }
}
}