using System; using UnityEngine.Experimental.Rendering; namespace UnityEngine.Rendering.HighDefinition { // RenderPipelineSettings define settings that can't be change during runtime. It is equivalent to the GraphicsSettings of Unity (Tiers + shader variant removal). // This allow to allocate resource or not for a given feature. // FrameSettings control within a frame what is enable or not(enableShadow, enableDistortion...). // HDRenderPipelineAsset reference the current RenderPipelineSettings used, there is one per supported platform(Currently this feature is not implemented and only one GlobalFrameSettings is available). // A Camera with HDAdditionalData has one FrameSettings that configures how it will render. For example a camera used for reflection will disable distortion and post-process. // Additionally, on a Camera there is another FrameSettings called ActiveFrameSettings that is created on the fly based on FrameSettings and allows modifications for debugging purpose at runtime without being serialized on disk. // The ActiveFrameSettings is registered in the debug windows at the creation of the camera. // A Camera with HDAdditionalData has a RenderPath that defines if it uses a "Default" FrameSettings, a preset of FrameSettings or a custom one. // HDRenderPipelineAsset contains a "Default" FrameSettings that can be referenced by any camera with RenderPath.Defaut or when the camera doesn't have HDAdditionalData like the camera of the Editor. // It also contains a DefaultActiveFrameSettings // RenderPipelineSettings represents settings that are immutable at runtime. // There is a dedicated RenderPipelineSettings for each platform /// /// HDRP Render Pipeline Settings. /// [Serializable] public struct RenderPipelineSettings { /// /// Supported Lit Shader Mode. /// public enum SupportedLitShaderMode { /// Forward shading only. ForwardOnly = 1 << 0, /// Deferred shading only. DeferredOnly = 1 << 1, /// Both Forward and Deferred shading. Both = ForwardOnly | DeferredOnly } /// /// Color Buffer format. /// public enum ColorBufferFormat { /// R11G11B10 for faster rendering. R11G11B10 = GraphicsFormat.B10G11R11_UFloatPack32, /// R16G16B16A16 for better quality. R16G16B16A16 = GraphicsFormat.R16G16B16A16_SFloat } /// /// Custom Buffers format. /// public enum CustomBufferFormat { /// Regular R8G8B8A8 format. R8G8B8A8 = GraphicsFormat.R8G8B8A8_SNorm, /// R16G16B16A16 high quality HDR format. R16G16B16A16 = GraphicsFormat.R16G16B16A16_SFloat, /// R11G11B10 medium quality HDR format. R11G11B10 = GraphicsFormat.B10G11R11_UFloatPack32, } /// /// Supported Ray Tracing Mode. /// public enum SupportedRayTracingMode { /// Performance mode only. Performance = 1 << 0, /// Quality mode only. Quality = 1 << 1, /// Both Performance and Quality modes. Both = Performance | Quality } internal static RenderPipelineSettings NewDefault() { RenderPipelineSettings settings = new RenderPipelineSettings() { supportShadowMask = true, supportSSAO = true, supportSubsurfaceScattering = true, sssSampleBudget = new IntScalableSetting(new[] { (int)DefaultSssSampleBudgetForQualityLevel.Low, (int)DefaultSssSampleBudgetForQualityLevel.Medium, (int)DefaultSssSampleBudgetForQualityLevel.High }, ScalableSettingSchemaId.With3Levels), supportVolumetrics = true, supportDistortion = true, supportTransparentBackface = true, supportTransparentDepthPrepass = true, supportTransparentDepthPostpass = true, colorBufferFormat = ColorBufferFormat.R11G11B10, supportCustomPass = true, customBufferFormat = CustomBufferFormat.R8G8B8A8, supportedLitShaderMode = SupportedLitShaderMode.DeferredOnly, supportDecals = true, supportDecalLayers = false, decalLayerName0 = "Decal Layer default", decalLayerName1 = "Decal Layer 1", decalLayerName2 = "Decal Layer 2", decalLayerName3 = "Decal Layer 3", decalLayerName4 = "Decal Layer 4", decalLayerName5 = "Decal Layer 5", decalLayerName6 = "Decal Layer 6", decalLayerName7 = "Decal Layer 7", msaaSampleCount = MSAASamples.None, supportMotionVectors = true, supportRuntimeDebugDisplay = false, supportRuntimeAOVAPI = false, supportDitheringCrossFade = true, supportTerrainHole = false, planarReflectionResolution = new PlanarReflectionAtlasResolutionScalableSetting(new[] { PlanarReflectionAtlasResolution.Resolution256, PlanarReflectionAtlasResolution.Resolution1024, PlanarReflectionAtlasResolution.Resolution2048 }, ScalableSettingSchemaId.With3Levels), lightLoopSettings = GlobalLightLoopSettings.NewDefault(), hdShadowInitParams = HDShadowInitParameters.NewDefault(), decalSettings = GlobalDecalSettings.NewDefault(), postProcessSettings = GlobalPostProcessSettings.NewDefault(), dynamicResolutionSettings = GlobalDynamicResolutionSettings.NewDefault(), lowresTransparentSettings = GlobalLowResolutionTransparencySettings.NewDefault(), xrSettings = GlobalXRSettings.NewDefault(), postProcessQualitySettings = GlobalPostProcessingQualitySettings.NewDefault(), lightingQualitySettings = GlobalLightingQualitySettings.NewDefault(), lightSettings = LightSettings.NewDefault(), supportRayTracing = false, supportedRayTracingMode = SupportedRayTracingMode.Both, lodBias = new FloatScalableSetting(new[] { 1.0f, 1, 1 }, ScalableSettingSchemaId.With3Levels), maximumLODLevel = new IntScalableSetting(new[] { 0, 0, 0 }, ScalableSettingSchemaId.With3Levels), lightLayerName0 = "Light Layer default", lightLayerName1 = "Light Layer 1", lightLayerName2 = "Light Layer 2", lightLayerName3 = "Light Layer 3", lightLayerName4 = "Light Layer 4", lightLayerName5 = "Light Layer 5", lightLayerName6 = "Light Layer 6", lightLayerName7 = "Light Layer 7", supportProbeVolume = false, probeVolumeSettings = GlobalProbeVolumeSettings.@default, }; return settings; } /// /// Light Settings. /// [Serializable] public struct LightSettings { /// Enable contact shadows. public BoolScalableSetting useContactShadow; internal static LightSettings NewDefault() => new LightSettings() { useContactShadow = new BoolScalableSetting(new[] { false, false, true }, ScalableSettingSchemaId.With3Levels) }; } /// /// Represents resolution settings for planar reflections. /// [Serializable] public class PlanarReflectionAtlasResolutionScalableSetting : ScalableSetting { /// /// Instantiate a new PlanarReflectionAtlasResolution scalable setting. /// /// The values of the settings /// The schema of the setting. public PlanarReflectionAtlasResolutionScalableSetting(PlanarReflectionAtlasResolution[] values, ScalableSettingSchemaId schemaId) : base(values, schemaId) { } } // Lighting /// Support shadow masks. public bool supportShadowMask; /// Support screen space reflections. public bool supportSSR; /// Support transparent screen space reflections. public bool supportSSRTransparent; /// Support screen space ambient occlusion. public bool supportSSAO; /// Support screen space global illumination. public bool supportSSGI; /// Support subsurface scattering. public bool supportSubsurfaceScattering; /// Sample budget for the Subsurface Scattering algorithm. public IntScalableSetting sssSampleBudget; /// Support volumetric lighting. public bool supportVolumetrics; /// Support light layers. public bool supportLightLayers; /// Name for light layer 0. public string lightLayerName0; /// Name for light layer 1. public string lightLayerName1; /// Name for light layer 2. public string lightLayerName2; /// Name for light layer 3. public string lightLayerName3; /// Name for light layer 4. public string lightLayerName4; /// Name for light layer 5. public string lightLayerName5; /// Name for light layer 6. public string lightLayerName6; /// Name for light layer 7. public string lightLayerName7; /// Support distortion. public bool supportDistortion; /// Support transparent backface pass. public bool supportTransparentBackface; /// Support transparent depth pre-pass. public bool supportTransparentDepthPrepass; /// Support transparent depth post-pass. public bool supportTransparentDepthPostpass; /// Color buffer format. public ColorBufferFormat colorBufferFormat; /// Support custom passes. public bool supportCustomPass; /// Custom passes buffer format. public CustomBufferFormat customBufferFormat; /// Supported Lit shader modes. public SupportedLitShaderMode supportedLitShaderMode; /// public PlanarReflectionAtlasResolutionScalableSetting planarReflectionResolution; // Engine /// Support decals. public bool supportDecals; /// Support decal Layers. public bool supportDecalLayers; /// Name for decal layer 0. public string decalLayerName0; /// Name for decal layer 1. public string decalLayerName1; /// Name for decal layer 2. public string decalLayerName2; /// Name for decal layer 3. public string decalLayerName3; /// Name for decal layer 4. public string decalLayerName4; /// Name for decal layer 5. public string decalLayerName5; /// Name for decal layer 6. public string decalLayerName6; /// Name for decal layer 7. public string decalLayerName7; /// Number of samples when using MSAA. public MSAASamples msaaSampleCount; /// Support MSAA. public bool supportMSAA => msaaSampleCount != MSAASamples.None; // Returns true if the output of the rendering passes support an alpha channel internal bool supportsAlpha => colorBufferFormat == ColorBufferFormat.R16G16B16A16; /// Support motion vectors. public bool supportMotionVectors; /// Support runtime debug display. public bool supportRuntimeDebugDisplay; /// Support runtime AOV API. public bool supportRuntimeAOVAPI; /// Support dithered cross-fade. public bool supportDitheringCrossFade; /// Support terrain holes. public bool supportTerrainHole; /// Support Probe Volumes. [SerializeField] internal bool supportProbeVolume; /// Support ray tracing. public bool supportRayTracing; /// Support ray tracing mode. public SupportedRayTracingMode supportedRayTracingMode; /// Global Probe Volume settings. [SerializeField] internal GlobalProbeVolumeSettings probeVolumeSettings; /// Global light loop settings. public GlobalLightLoopSettings lightLoopSettings; /// Global shadows settings. public HDShadowInitParameters hdShadowInitParams; /// Global decal settings public GlobalDecalSettings decalSettings; /// Global post process settings. public GlobalPostProcessSettings postProcessSettings; /// Global dynamic resolution settings. public GlobalDynamicResolutionSettings dynamicResolutionSettings; /// Global low resolution transparency settings. public GlobalLowResolutionTransparencySettings lowresTransparentSettings; /// Global XR settings. public GlobalXRSettings xrSettings; /// Global post processing quality settings. public GlobalPostProcessingQualitySettings postProcessQualitySettings; /// Light Settings. public LightSettings lightSettings; /// Maximum LoD Level. public IntScalableSetting maximumLODLevel; /// LoD bias. public FloatScalableSetting lodBias; /// Global lighting quality settings. public GlobalLightingQualitySettings lightingQualitySettings; #pragma warning disable 618 // Type or member is obsolete [Obsolete("For data migration")] internal bool m_ObsoleteincreaseSssSampleCount; #pragma warning restore 618 } }