using System;
namespace UnityEngine.Rendering.HighDefinition
{
///
/// A volume component that holds settings for the Exposure effect.
///
[Serializable, VolumeComponentMenu("Exposure")]
[HelpURL(Documentation.baseURL + Documentation.version + Documentation.subURL + "Override-Exposure" + Documentation.endURL)]
public sealed class Exposure : VolumeComponent, IPostProcessComponent
{
///
/// Specifies the method that HDRP uses to process exposure.
///
///
[Tooltip("Specifies the method that HDRP uses to process exposure.")]
public ExposureModeParameter mode = new ExposureModeParameter(ExposureMode.Fixed);
///
/// Specifies the metering method that HDRP uses the filter the luminance source.
///
///
[Tooltip("Specifies the metering method that HDRP uses the filter the luminance source.")]
public MeteringModeParameter meteringMode = new MeteringModeParameter(MeteringMode.CenterWeighted);
///
/// Specifies the luminance source that HDRP uses to calculate the current Scene exposure.
///
///
[Tooltip("Specifies the luminance source that HDRP uses to calculate the current Scene exposure.")]
public LuminanceSourceParameter luminanceSource = new LuminanceSourceParameter(LuminanceSource.ColorBuffer);
///
/// Sets a static exposure value for Cameras in this Volume.
/// This parameter is only used when is set.
///
[Tooltip("Sets a static exposure value for Cameras in this Volume.")]
public FloatParameter fixedExposure = new FloatParameter(0f);
///
/// Sets the compensation that the Camera applies to the calculated exposure value.
/// This parameter is only used when any mode but is set.
///
[Tooltip("Sets the compensation that the Camera applies to the calculated exposure value.")]
public FloatParameter compensation = new FloatParameter(0f);
///
/// Sets the minimum value that the Scene exposure can be set to.
/// This parameter is only used when or is set.
///
[Tooltip("Sets the minimum value that the Scene exposure can be set to.")]
public FloatParameter limitMin = new FloatParameter(-1f);
///
/// Sets the maximum value that the Scene exposure can be set to.
/// This parameter is only used when or is set.
///
[Tooltip("Sets the maximum value that the Scene exposure can be set to.")]
public FloatParameter limitMax = new FloatParameter(14f);
///
/// Specifies a curve that remaps the Scene exposure on the x-axis to the exposure you want on the y-axis.
/// This parameter is only used when is set.
///
[Tooltip("Specifies a curve that remaps the Scene exposure on the x-axis to the exposure you want on the y-axis.")]
public AnimationCurveParameter curveMap = new AnimationCurveParameter(AnimationCurve.Linear(-10f, -10f, 20f, 20f)); // TODO: Use TextureCurve instead?
///
/// Specifies a curve that determines for each current exposure value (x-value) what minimum value is allowed to auto-adaptation (y-axis).
/// This parameter is only used when is set.
///
[Tooltip("Specifies a curve that determines for each current exposure value (x-value) what minimum value is allowed to auto-adaptation (y-axis).")]
public AnimationCurveParameter limitMinCurveMap = new AnimationCurveParameter(AnimationCurve.Linear(-10f, -12f, 20f, 18f));
///
/// Specifies a curve that determines for each current exposure value (x-value) what maximum value is allowed to auto-adaptation (y-axis).
/// This parameter is only used when is set.
///
[Tooltip("Specifies a curve that determines for each current exposure value (x-value) what maximum value is allowed to auto-adaptation (y-axis).")]
public AnimationCurveParameter limitMaxCurveMap = new AnimationCurveParameter(AnimationCurve.Linear(-10f, -8f, 20f, 22f));
///
/// Specifies the method that HDRP uses to change the exposure when the Camera moves from dark to light and vice versa.
/// This parameter is only used when or is set.
///
[Tooltip("Specifies the method that HDRP uses to change the exposure when the Camera moves from dark to light and vice versa.")]
public AdaptationModeParameter adaptationMode = new AdaptationModeParameter(AdaptationMode.Progressive);
///
/// Sets the speed at which the exposure changes when the Camera moves from a dark area to a bright area.
/// This parameter is only used when or is set.
///
[Tooltip("Sets the speed at which the exposure changes when the Camera moves from a dark area to a bright area.")]
public MinFloatParameter adaptationSpeedDarkToLight = new MinFloatParameter(3f, 0.001f);
///
/// Sets the speed at which the exposure changes when the Camera moves from a bright area to a dark area.
/// This parameter is only used when or is set.
///
[Tooltip("Sets the speed at which the exposure changes when the Camera moves from a bright area to a dark area.")]
public MinFloatParameter adaptationSpeedLightToDark = new MinFloatParameter(1f, 0.001f);
///
/// Sets the texture mask used to weight the pixels in the buffer when computing exposure.
///
[Tooltip("Sets the texture mask to be used to weight the pixels in the buffer for the sake of computing exposure.")]
public NoInterpTextureParameter weightTextureMask = new NoInterpTextureParameter(null);
///
/// These values are the lower and upper percentages of the histogram that will be used to
/// find a stable average luminance. Values outside of this range will be discarded and won't
/// contribute to the average luminance.
///
[Tooltip("Sets the range of values (in terms of percentages) of the histogram that are accepted while finding a stable average exposure. Anything outside the value is discarded.")]
public FloatRangeParameter histogramPercentages = new FloatRangeParameter(new Vector2(40.0f, 90.0f), 0.0f, 100.0f);
///
/// Sets whether histogram exposure mode will remap the computed exposure with a curve remapping (akin to Curve Remapping mode)
///
[Tooltip("Sets whether histogram exposure mode will remap the computed exposure with a curve remapping (akin to Curve Remapping mode).")]
public BoolParameter histogramUseCurveRemapping = new BoolParameter(false);
///
/// Sets the desired Mid gray level used by the auto exposure (i.e. to what grey value the auto exposure system maps the average scene luminance).
/// Note that the lens model used in HDRP is not of a perfect lens, hence it will not map precisely to the selected value.
///
[AdditionalProperty]
[Tooltip("Sets the desired Mid gray level used by the auto exposure (i.e. to what grey value the auto exposure system maps the average scene luminance).")]
public TargetMidGrayParameter targetMidGray = new TargetMidGrayParameter(TargetMidGray.Grey125);
///
/// Sets whether the procedural metering mask is centered around the exposure target (to be set on the camera)
///
[Tooltip("Sets whether histogram exposure mode will remap the computed exposure with a curve remapping (akin to Curve Remapping mode).")]
public BoolParameter centerAroundExposureTarget = new BoolParameter(false);
///
/// Sets the center of the procedural metering mask ([0,0] being bottom left of the screen and [1,1] top right of the screen)
///
public NoInterpVector2Parameter proceduralCenter = new NoInterpVector2Parameter(new Vector2(0.5f, 0.5f));
///
/// Sets the radii of the procedural mask, in terms of fraction of half the screen (i.e. 0.5 means a mask that stretch half of the screen in both directions).
///
public NoInterpVector2Parameter proceduralRadii = new NoInterpVector2Parameter(new Vector2(0.3f, 0.3f));
///
/// All pixels below this threshold (in EV100 units) will be assigned a weight of 0 in the metering mask.
///
[AdditionalProperty]
[Tooltip("All pixels below this threshold (in EV100 units) will be assigned a weight of 0 in the metering mask.")]
public FloatParameter maskMinIntensity = new FloatParameter(-30.0f);
///
/// All pixels above this threshold (in EV100 units) will be assigned a weight of 0 in the metering mask.
///
[AdditionalProperty]
[Tooltip("All pixels above this threshold (in EV100 units) will be assigned a weight of 0 in the metering mask.")]
public FloatParameter maskMaxIntensity = new FloatParameter(30.0f);
///
/// Sets the softness of the mask, the higher the value the less influence is given to pixels at the edge of the mask.
///
public NoInterpMinFloatParameter proceduralSoftness = new NoInterpMinFloatParameter(0.5f, 0.0f);
///
/// Tells if the effect needs to be rendered or not.
///
/// true if the effect should be rendered, false otherwise.
public bool IsActive()
{
return true;
}
}
///
/// Methods that HDRP uses to process exposure.
///
///
public enum ExposureMode
{
///
/// Allows you to manually sets the Scene exposure.
///
Fixed = 0,
///
/// Automatically sets the exposure depending on what is on screen.
///
Automatic = 1,
///
/// Automatically sets the exposure depending on what is on screen and can filter out outliers based on provided settings.
///
AutomaticHistogram = 4,
///
/// Maps the current Scene exposure to a custom curve.
///
CurveMapping = 2,
///
/// Uses the current physical Camera settings to set the Scene exposure.
///
UsePhysicalCamera = 3
}
///
/// Metering methods that HDRP uses the filter the luminance source
///
///
public enum MeteringMode
{
///
/// The Camera uses the entire luminance buffer to measure exposure.
///
Average,
///
/// The Camera only uses the center of the buffer to measure exposure. This is useful if you
/// want to only expose light against what is in the center of your screen.
///
Spot,
///
/// The Camera applies a weight to every pixel in the buffer and then uses them to measure
/// the exposure. Pixels in the center have the maximum weight, pixels at the screen borders
/// have the minimum weight, and pixels in between have a progressively lower weight the
/// closer they are to the screen borders.
///
CenterWeighted,
///
/// The Camera applies a weight to every pixel in the buffer and then uses them to measure
/// the exposure. The weighting is specified by the texture provided by the user. Note that if
/// no texture is provided, then this metering mode is equivalent to Average.
///
MaskWeighted,
///
/// Create a weight mask centered around the specified UV and with the desired parameters.
///
ProceduralMask,
}
///
/// Luminance source that HDRP uses to calculate the current Scene exposure.
///
///
/// is not implemented yet.
///
///
public enum LuminanceSource
{
///
/// Uses the lighting data only.
///
///
/// This mode is not implemented yet.
///
LightingBuffer,
///
/// Uses the final color data before post-processing has been applied.
///
ColorBuffer
}
///
/// The target grey value used by the exposure system. Note this is equivalent of changing the calibration constant K on the used virtual reflected light meter.
///
public enum TargetMidGray
{
///
/// Mid Grey 12.5% (reflected light meter K set as 12.5)
///
Grey125,
///
/// Mid Grey 14.0% (reflected light meter K set as 14.0)
///
Grey14,
///
/// Mid Grey 18.0% (reflected light meter K set as 18.0). Note that this value is outside of the suggested K range by the ISO standard.
///
Grey18
}
///
/// Methods that HDRP uses to change the exposure when the Camera moves from dark to light and vice versa.
///
///
public enum AdaptationMode
{
///
/// The exposure changes instantly.
///
Fixed,
///
/// The exposure changes over the period of time.
///
///
///
Progressive
}
///
/// A that holds a value.
///
[Serializable]
public sealed class ExposureModeParameter : VolumeParameter
{
///
/// Creates a new instance.
///
/// The initial value to store in the parameter.
/// The initial override state for the parameter.
public ExposureModeParameter(ExposureMode value, bool overrideState = false) : base(value, overrideState) {}
}
///
/// A that holds a value.
///
[Serializable]
public sealed class MeteringModeParameter : VolumeParameter
{
///
/// Creates a new instance.
///
/// The initial value to store in the parameter.
/// The initial override state for the parameter.
public MeteringModeParameter(MeteringMode value, bool overrideState = false) : base(value, overrideState) {}
}
///
/// A that holds a value.
///
[Serializable]
public sealed class LuminanceSourceParameter : VolumeParameter
{
///
/// Creates a new instance.
///
/// The initial value to store in the parameter.
/// The initial override state for the parameter.
public LuminanceSourceParameter(LuminanceSource value, bool overrideState = false) : base(value, overrideState) {}
}
///
/// A that holds a value.
///
[Serializable]
public sealed class AdaptationModeParameter : VolumeParameter
{
///
/// Creates a new instance.
///
/// The initial value to store in the parameter.
/// The initial override state for the parameter.
public AdaptationModeParameter(AdaptationMode value, bool overrideState = false) : base(value, overrideState) {}
}
///
/// A that holds a value.
///
[Serializable]
public sealed class TargetMidGrayParameter : VolumeParameter
{
///
/// Creates a new instance.
///
/// The initial value to store in the parameter.
/// The initial override state for the parameter.
public TargetMidGrayParameter(TargetMidGray value, bool overrideState = false) : base(value, overrideState) {}
}
}