using System; using UnityEngine.Serialization; using UnityEngine.Experimental.Rendering; namespace UnityEngine.Rendering.HighDefinition { /// /// Available color grading LUT formats. /// /// public enum GradingLutFormat { /// /// R11G11B10. Fastest lookup format but can result in a loss of precision in some extreme cases. /// R11G11B10 = GraphicsFormat.B10G11R11_UFloatPack32, /// /// 16 bit per channel. /// R16G16B16A16 = GraphicsFormat.R16G16B16A16_SFloat, /// /// 32 bit per channel. Should only be used in extreme grading cases. /// R32G32B32A32 = GraphicsFormat.R32G32B32A32_SFloat } /// /// Format of intermediate buffers for post processing. /// public enum PostProcessBufferFormat { /// /// R11G11B10. Fastest lookup format but can result in a loss of precision in some extreme cases. /// R11G11B10 = GraphicsFormat.B10G11R11_UFloatPack32, /// /// 16 bit per channel. /// R16G16B16A16 = GraphicsFormat.R16G16B16A16_SFloat, /// /// 32 bit per channel. Should only be used in extreme cases. /// R32G32B32A32 = GraphicsFormat.R32G32B32A32_SFloat } /// /// Project-wide settings related to post-processing. /// [Serializable] public struct GlobalPostProcessSettings { internal static GlobalPostProcessSettings NewDefault() => new GlobalPostProcessSettings() { lutSize = 32, lutFormat = GradingLutFormat.R16G16B16A16, bufferFormat = PostProcessBufferFormat.R11G11B10 }; // Returns true if the post-processing passes support an alpha channel internal bool supportsAlpha => bufferFormat != PostProcessBufferFormat.R11G11B10; // Note: A lut size of 16^3 is barely usable (noticeable color banding in highly contrasted // areas and harsh tonemappers like ACES'). 32 should be the minimum, the lut being encoded // in log. Lower sizes would work better with an additional 1D shaper lut but for now we'll // keep it simple. /// /// The minimum allowed size for the color grading LUT. /// public const int k_MinLutSize = 16; /// /// The maximum allowed size for the color grading LUT. /// public const int k_MaxLutSize = 65; [SerializeField] int m_LutSize; /// /// Project-wide LUT size used for the internal color grading LUT and external LUTs. /// public int lutSize { get => m_LutSize; set => m_LutSize = Mathf.Clamp(value, k_MinLutSize, k_MaxLutSize); } /// /// The texture format to use to store the internal color gradint LUT. /// /// [FormerlySerializedAs("m_LutFormat")] public GradingLutFormat lutFormat; /// /// The texture format to be used for the post-processing passes. /// public PostProcessBufferFormat bufferFormat; } }