using System; using UnityEngine.Experimental.Rendering; using UnityEngine.Serialization; #if UNITY_EDITOR // TODO @ SHADERS: Enable as many of the rules (currently commented out) as make sense // once the setting asset aggregation behavior is finalized. More fine tuning // of these rules is also desirable (current rules have been interpreted from // the variant stripping logic) using ShaderKeywordFilter = UnityEditor.ShaderKeywordFilter; #endif 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 } /// /// The available Probe system used. /// public enum LightProbeSystem { /// The legacy light probe system. [InspectorName("Light Probe Groups")] LegacyLightProbes = 0, /// Adaptive Probe Volumes system. AdaptiveProbeVolumes = 1, } /// /// Color Buffer format. /// public enum ColorBufferFormat { /// R11G11B10 for faster rendering. R11G11B10 = GraphicsFormat.B10G11R11_UFloatPack32, /// R16G16B16A16 for better quality. R16G16B16A16 = GraphicsFormat.R16G16B16A16_SFloat } /// /// Depth Buffer format. /// public enum DepthBufferFormat { /// Automatically switch between 32 and 24 bit depth depending on the platform. Auto = 0, /// Forces HDRP to use 32 bit depth + 8 bit stencil buffer ForceD32 = GraphicsFormat.D32_SFloat_S8_UInt, /// Forces HDRP to use 24 bit depth + 8 bit stencil buffer ForceD24 = GraphicsFormat.D24_UNorm_S8_UInt, /// Forces HDRP to use 16 bit depth + 8 bit stencil buffer. Improves performances of depth related effects but can cause Z-Fighting due to the low precision. ForceD16 = GraphicsFormat.D16_UNorm_S8_UInt, } /// /// Custom Buffers format. /// public enum CustomBufferFormat { /// Regular R8G8B8A8 format. [InspectorName("Signed R8G8B8A8")] SignedR8G8B8A8 = GraphicsFormat.R8G8B8A8_SNorm, /// Regular R8G8B8A8 format. R8G8B8A8 = GraphicsFormat.R8G8B8A8_UNorm, /// 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, subsurfaceScatteringAttenuation = true, sssSampleBudget = new IntScalableSetting(new[] { (int)DefaultSssSampleBudgetForQualityLevel.Low, (int)DefaultSssSampleBudgetForQualityLevel.Medium, (int)DefaultSssSampleBudgetForQualityLevel.High }, ScalableSettingSchemaId.With3Levels), sssDownsampleSteps = new IntScalableSetting(new[] { (int)DefaultSssDownsampleSteps.Low, (int)DefaultSssDownsampleSteps.Medium, (int)DefaultSssDownsampleSteps.High }, ScalableSettingSchemaId.With3Levels), supportVolumetrics = true, supportDistortion = true, supportTransparentBackface = true, supportTransparentDepthPrepass = true, supportTransparentDepthPostpass = true, colorBufferFormat = ColorBufferFormat.R11G11B10, depthBufferFormat = DepthBufferFormat.Auto, supportCustomPass = true, supportVariableRateShading = true, customBufferFormat = CustomBufferFormat.R8G8B8A8, supportedLitShaderMode = SupportedLitShaderMode.DeferredOnly, supportDecals = true, supportDecalLayers = false, supportSurfaceGradient = true, decalNormalBufferHP = false, msaaSampleCount = MSAASamples.None, supportMotionVectors = true, supportRuntimeAOVAPI = false, supportTerrainHole = false, supportComputeThickness = false, computeThicknessResolution = ComputeThicknessResolution.Half, computeThicknessLayerMask = 0, planarReflectionResolution = new PlanarReflectionAtlasResolutionScalableSetting(new[] { PlanarReflectionAtlasResolution.Resolution256, PlanarReflectionAtlasResolution.Resolution1024, PlanarReflectionAtlasResolution.Resolution2048 }, ScalableSettingSchemaId.With3Levels), cubeReflectionResolution = new ReflectionProbeResolutionScalableSetting(new[] { CubeReflectionResolution.CubeReflectionResolution128, CubeReflectionResolution.CubeReflectionResolution256, CubeReflectionResolution.CubeReflectionResolution512 }, 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(), // Water Properties supportWater = false, waterSimulationResolution = WaterSimulationResolution.Medium128, supportWaterExclusion = true, supportWaterHorizontalDeformation = false, supportWaterDecals = true, waterDecalAtlasSize = WaterAtlasSize.AtlasSize1024, maximumWaterDecalCount = 48, waterScriptInteractionsMode = WaterScriptInteractionsMode.GPUReadback, waterFullCPUSimulation = false, supportScreenSpaceLensFlare = true, supportDataDrivenLensFlare = true, supportRayTracing = false, supportVFXRayTracing = false, supportedRayTracingMode = SupportedRayTracingMode.Both, lodBias = new FloatScalableSetting(new[] { 1.0f, 1, 1 }, ScalableSettingSchemaId.With3Levels), maximumLODLevel = new IntScalableSetting(new[] { 0, 0, 0 }, ScalableSettingSchemaId.With3Levels), lightProbeSystem = LightProbeSystem.AdaptiveProbeVolumes, probeVolumeMemoryBudget = ProbeVolumeTextureMemoryBudget.MemoryBudgetMedium, probeVolumeBlendingMemoryBudget = ProbeVolumeBlendingTextureMemoryBudget.MemoryBudgetLow, supportProbeVolumeScenarios = false, supportProbeVolumeScenarioBlending = true, supportHighQualityLineRendering = false, supportProbeVolumeGPUStreaming = false, supportProbeVolumeDiskStreaming = false, highQualityLineRenderingMemoryBudget = LineRendering.MemoryBudget.MemoryBudgetLow, probeVolumeSHBands = ProbeVolumeSHBands.SphericalHarmonicsL1, gpuResidentDrawerSettings = GlobalGPUResidentDrawerSettings.NewDefault() }; 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) { } } /// /// Represents resolution settings for cube reflections. /// [Serializable] public class ReflectionProbeResolutionScalableSetting : ScalableSetting { /// /// Instantiate a new CubeReflectionResolution scalable setting. /// /// The values of the settings /// The schema of the setting. public ReflectionProbeResolutionScalableSetting(CubeReflectionResolution[] 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. #if UNITY_EDITOR // multi_compile_fragment _ OUTPUT_SPLIT_LIGHTING // [ShaderKeywordFilter.RemoveIf(true, keywordNames: "OUTPUT_SPLIT_LIGHTING")] #endif public bool supportSubsurfaceScattering; /// Enable SubSurface-Scattering occlusion computation. Enabling this makes the SSS slightly more expensive but add great details to occluded zones with SSS materials. public bool subsurfaceScatteringAttenuation; /// Sample budget for the Subsurface Scattering algorithm. public IntScalableSetting sssSampleBudget; /// Downsample input texture for the Subsurface Scattering algorithm. public IntScalableSetting sssDownsampleSteps; /// Support volumetric lighting. public bool supportVolumetrics; /// Support volumetric clouds. public bool supportVolumetricClouds; /// Support light layers. public bool supportLightLayers; /// Enable rendering layer mask buffer. public bool renderingLayerMaskBuffer; // Water /// Support Water Surfaces. public bool supportWater; /// Water simulation resolution public WaterSimulationResolution waterSimulationResolution; /// Support Water Surfaces exclusion. public bool supportWaterExclusion; /// Support Water Surfaces Horizontal Deformation. public bool supportWaterHorizontalDeformation; /// Support Water Surfaces deformation. public bool supportWaterDecals; /// Defines the resolution of the decal atlas. public WaterAtlasSize waterDecalAtlasSize; /// Maximum amount of visible water decals. public int maximumWaterDecalCount; /// Defines if the script interactions should simulate water on CPU or fetch simulation from the GPU. [Tooltip("Defines if the script interactions should simulate water on CPU or fetch simulation from the GPU.")] public WaterScriptInteractionsMode waterScriptInteractionsMode; /// Defines if the CPU simulation should be evaluated at full resolution or half resolution. [Tooltip("Defines if the CPU simulation should be evaluated at full resolution or half resolution.")] public bool waterFullCPUSimulation; // Compute Thickness /// Sample Compute Thickness algorithm. public bool supportComputeThickness; /// Scale for compute thickness texture array. public ComputeThicknessResolution computeThicknessResolution; /// LayerMask used to render thickness. public LayerMask computeThicknessLayerMask; /// Names for rendering layers. [Obsolete("This property is obsolete. Use RenderingLayerMask API and Tags & Layers project settings instead. #from(2023.3)")] public string[] renderingLayerNames { get { return (string[])HDRenderPipelineGlobalSettings.instance.renderingLayerNames.Clone(); } set { HDRenderPipelineGlobalSettings.instance.renderingLayerNames = value; } } /// 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; /// Depth buffer format. public DepthBufferFormat depthBufferFormat; /// Support custom passes. public bool supportCustomPass; /// Support variable rate shading. public bool supportVariableRateShading; /// Custom passes buffer format. public CustomBufferFormat customBufferFormat; /// Supported Lit shader modes. #if UNITY_EDITOR // multi_compile_fragment _ WRITE_MSAA_DEPTH // [ShaderKeywordFilter.RemoveIf(SupportedLitShaderMode.DeferredOnly, keywordNames: "WRITE_MSAA_DEPTH")] #endif public SupportedLitShaderMode supportedLitShaderMode; /// public PlanarReflectionAtlasResolutionScalableSetting planarReflectionResolution; /// public ReflectionProbeResolutionScalableSetting cubeReflectionResolution; // Engine /// Support decals. #if UNITY_EDITOR // multi_compile_fragment DECALS_OFF DECALS_3RT DECALS_4RT // If decals are not supported, remove the multiple render target variants // [ShaderKeywordFilter.RemoveIf(false, keywordNames: new string[] {"DECALS_3RT", "DECALS_4RT"})] // Similar but separate rule due to the separate multi_compile_fragment _ DECAL_SURFACE_GRADIENT // [ShaderKeywordFilter.RemoveIf(false, keywordNames: "DECAL_SURFACE_GRADIENT")] // If decals are supported, remove the no decal variant // [ShaderKeywordFilter.RemoveIf(true, keywordNames: "DECALS_OFF")] // If decals are not supported, remove WRITE_DECAL_BUFFER // [ShaderKeywordFilter.RemoveIf(false, keywordNames: "WRITE_DECAL_BUFFER")] #endif public bool supportDecals; /// Support decal Layers. #if UNITY_EDITOR // multi_compile _ WRITE_DECAL_BUFFER // [ShaderKeywordFilter.SelectOrRemove(true, keywordNames: "WRITE_DECAL_BUFFER")] #endif public bool supportDecalLayers; /// Support surface gradient for decal normal blending. #if UNITY_EDITOR // multi_compile_fragment _ DECAL_SURFACE_GRADIENT // Remove if surface gradient is not supported // [ShaderKeywordFilter.RemoveIf(true, keywordNames: "DECAL_SURFACE_GRADIENT")] #endif public bool supportSurfaceGradient; /// High precision normal buffer. public bool decalNormalBufferHP; /// Support High Quality Line Rendering. public bool supportHighQualityLineRendering; /// High Quality Line Rendering Memory Budget. public LineRendering.MemoryBudget highQualityLineRenderingMemoryBudget; /// Default Number of samples when using MSAA. public MSAASamples msaaSampleCount; /// Support MSAA. [Obsolete("#from(2021.2)")] public bool supportMSAA => msaaSampleCount != MSAASamples.None; // Returns true if the output of the rendering passes support an alpha channel internal bool SupportsAlpha() { return CoreUtils.IsSceneFilteringEnabled() || (colorBufferFormat == ColorBufferFormat.R16G16B16A16); } /// Support motion vectors. public bool supportMotionVectors; // Post Processing /// Support Screen Space Lens Flare. public bool supportScreenSpaceLensFlare; /// Support Data Driven Lens Flare. public bool supportDataDrivenLensFlare; /// Support runtime debug display. [Obsolete("Use HDRenderPipelineGlobalSettings.instance.stripDebugVariants) instead. #from(2023.1)")] public bool supportRuntimeDebugDisplay { get => !HDRenderPipelineGlobalSettings.instance.m_StripDebugVariants; set => HDRenderPipelineGlobalSettings.instance.m_StripDebugVariants = !value; } internal bool supportProbeVolume => (lightProbeSystem == LightProbeSystem.AdaptiveProbeVolumes); [FormerlySerializedAs("supportProbeVolume")] [Obsolete("Use lightProbeSystem instead #from(2023.2)")] internal bool oldSupportProbeVolume; /// Support LOD Dithering Cross-Fade/// [Obsolete("This setting has no effect, use LOD Quality Setting instead #from(2023.2)")] public bool supportDitheringCrossFade; /// Support runtime AOV API. public bool supportRuntimeAOVAPI; /// Support terrain holes. public bool supportTerrainHole; /// Determines what system to use. #if UNITY_EDITOR // multi_compile _ PROBE_VOLUMES_L1 PROBE_VOLUMES_L2 // [ShaderKeywordFilter.SelectIf(LightProbeSystem.ProbeVolumes, new string[] {"PROBE_VOLUMES_L1", "PROBE_VOLUMES_L2"})] // [ShaderKeywordFilter.RemoveIf(LightProbeSystem.LegacyLightProbes, keywordNames: new string[] {"PROBE_VOLUMES_L1", "PROBE_VOLUMES_L2"})] #endif public LightProbeSystem lightProbeSystem; [SerializeField] [FormerlySerializedAs("lightProbeSystem")] internal LightProbeSystem oldLightProbeSystem; /// Probe Volume Memory Budget. public ProbeVolumeTextureMemoryBudget probeVolumeMemoryBudget; /// Support GPU Streaming for Probe Volumes. [FormerlySerializedAs("supportProbeVolumeStreaming")] public bool supportProbeVolumeGPUStreaming; /// Support Disk Streaming for Probe Volumes. public bool supportProbeVolumeDiskStreaming; /// Probe Volumes SH Bands. #if UNITY_EDITOR // multi_compile _ PROBE_VOLUMES_L1 PROBE_VOLUMES_L2 // [ShaderKeywordFilter.RemoveIf(ProbeVolumeSHBands.SphericalHarmonicsL1, keywordNames: "PROBE_VOLUMES_L2")] // [ShaderKeywordFilter.RemoveIf(ProbeVolumeSHBands.SphericalHarmonicsL2, keywordNames: "PROBE_VOLUMES_L1")] #endif public ProbeVolumeSHBands probeVolumeSHBands; /// Support Scenarios for Probe Volumes. public bool supportProbeVolumeScenarios; /// Support Scenarios for Probe Volumes. public bool supportProbeVolumeScenarioBlending; /// Probe Volume Memory Budget for scenario blending. public ProbeVolumeBlendingTextureMemoryBudget probeVolumeBlendingMemoryBudget; /// Support ray tracing. public bool supportRayTracing; /// Support ray tracing of VFXs. public bool supportVFXRayTracing; /// Support ray tracing mode. public SupportedRayTracingMode supportedRayTracingMode; /// 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; /// Global macro batcher settings. [FormerlySerializedAs("macroBatcherSettings")] public GlobalGPUResidentDrawerSettings gpuResidentDrawerSettings; #pragma warning disable 618 // Type or member is obsolete [Obsolete("For data migration. #from(2021.1)")] internal bool m_ObsoleteincreaseSssSampleCount; [SerializeField] [FormerlySerializedAs("lightLayerName0"), Obsolete("Moved to HDGlobal Settings. #from(2021.2)")] internal string m_ObsoleteLightLayerName0; [SerializeField] [FormerlySerializedAs("lightLayerName1"), Obsolete("Moved to HDGlobal Settings. #from(2021.2)")] internal string m_ObsoleteLightLayerName1; [SerializeField] [FormerlySerializedAs("lightLayerName2"), Obsolete("Moved to HDGlobal Settings. #from(2021.2)")] internal string m_ObsoleteLightLayerName2; [SerializeField] [FormerlySerializedAs("lightLayerName3"), Obsolete("Moved to HDGlobal Settings. #from(2021.2)")] internal string m_ObsoleteLightLayerName3; [SerializeField] [FormerlySerializedAs("lightLayerName4"), Obsolete("Moved to HDGlobal Settings. #from(2021.2)")] internal string m_ObsoleteLightLayerName4; [SerializeField] [FormerlySerializedAs("lightLayerName5"), Obsolete("Moved to HDGlobal Settings. #from(2021.2)")] internal string m_ObsoleteLightLayerName5; [SerializeField] [FormerlySerializedAs("lightLayerName6"), Obsolete("Moved to HDGlobal Settings. #from(2021.2)")] internal string m_ObsoleteLightLayerName6; [SerializeField] [FormerlySerializedAs("lightLayerName7"), Obsolete("Moved to HDGlobal Settings. #from(2021.2)")] internal string m_ObsoleteLightLayerName7; [SerializeField] [FormerlySerializedAs("decalLayerName0"), Obsolete("Moved to HDGlobal Settings. #from(2021.2)")] internal string m_ObsoleteDecalLayerName0; [SerializeField] [FormerlySerializedAs("decalLayerName1"), Obsolete("Moved to HDGlobal Settings. #from(2021.2)")] internal string m_ObsoleteDecalLayerName1; [SerializeField] [FormerlySerializedAs("decalLayerName2"), Obsolete("Moved to HDGlobal Settings. #from(2021.2)")] internal string m_ObsoleteDecalLayerName2; [SerializeField] [FormerlySerializedAs("decalLayerName3"), Obsolete("Moved to HDGlobal Settings. #from(2021.2)")] internal string m_ObsoleteDecalLayerName3; [SerializeField] [FormerlySerializedAs("decalLayerName4"), Obsolete("Moved to HDGlobal Settings. #from(2021.2)")] internal string m_ObsoleteDecalLayerName4; [SerializeField] [FormerlySerializedAs("decalLayerName5"), Obsolete("Moved to HDGlobal Settings. #from(2021.2)")] internal string m_ObsoleteDecalLayerName5; [SerializeField] [FormerlySerializedAs("decalLayerName6"), Obsolete("Moved to HDGlobal Settings. #from(2021.2)")] internal string m_ObsoleteDecalLayerName6; [SerializeField] [FormerlySerializedAs("decalLayerName7"), Obsolete("Moved to HDGlobal Settings. #from(2021.2)")] internal string m_ObsoleteDecalLayerName7; [SerializeField] [FormerlySerializedAs("supportRuntimeDebugDisplay"), Obsolete("Moved to HDGlobal Settings. #from(2022.1)")] internal bool m_ObsoleteSupportRuntimeDebugDisplay; #pragma warning restore 618 } }