diff --git a/TestProjects/HDRP_DXR_Tests/LocalPackages/com.unity.render-pipelines.high-definition-config/Runtime.meta b/TestProjects/HDRP_DXR_Tests/LocalPackages/com.unity.render-pipelines.high-definition-config/Runtime.meta deleted file mode 100644 index f39f7b8ba30..00000000000 --- a/TestProjects/HDRP_DXR_Tests/LocalPackages/com.unity.render-pipelines.high-definition-config/Runtime.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 5d299198a792a964e9d443aa47506e2c -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/TestProjects/HDRP_DXR_Tests/LocalPackages/com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs b/TestProjects/HDRP_DXR_Tests/LocalPackages/com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs deleted file mode 100644 index ac8b3435e33..00000000000 --- a/TestProjects/HDRP_DXR_Tests/LocalPackages/com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs +++ /dev/null @@ -1,85 +0,0 @@ -//----------------------------------------------------------------------------- -// Configuration -//----------------------------------------------------------------------------- - -namespace UnityEngine.Rendering.HighDefinition -{ - [GenerateHLSL(PackingRules.Exact)] - public enum ProbeVolumesEvaluationModes - { - Disabled = 0, - LightLoop = 1, - MaterialPass = 2, - } - - [GenerateHLSL(PackingRules.Exact)] - public enum ProbeVolumesEncodingModes - { - SphericalHarmonicsL0 = 0, - SphericalHarmonicsL1 = 1, - SphericalHarmonicsL2 = 2 - } - - [GenerateHLSL(PackingRules.Exact)] - public enum ProbeVolumesBilateralFilteringModes - { - Disabled = 0, - Validity = 1, - OctahedralDepth = 2 - } - - [GenerateHLSL(PackingRules.Exact)] - public enum ShaderOptions - { - ColoredShadow = 1, // Allow to defined if colored shadow are supported in shaders or not - CameraRelativeRendering = 1, // Rendering sets the origin of the world to the position of the primary (scene view) camera - PreExposition = 1, - PrecomputedAtmosphericAttenuation = 0, // Precomputes atmospheric attenuation for the directional light on the CPU, which makes it independent from the fragment's position, which is faster but wrong -#if ENABLE_RAYTRACING - Raytracing = 1, -#else - Raytracing = 0, -#endif -#if ENABLE_VR - XrMaxViews = 2, // Used for single-pass rendering (with fast path in vertex shader code when forced to 2) -#else - XrMaxViews = 1, -#endif - - // Warning: Probe Volumes is a highly experimental feature. It is disabled by default for this reason. - // It's functionality is subject to breaking changes and whole sale removal. - // It is not recommended for use outside of for providing feedback. It should not be used in production. - // To enable, set: - // ProbeVolumesEvaluationMode = ProbeVolumesEvaluationModes.MaterialPass - // and inside of the editor run: - // Edit->Render Pipeline->Generate Shader Includes - // Probe Volumes feature must also be enabled inside of your HDRenderPipelineAsset. - ProbeVolumesEvaluationMode = ProbeVolumesEvaluationModes.Disabled, - ProbeVolumesAdditiveBlending = 1, - ProbeVolumesBilateralFilteringMode = ProbeVolumesBilateralFilteringModes.Validity, - ProbeVolumesEncodingMode = ProbeVolumesEncodingModes.SphericalHarmonicsL1, - - AreaLights = 1, - - BarnDoor = 0 - }; - - // Note: #define can't be use in include file in C# so we chose this way to configure both C# and hlsl - // Changing a value in this enum Config here require to regenerate the hlsl include and recompile C# and shaders - public class ShaderConfig - { - public const int k_XRMaxViewsForCBuffer = 2; // REALLY IMPORTANT! This needs to be the maximum possible XrMaxViews for any supported platform! - // this needs to be constant and not vary like XrMaxViews does as it is used to generate the cbuffer declarations - - public static int s_CameraRelativeRendering = (int)ShaderOptions.CameraRelativeRendering; - public static int s_PreExposition = (int)ShaderOptions.PreExposition; - public static int s_XrMaxViews = (int)ShaderOptions.XrMaxViews; - public static int s_PrecomputedAtmosphericAttenuation = (int)ShaderOptions.PrecomputedAtmosphericAttenuation; - public static ProbeVolumesEvaluationModes s_ProbeVolumesEvaluationMode = (ProbeVolumesEvaluationModes)ShaderOptions.ProbeVolumesEvaluationMode; - public static int s_ProbeVolumesAdditiveBlending = (int)ShaderOptions.ProbeVolumesAdditiveBlending; - public static ProbeVolumesBilateralFilteringModes s_ProbeVolumesBilateralFilteringMode = (ProbeVolumesBilateralFilteringModes)ShaderOptions.ProbeVolumesBilateralFilteringMode; - public static ProbeVolumesEncodingModes s_ProbeVolumesEncodingMode = (ProbeVolumesEncodingModes)ShaderOptions.ProbeVolumesEncodingMode; - public static int s_AreaLights = (int)ShaderOptions.AreaLights; - public static int s_BarnDoor = (int)ShaderOptions.BarnDoor; - } -} diff --git a/TestProjects/HDRP_DXR_Tests/LocalPackages/com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs.hlsl b/TestProjects/HDRP_DXR_Tests/LocalPackages/com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs.hlsl deleted file mode 100644 index b21ea94c319..00000000000 --- a/TestProjects/HDRP_DXR_Tests/LocalPackages/com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs.hlsl +++ /dev/null @@ -1,45 +0,0 @@ -// -// This file was automatically generated. Please don't edit by hand. -// - -#ifndef SHADERCONFIG_CS_HLSL -#define SHADERCONFIG_CS_HLSL -// -// UnityEngine.Rendering.HighDefinition.ProbeVolumesEvaluationModes: static fields -// -#define PROBEVOLUMESEVALUATIONMODES_DISABLED (0) -#define PROBEVOLUMESEVALUATIONMODES_LIGHT_LOOP (1) -#define PROBEVOLUMESEVALUATIONMODES_MATERIAL_PASS (2) - -// -// UnityEngine.Rendering.HighDefinition.ProbeVolumesEncodingModes: static fields -// -#define PROBEVOLUMESENCODINGMODES_SPHERICAL_HARMONICS_L0 (0) -#define PROBEVOLUMESENCODINGMODES_SPHERICAL_HARMONICS_L1 (1) -#define PROBEVOLUMESENCODINGMODES_SPHERICAL_HARMONICS_L2 (2) - -// -// UnityEngine.Rendering.HighDefinition.ProbeVolumesBilateralFilteringModes: static fields -// -#define PROBEVOLUMESBILATERALFILTERINGMODES_DISABLED (0) -#define PROBEVOLUMESBILATERALFILTERINGMODES_VALIDITY (1) -#define PROBEVOLUMESBILATERALFILTERINGMODES_OCTAHEDRAL_DEPTH (2) - -// -// UnityEngine.Rendering.HighDefinition.ShaderOptions: static fields -// -#define SHADEROPTIONS_COLORED_SHADOW (1) -#define SHADEROPTIONS_CAMERA_RELATIVE_RENDERING (1) -#define SHADEROPTIONS_PRE_EXPOSITION (1) -#define SHADEROPTIONS_PRECOMPUTED_ATMOSPHERIC_ATTENUATION (0) -#define SHADEROPTIONS_RAYTRACING (1) -#define SHADEROPTIONS_XR_MAX_VIEWS (2) -#define SHADEROPTIONS_PROBE_VOLUMES_EVALUATION_MODE (0) -#define SHADEROPTIONS_PROBE_VOLUMES_ADDITIVE_BLENDING (1) -#define SHADEROPTIONS_PROBE_VOLUMES_BILATERAL_FILTERING_MODE (1) -#define SHADEROPTIONS_PROBE_VOLUMES_ENCODING_MODE (1) -#define SHADEROPTIONS_AREA_LIGHTS (1) -#define SHADEROPTIONS_BARN_DOOR (0) - - -#endif diff --git a/TestProjects/HDRP_DXR_Tests/LocalPackages/com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs.hlsl.meta b/TestProjects/HDRP_DXR_Tests/LocalPackages/com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs.hlsl.meta deleted file mode 100644 index 6398631396b..00000000000 --- a/TestProjects/HDRP_DXR_Tests/LocalPackages/com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs.hlsl.meta +++ /dev/null @@ -1,9 +0,0 @@ -fileFormatVersion: 2 -guid: bcb8aa9f314d49b4c97aa1f3f3511e7b -ShaderImporter: - externalObjects: {} - defaultTextures: [] - nonModifiableTextures: [] - userData: - assetBundleName: - assetBundleVariant: diff --git a/TestProjects/HDRP_DXR_Tests/LocalPackages/com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs.meta b/TestProjects/HDRP_DXR_Tests/LocalPackages/com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs.meta deleted file mode 100644 index e4103cdaf61..00000000000 --- a/TestProjects/HDRP_DXR_Tests/LocalPackages/com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs.meta +++ /dev/null @@ -1,12 +0,0 @@ -fileFormatVersion: 2 -guid: 488b9213a64c77540bca3fe167edbe6c -timeCreated: 1475742183 -licenseType: Pro -MonoImporter: - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/TestProjects/HDRP_DXR_Tests/LocalPackages/com.unity.render-pipelines.high-definition-config/Runtime/Unity.RenderPipelines.HighDefinition.Config.Runtime.asmdef b/TestProjects/HDRP_DXR_Tests/LocalPackages/com.unity.render-pipelines.high-definition-config/Runtime/Unity.RenderPipelines.HighDefinition.Config.Runtime.asmdef deleted file mode 100644 index 6c4dd013f66..00000000000 --- a/TestProjects/HDRP_DXR_Tests/LocalPackages/com.unity.render-pipelines.high-definition-config/Runtime/Unity.RenderPipelines.HighDefinition.Config.Runtime.asmdef +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "Unity.RenderPipelines.HighDefinition.Config.Runtime", - "references": [ - "GUID:df380645f10b7bc4b97d4f5eb6303d95" - ], - "includePlatforms": [], - "excludePlatforms": [], - "allowUnsafeCode": true, - "overrideReferences": false, - "precompiledReferences": [], - "autoReferenced": true, - "defineConstraints": [], - "versionDefines": [] -} \ No newline at end of file diff --git a/TestProjects/HDRP_DXR_Tests/LocalPackages/com.unity.render-pipelines.high-definition-config/Runtime/Unity.RenderPipelines.HighDefinition.Config.Runtime.asmdef.meta b/TestProjects/HDRP_DXR_Tests/LocalPackages/com.unity.render-pipelines.high-definition-config/Runtime/Unity.RenderPipelines.HighDefinition.Config.Runtime.asmdef.meta deleted file mode 100644 index 7ab3dfd7dc4..00000000000 --- a/TestProjects/HDRP_DXR_Tests/LocalPackages/com.unity.render-pipelines.high-definition-config/Runtime/Unity.RenderPipelines.HighDefinition.Config.Runtime.asmdef.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: a075b55b404a34748ac14ea9b6039911 -AssemblyDefinitionImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/TestProjects/HDRP_DXR_Tests/LocalPackages/com.unity.render-pipelines.high-definition-config/package.json b/TestProjects/HDRP_DXR_Tests/LocalPackages/com.unity.render-pipelines.high-definition-config/package.json deleted file mode 100644 index 8fa61e8ca06..00000000000 --- a/TestProjects/HDRP_DXR_Tests/LocalPackages/com.unity.render-pipelines.high-definition-config/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "com.unity.render-pipelines.high-definition-config", - "description": "Configuration files for the High Definition Render Pipeline.", - "version": "10.0.0-preview.1", - "unity": "2020.2", - "unityRelease": "0a14", - "displayName": "High Definition RP Config", - "dependencies": { - "com.unity.render-pipelines.core": "10.0.0-preview.1" - } -} diff --git a/TestProjects/HDRP_DXR_Tests/LocalPackages/com.unity.render-pipelines.high-definition-config/package.json.meta b/TestProjects/HDRP_DXR_Tests/LocalPackages/com.unity.render-pipelines.high-definition-config/package.json.meta deleted file mode 100644 index 21281d76a2b..00000000000 --- a/TestProjects/HDRP_DXR_Tests/LocalPackages/com.unity.render-pipelines.high-definition-config/package.json.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: af6e0e6bb9a468845bfb9c9381e3219b -PackageManifestImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/TestProjects/HDRP_DXR_Tests/Packages/manifest.json b/TestProjects/HDRP_DXR_Tests/Packages/manifest.json index 5586ac58202..db4dbda5ee3 100644 --- a/TestProjects/HDRP_DXR_Tests/Packages/manifest.json +++ b/TestProjects/HDRP_DXR_Tests/Packages/manifest.json @@ -11,7 +11,7 @@ "com.unity.purchasing": "2.0.6", "com.unity.render-pipelines.core": "file:../../../com.unity.render-pipelines.core", "com.unity.render-pipelines.high-definition": "file:../../../com.unity.render-pipelines.high-definition", - "com.unity.render-pipelines.high-definition-config": "file:../LocalPackages/com.unity.render-pipelines.high-definition-config", + "com.unity.render-pipelines.high-definition-config": "file:../../../com.unity.render-pipelines.high-definition-config", "com.unity.shadergraph": "file:../../../com.unity.shadergraph", "com.unity.test-framework": "1.1.14", "com.unity.test-framework.build": "0.0.1-preview.12", diff --git a/com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs b/com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs index ac8b3435e33..3e28a07a2cb 100644 --- a/com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs +++ b/com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs @@ -35,11 +35,7 @@ public enum ShaderOptions CameraRelativeRendering = 1, // Rendering sets the origin of the world to the position of the primary (scene view) camera PreExposition = 1, PrecomputedAtmosphericAttenuation = 0, // Precomputes atmospheric attenuation for the directional light on the CPU, which makes it independent from the fragment's position, which is faster but wrong -#if ENABLE_RAYTRACING - Raytracing = 1, -#else - Raytracing = 0, -#endif + #if ENABLE_VR XrMaxViews = 2, // Used for single-pass rendering (with fast path in vertex shader code when forced to 2) #else diff --git a/com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs.hlsl b/com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs.hlsl index efc6d322dac..1c4835c2a0c 100644 --- a/com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs.hlsl +++ b/com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs.hlsl @@ -32,7 +32,6 @@ #define SHADEROPTIONS_CAMERA_RELATIVE_RENDERING (1) #define SHADEROPTIONS_PRE_EXPOSITION (1) #define SHADEROPTIONS_PRECOMPUTED_ATMOSPHERIC_ATTENUATION (0) -#define SHADEROPTIONS_RAYTRACING (0) #define SHADEROPTIONS_XR_MAX_VIEWS (2) #define SHADEROPTIONS_PROBE_VOLUMES_EVALUATION_MODE (0) #define SHADEROPTIONS_PROBE_VOLUMES_ADDITIVE_BLENDING (1) diff --git a/com.unity.render-pipelines.high-definition/Editor/BuildProcessors/HDRPPreprocessShaders.cs b/com.unity.render-pipelines.high-definition/Editor/BuildProcessors/HDRPPreprocessShaders.cs index 846edf391b5..47982e1c733 100644 --- a/com.unity.render-pipelines.high-definition/Editor/BuildProcessors/HDRPPreprocessShaders.cs +++ b/com.unity.render-pipelines.high-definition/Editor/BuildProcessors/HDRPPreprocessShaders.cs @@ -19,16 +19,6 @@ public CommonShaderPreprocessor() { } protected override bool DoShadersStripper(HDRenderPipelineAsset hdrpAsset, Shader shader, ShaderSnippetData snippet, ShaderCompilerData inputData) { - // Strip every useless shadow configs - var shadowInitParams = hdrpAsset.currentPlatformRenderPipelineSettings.hdShadowInitParams; - - foreach (var shadowVariant in m_ShadowKeywords.ShadowVariants) - { - if (shadowVariant.Key != shadowInitParams.shadowFilteringQuality) - if (inputData.shaderKeywordSet.IsEnabled(shadowVariant.Value)) - return true; - } - // CAUTION: Pass Name and Lightmode name must match in master node and .shader. // HDRP use LightMode to do drawRenderer and pass name is use here for stripping! @@ -82,6 +72,26 @@ protected override bool DoShadersStripper(HDRenderPipelineAsset hdrpAsset, Shade if (inputData.shaderKeywordSet.IsEnabled(m_SubsurfaceScattering) && !hdrpAsset.currentPlatformRenderPipelineSettings.supportSubsurfaceScattering) return true; + // SHADOW + + // Strip every useless shadow configs + var shadowInitParams = hdrpAsset.currentPlatformRenderPipelineSettings.hdShadowInitParams; + + foreach (var shadowVariant in m_ShadowKeywords.ShadowVariants) + { + if (shadowVariant.Key != shadowInitParams.shadowFilteringQuality) + if (inputData.shaderKeywordSet.IsEnabled(shadowVariant.Value)) + return true; + } + + // Screen space shadow variant is exclusive, either we have a variant with dynamic if that support screen space shadow or not + // either we have a variant that don't support at all. We can't have both at the same time. + if (inputData.shaderKeywordSet.IsEnabled(m_ScreenSpaceShadowOFFKeywords) && shadowInitParams.supportScreenSpaceShadows) + return true; + + if (inputData.shaderKeywordSet.IsEnabled(m_ScreenSpaceShadowONKeywords) && !shadowInitParams.supportScreenSpaceShadows) + return true; + // DECAL // Identify when we compile a decal shader @@ -134,6 +144,7 @@ protected override bool DoShadersStripper(HDRenderPipelineAsset hdrpAsset, Shade } } +#if UNITY_2020_2_OR_NEWER class HDRPPreprocessComputeShaders : IPreprocessComputeShaders { struct ExportComputeShaderStrip : System.IDisposable @@ -195,6 +206,8 @@ public void Dispose() protected ShadowKeywords m_ShadowKeywords = new ShadowKeywords(); protected ShaderKeyword m_EnableAlpha = new ShaderKeyword("ENABLE_ALPHA"); protected ShaderKeyword m_MSAA = new ShaderKeyword("ENABLE_MSAA"); + protected ShaderKeyword m_ScreenSpaceShadowOFFKeywords = new ShaderKeyword("SCREEN_SPACE_SHADOWS_OFF"); + protected ShaderKeyword m_ScreenSpaceShadowONKeywords = new ShaderKeyword("SCREEN_SPACE_SHADOWS_ON"); public int callbackOrder { get { return 0; } } @@ -226,18 +239,24 @@ internal bool StripShader(HDRenderPipelineAsset hdAsset, ComputeShader shader, s if (shadowVariant.Key != shadowInitParams.shadowFilteringQuality) { if (inputData.shaderKeywordSet.IsEnabled(shadowVariant.Value)) - { return true; - } } } - if(inputData.shaderKeywordSet.IsEnabled(m_MSAA) && !hdAsset.currentPlatformRenderPipelineSettings.supportMSAA) + // Screen space shadow variant is exclusive, either we have a variant with dynamic if that support screen space shadow or not + // either we have a variant that don't support at all. We can't have both at the same time. + if (inputData.shaderKeywordSet.IsEnabled(m_ScreenSpaceShadowOFFKeywords) && shadowInitParams.supportScreenSpaceShadows) + return true; + + if (inputData.shaderKeywordSet.IsEnabled(m_ScreenSpaceShadowONKeywords) && !shadowInitParams.supportScreenSpaceShadows) + return true; + + if (inputData.shaderKeywordSet.IsEnabled(m_MSAA) && !hdAsset.currentPlatformRenderPipelineSettings.supportMSAA) { return true; } - if(inputData.shaderKeywordSet.IsEnabled(m_EnableAlpha) && !hdAsset.currentPlatformRenderPipelineSettings.supportsAlpha) + if (inputData.shaderKeywordSet.IsEnabled(m_EnableAlpha) && !hdAsset.currentPlatformRenderPipelineSettings.supportsAlpha) { return true; } @@ -308,6 +327,7 @@ public void OnProcessComputeShader(ComputeShader shader, string kernelName, ILis } } } +#endif // #if UNITY_2020_2_OR_NEWER class HDRPreprocessShaders : IPreprocessShaders { diff --git a/com.unity.render-pipelines.high-definition/Editor/DefaultScene/HDWizard.Configuration.cs b/com.unity.render-pipelines.high-definition/Editor/DefaultScene/HDWizard.Configuration.cs index 63d6a89afc7..14ec5ac820d 100644 --- a/com.unity.render-pipelines.high-definition/Editor/DefaultScene/HDWizard.Configuration.cs +++ b/com.unity.render-pipelines.high-definition/Editor/DefaultScene/HDWizard.Configuration.cs @@ -172,7 +172,6 @@ Entry[] entries new Entry(InclusiveScope.DXR, Style.dxrReflections, IsDXRReflectionsCorrect, FixDXRReflections), new Entry(InclusiveScope.DXR, Style.dxrActivated, IsDXRActivationCorrect, FixDXRActivation), new Entry(InclusiveScope.DXR, Style.dxrResources, IsDXRAssetCorrect, FixDXRAsset), - new Entry(InclusiveScope.DXR, Style.dxrShaderConfig, IsDXRShaderConfigCorrect, FixDXRShaderConfig), new Entry(InclusiveScope.DXR, Style.dxrScene, IsDXRDefaultSceneCorrect, FixDXRDefaultScene), }; return m_Entries; @@ -634,42 +633,6 @@ void FixDXRAsset(bool fromAsyncUnused) = AssetDatabase.LoadAssetAtPath(HDUtils.GetHDRenderPipelinePath() + "Runtime/RenderPipelineResources/HDRenderPipelineRayTracingResources.asset"); ResourceReloader.ReloadAllNullIn(HDRenderPipeline.defaultAsset.renderPipelineRayTracingResources, HDUtils.GetHDRenderPipelinePath()); } - - bool IsDXRShaderConfigCorrect() - { - if (!lastPackageConfigInstalledCheck) - return false; - - bool found = false; - using (StreamReader streamReader = new StreamReader("LocalPackages/com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs.hlsl")) - { - while (!streamReader.EndOfStream && !found) - found = streamReader.ReadLine().Contains("#define SHADEROPTIONS_RAYTRACING (1)"); - } - return found; - } - void FixDXRShaderConfig(bool fromAsyncUnused) - { - Debug.Log("Fixing DXRShaderConfig"); - if (!lastPackageConfigInstalledCheck) - { - InstallLocalConfigurationPackage(() => FixDXRShaderConfig(false)); - } - else - { - // Then we want to make sure that the shader config value is set to 1 - string[] lines = System.IO.File.ReadAllLines("LocalPackages/com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs.hlsl"); - for (int lineIdx = 0; lineIdx < lines.Length; ++lineIdx) - { - if (lines[lineIdx].Contains("SHADEROPTIONS_RAYTRACING")) - { - lines[lineIdx] = "#define SHADEROPTIONS_RAYTRACING (1)"; - break; - } - } - File.WriteAllLines("LocalPackages/com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs.hlsl", lines); - } - } bool IsDXRScreenSpaceShadowCorrect() => HDRenderPipeline.currentAsset != null diff --git a/com.unity.render-pipelines.high-definition/Editor/DefaultScene/HDWizard.Window.cs b/com.unity.render-pipelines.high-definition/Editor/DefaultScene/HDWizard.Window.cs index e1f451f0171..1b2fbf166a1 100644 --- a/com.unity.render-pipelines.high-definition/Editor/DefaultScene/HDWizard.Window.cs +++ b/com.unity.render-pipelines.high-definition/Editor/DefaultScene/HDWizard.Window.cs @@ -152,9 +152,6 @@ public ConfigStyle(string label, string error, string button = resolve, MessageT public static readonly ConfigStyle dxrResources = new ConfigStyle( label: "DXR resources", error: "There is an issue with the DXR resources! Or your hardware and/or OS cannot be used for DXR! (unfixable in second case)"); - public static readonly ConfigStyle dxrShaderConfig = new ConfigStyle( - label: "DXR shader config", - error: "There is an issue with the DXR shader config!"); public static readonly ConfigStyle dxrScene = new ConfigStyle( label: "Default DXR scene prefab", error: "Default DXR scene prefab must be set to create HD templated scene!"); diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/BaseShaderPreprocessor.cs b/com.unity.render-pipelines.high-definition/Editor/Material/BaseShaderPreprocessor.cs index c3051691685..983be44a664 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/BaseShaderPreprocessor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/BaseShaderPreprocessor.cs @@ -49,6 +49,9 @@ abstract class BaseShaderPreprocessor protected ShaderKeyword m_WriteNormalBuffer; protected ShaderKeyword m_WriteMSAADepth; protected ShaderKeyword m_SubsurfaceScattering; + protected ShaderKeyword m_ScreenSpaceShadowOFFKeywords; + protected ShaderKeyword m_ScreenSpaceShadowONKeywords; + protected ShadowKeywords m_ShadowKeywords; protected Dictionary m_ShadowVariants; @@ -75,6 +78,9 @@ public BaseShaderPreprocessor() m_WriteNormalBuffer = new ShaderKeyword("WRITE_NORMAL_BUFFER"); m_WriteMSAADepth = new ShaderKeyword("WRITE_MSAA_DEPTH"); m_SubsurfaceScattering = new ShaderKeyword("OUTPUT_SPLIT_LIGHTING"); + m_ScreenSpaceShadowOFFKeywords = new ShaderKeyword("SCREEN_SPACE_SHADOWS_OFF"); + m_ScreenSpaceShadowONKeywords = new ShaderKeyword("SCREEN_SPACE_SHADOWS_ON"); + m_ShadowKeywords = new ShadowKeywords(); } diff --git a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDTarget.cs b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDTarget.cs index b3cea2344a4..09a26988a3e 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDTarget.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Material/ShaderGraph/HDTarget.cs @@ -870,6 +870,7 @@ static class CoreKeywords { Lightmaps }, { CoreKeywordDescriptors.ShadowsShadowmask }, { CoreKeywordDescriptors.Shadow }, + { CoreKeywordDescriptors.ScreenSpaceShadow }, { CoreKeywordDescriptors.Decals }, { CoreKeywordDescriptors.LightList, new FieldCondition(Fields.SurfaceOpaque, true) }, }; @@ -1114,6 +1115,20 @@ static class CoreKeywordDescriptors scope = KeywordScope.Global, }; + public static KeywordDescriptor ScreenSpaceShadow = new KeywordDescriptor() + { + displayName = "ScreenSpaceShadow", + referenceName = "SCREEN_SPACE_SHADOWS", + type = KeywordType.Enum, + definition = KeywordDefinition.MultiCompile, + scope = KeywordScope.Global, + entries = new KeywordEntry[] + { + new KeywordEntry() { displayName = "Off", referenceName = "OFF" }, + new KeywordEntry() { displayName = "On", referenceName = "ON" }, + } + }; + public static KeywordDescriptor LightLayers = new KeywordDescriptor() { displayName = "Light Layers", diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Deferred.shader b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Deferred.shader index 10af7eb0f8a..93336d39e82 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Deferred.shader +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Deferred.shader @@ -37,6 +37,7 @@ Shader "Hidden/HDRP/Deferred" // Split lighting is utilized during the SSS pass. #pragma multi_compile _ OUTPUT_SPLIT_LIGHTING #pragma multi_compile _ SHADOWS_SHADOWMASK + #pragma multi_compile SCREEN_SPACE_SHADOWS_OFF SCREEN_SPACE_SHADOWS_ON #pragma multi_compile _ DEBUG_DISPLAY #pragma multi_compile SHADOW_LOW SHADOW_MEDIUM SHADOW_HIGH diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightEvaluation.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightEvaluation.hlsl index c3497fd9162..869e9e416b3 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightEvaluation.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightEvaluation.hlsl @@ -421,7 +421,7 @@ SHADOW_TYPE EvaluateShadow_Punctual(LightLoopContext lightLoopContext, PositionI LightData light, BuiltinData builtinData, float3 N, float3 L, float4 distances) { #ifndef LIGHT_EVALUATION_NO_SHADOWS - SHADOW_TYPE shadow = 1.0; + float shadow = 1.0; float shadowMask = 1.0; float NdotL = dot(N, L); // Disable contact shadow and shadow mask when facing away from light (i.e transmission) @@ -431,7 +431,7 @@ SHADOW_TYPE EvaluateShadow_Punctual(LightLoopContext lightLoopContext, PositionI shadow = shadowMask = (light.shadowMaskSelector.x >= 0.0 && NdotL > 0.0) ? dot(BUILTIN_DATA_SHADOW_MASK, light.shadowMaskSelector) : 1.0; #endif -#if defined(SCREEN_SPACE_SHADOWS) && !defined(_SURFACE_TYPE_TRANSPARENT) && (SHADERPASS != SHADERPASS_VOLUMETRIC_LIGHTING) +#if defined(SCREEN_SPACE_SHADOWS_ON) && !defined(_SURFACE_TYPE_TRANSPARENT) if ((light.screenSpaceShadowIndex & SCREEN_SPACE_SHADOW_INDEX_MASK) != INVALID_SCREEN_SPACE_SHADOW) { shadow = GetScreenSpaceShadow(posInput, light.screenSpaceShadowIndex); @@ -476,7 +476,7 @@ SHADOW_TYPE EvaluateShadow_RectArea( LightLoopContext lightLoopContext, Position LightData light, BuiltinData builtinData, float3 N, float3 L, float dist) { #ifndef LIGHT_EVALUATION_NO_SHADOWS - SHADOW_TYPE shadow = 1.0; + float shadow = 1.0; float shadowMask = 1.0; float NdotL = dot(N, L); // Disable contact shadow and shadow mask when facing away from light (i.e transmission) @@ -486,7 +486,7 @@ SHADOW_TYPE EvaluateShadow_RectArea( LightLoopContext lightLoopContext, Position shadow = shadowMask = (light.shadowMaskSelector.x >= 0.0 && NdotL > 0.0) ? dot(BUILTIN_DATA_SHADOW_MASK, light.shadowMaskSelector) : 1.0; #endif -#if defined(SCREEN_SPACE_SHADOWS) && !defined(_SURFACE_TYPE_TRANSPARENT) && (SHADERPASS != SHADERPASS_VOLUMETRIC_LIGHTING) +#if defined(SCREEN_SPACE_SHADOWS_ON) && !defined(_SURFACE_TYPE_TRANSPARENT) if ((light.screenSpaceShadowIndex & SCREEN_SPACE_SHADOW_INDEX_MASK) != INVALID_SCREEN_SPACE_SHADOW) { shadow = GetScreenSpaceShadow(posInput, light.screenSpaceShadowIndex); diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/Deferred.compute b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/Deferred.compute index b78b9dee4b6..ff8f1b39077 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/Deferred.compute +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/Deferred.compute @@ -33,6 +33,7 @@ #pragma kernel Deferred_Indirect_Fptl_Variant28 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Fptl_Variant28 USE_INDIRECT VARIANT=28 #pragma multi_compile _ SHADOWS_SHADOWMASK +#pragma multi_compile SCREEN_SPACE_SHADOWS_OFF SCREEN_SPACE_SHADOWS_ON #pragma multi_compile SHADOW_LOW SHADOW_MEDIUM SHADOW_HIGH diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/DeferredTile.shader b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/DeferredTile.shader index d29856a198b..98d88f8405e 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/DeferredTile.shader +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/DeferredTile.shader @@ -305,6 +305,7 @@ Shader "Hidden/HDRP/DeferredTile" #pragma multi_compile _ OUTPUT_SPLIT_LIGHTING #pragma multi_compile _ DEBUG_DISPLAY #pragma multi_compile _ SHADOWS_SHADOWMASK /// Variant with and without shadowmask + #pragma multi_compile SCREEN_SPACE_SHADOWS_OFF SCREEN_SPACE_SHADOWS_ON #pragma multi_compile SHADOW_LOW SHADOW_MEDIUM SHADOW_HIGH #define USE_FPTL_LIGHTLIST 1 // deferred opaque always use FPTL diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs index e5cfe8f807a..0fefe0b3611 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs @@ -943,6 +943,23 @@ void InitializeLightLoop(IBLFilterBSDF[] iBLFilterBSDFArray) Shader.DisableKeyword(p); Shader.EnableKeyword(shadowKeywords[(int)shadowParams.shadowFilteringQuality]); + // Setup screen space shadow map usage. + // Screen space shadow map are currently only used with Raytracing and are a global keyword. + // either we support it and then use the variant that allow to enable/disable them, or we don't + // and use the variant that have them disabled. + // So this mean that even if we disable screen space shadow in frame settings, the version + // of the shader for the variant SCREEN_SPACE_SHADOWS is used, but a dynamic branch disable it. + if (shadowParams.supportScreenSpaceShadows) + { + Shader.EnableKeyword("SCREEN_SPACE_SHADOWS_ON"); + Shader.DisableKeyword("SCREEN_SPACE_SHADOWS_OFF"); + } + else + { + Shader.DisableKeyword("SCREEN_SPACE_SHADOWS_ON"); + Shader.EnableKeyword("SCREEN_SPACE_SHADOWS_OFF"); + } + InitShadowSystem(asset, defaultResources); s_lightVolumes = new DebugLightVolumes(); diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl index a708eb4fc20..b7741541e05 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.hlsl @@ -118,10 +118,10 @@ void ApplyDebug(LightLoopContext context, PositionInputs posInput, BSDFData bsdf { DirectionalLightData light = _DirectionalLightDatas[_DirectionalShadowIndex]; -#if defined(SCREEN_SPACE_SHADOWS) && !defined(_SURFACE_TYPE_TRANSPARENT) +#if defined(SCREEN_SPACE_SHADOWS_ON) && !defined(_SURFACE_TYPE_TRANSPARENT) if ((light.screenSpaceShadowIndex & SCREEN_SPACE_SHADOW_INDEX_MASK) != INVALID_SCREEN_SPACE_SHADOW) { - shadow = GetScreenSpaceColorShadow(posInput, light.screenSpaceShadowIndex); + shadow = GetScreenSpaceColorShadow(posInput, light.screenSpaceShadowIndex).SHADOW_TYPE_SWIZZLE; } else #endif @@ -190,7 +190,7 @@ void LightLoop( float3 V, PositionInputs posInput, PreLightData preLightData, BS { DirectionalLightData light = _DirectionalLightDatas[_DirectionalShadowIndex]; -#if defined(SCREEN_SPACE_SHADOWS) && !defined(_SURFACE_TYPE_TRANSPARENT) +#if defined(SCREEN_SPACE_SHADOWS_ON) && !defined(_SURFACE_TYPE_TRANSPARENT) if ((light.screenSpaceShadowIndex & SCREEN_SPACE_SHADOW_INDEX_MASK) != INVALID_SCREEN_SPACE_SHADOW) { context.shadowValue = GetScreenSpaceColorShadow(posInput, light.screenSpaceShadowIndex).SHADOW_TYPE_SWIZZLE; diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl index 5d9ed86d962..c2c8e0438c7 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl @@ -1,12 +1,6 @@ #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs.hlsl" #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/CookieSampling.hlsl" -// SCREEN_SPACE_SHADOWS needs to be defined in all cases in which they need to run. IMPORTANT: If this is activated, the light loop function WillRenderScreenSpaceShadows on C# MUST return true. -#if RAYTRACING_ENABLED && (SHADERPASS != SHADERPASS_RAYTRACING_INDIRECT) -// TODO: This will need to be a multi_compile when we'll have them on compute shaders. -#define SCREEN_SPACE_SHADOWS 1 -#endif - #define DWORD_PER_TILE 16 // See dwordsPerTile in LightLoop.cs, we have roomm for 31 lights and a number of light value all store on 16 bit (ushort) // Some file may not required HD shadow context at all. In this case provide an empty one diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.shader b/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.shader index c79b757d885..d50ead331b3 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.shader +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/AxF/AxF.shader @@ -397,6 +397,7 @@ Shader "HDRP/AxF" #pragma multi_compile _ DIRLIGHTMAP_COMBINED #pragma multi_compile _ DYNAMICLIGHTMAP_ON #pragma multi_compile _ SHADOWS_SHADOWMASK + #pragma multi_compile SCREEN_SPACE_SHADOWS_OFF SCREEN_SPACE_SHADOWS_ON // Setup DECALS_OFF so the shader stripper can remove variants #pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLit.shader b/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLit.shader index aaae7ac5a08..ae3ef2c3d02 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLit.shader +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLit.shader @@ -806,6 +806,7 @@ Shader "HDRP/LayeredLit" #pragma multi_compile _ DIRLIGHTMAP_COMBINED #pragma multi_compile _ DYNAMICLIGHTMAP_ON #pragma multi_compile _ SHADOWS_SHADOWMASK + #pragma multi_compile SCREEN_SPACE_SHADOWS_OFF SCREEN_SPACE_SHADOWS_ON // Setup DECALS_OFF so the shader stripper can remove variants #pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLitTessellation.shader b/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLitTessellation.shader index 6c3813a0768..920157693d8 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLitTessellation.shader +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLitTessellation.shader @@ -794,6 +794,7 @@ Shader "HDRP/LayeredLitTessellation" #pragma multi_compile _ DIRLIGHTMAP_COMBINED #pragma multi_compile _ DYNAMICLIGHTMAP_ON #pragma multi_compile _ SHADOWS_SHADOWMASK + #pragma multi_compile SCREEN_SPACE_SHADOWS_OFF SCREEN_SPACE_SHADOWS_ON // Setup DECALS_OFF so the shader stripper can remove variants #pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.shader b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.shader index 41c0b44e2a6..cb9ae72ca83 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.shader +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.shader @@ -737,6 +737,7 @@ Shader "HDRP/Lit" #pragma multi_compile _ DIRLIGHTMAP_COMBINED #pragma multi_compile _ DYNAMICLIGHTMAP_ON #pragma multi_compile _ SHADOWS_SHADOWMASK + #pragma multi_compile SCREEN_SPACE_SHADOWS_OFF SCREEN_SPACE_SHADOWS_ON // Setup DECALS_OFF so the shader stripper can remove variants #pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT @@ -811,6 +812,7 @@ Shader "HDRP/Lit" #pragma multi_compile _ DIRLIGHTMAP_COMBINED #pragma multi_compile _ DYNAMICLIGHTMAP_ON #pragma multi_compile _ SHADOWS_SHADOWMASK + #pragma multi_compile SCREEN_SPACE_SHADOWS_OFF SCREEN_SPACE_SHADOWS_ON // Setup DECALS_OFF so the shader stripper can remove variants #pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitTessellation.shader b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitTessellation.shader index d1a781726ed..74898d6e0a1 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitTessellation.shader +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitTessellation.shader @@ -665,6 +665,7 @@ Shader "HDRP/LitTessellation" #pragma multi_compile _ DIRLIGHTMAP_COMBINED #pragma multi_compile _ DYNAMICLIGHTMAP_ON #pragma multi_compile _ SHADOWS_SHADOWMASK + #pragma multi_compile SCREEN_SPACE_SHADOWS_OFF SCREEN_SPACE_SHADOWS_ON // Setup DECALS_OFF so the shader stripper can remove variants #pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT @@ -731,6 +732,7 @@ Shader "HDRP/LitTessellation" #pragma multi_compile _ DIRLIGHTMAP_COMBINED #pragma multi_compile _ DYNAMICLIGHTMAP_ON #pragma multi_compile _ SHADOWS_SHADOWMASK + #pragma multi_compile SCREEN_SPACE_SHADOWS_OFF SCREEN_SPACE_SHADOWS_ON // Setup DECALS_OFF so the shader stripper can remove variants #pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/TerrainLit/TerrainLit.shader b/com.unity.render-pipelines.high-definition/Runtime/Material/TerrainLit/TerrainLit.shader index 4552cafcadd..206f5ed28ff 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/TerrainLit/TerrainLit.shader +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/TerrainLit/TerrainLit.shader @@ -249,6 +249,7 @@ Shader "HDRP/TerrainLit" #pragma multi_compile _ DIRLIGHTMAP_COMBINED #pragma multi_compile _ DYNAMICLIGHTMAP_ON #pragma multi_compile _ SHADOWS_SHADOWMASK + #pragma multi_compile SCREEN_SPACE_SHADOWS_OFF SCREEN_SPACE_SHADOWS_ON // Setup DECALS_OFF so the shader stripper can remove variants #pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/TerrainLit/TerrainLit_Basemap.shader b/com.unity.render-pipelines.high-definition/Runtime/Material/TerrainLit/TerrainLit_Basemap.shader index 5c01c0cbdee..590613d2c9b 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/TerrainLit/TerrainLit_Basemap.shader +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/TerrainLit/TerrainLit_Basemap.shader @@ -201,6 +201,7 @@ Shader "Hidden/HDRP/TerrainLit_Basemap" #pragma multi_compile _ DIRLIGHTMAP_COMBINED #pragma multi_compile _ DYNAMICLIGHTMAP_ON #pragma multi_compile _ SHADOWS_SHADOWMASK + #pragma multi_compile SCREEN_SPACE_SHADOWS_OFF SCREEN_SPACE_SHADOWS_ON // Setup DECALS_OFF so the shader stripper can remove variants #pragma multi_compile DECALS_OFF DECALS_3RT DECALS_4RT diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/IndirectDiffuse/RaytracingIndirectDiffuse.compute b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/IndirectDiffuse/RaytracingIndirectDiffuse.compute index c09b4abf0f6..287c5fc0072 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/IndirectDiffuse/RaytracingIndirectDiffuse.compute +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/IndirectDiffuse/RaytracingIndirectDiffuse.compute @@ -138,7 +138,6 @@ void INDIRECT_DIFFUSE_INTEGRATION_UPSCALE(uint3 dispatchThreadId : SV_DispatchTh { UNITY_XR_ASSIGN_VIEW_INDEX(dispatchThreadId.z); -#if RAYTRACING_ENABLED #ifdef HALF_RESOLUTION // Compute the half res coordinate that we shall be using for our effect uint2 targetCoord = dispatchThreadId.xy; @@ -237,5 +236,4 @@ void INDIRECT_DIFFUSE_INTEGRATION_UPSCALE(uint3 dispatchThreadId : SV_DispatchTh { _UpscaledIndirectDiffuseTextureRW[COORD_TEXTURE2D_X(targetCoord)] = float4(resultSum.xyz / resultSum.w, 1.0); } -#endif } diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl index ea39ff3d17d..dc1efab57c5 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassDepthOnly.hlsl @@ -7,7 +7,22 @@ PackedVaryingsType Vert(AttributesMesh inputMesh) { VaryingsType varyingsType; - varyingsType.vmesh = VertMesh(inputMesh); + +#if (SHADERPASS == SHADERPASS_DEPTH_ONLY) && defined(HAVE_RECURSIVE_RENDERING) && !defined(SCENESELECTIONPASS) + // If we have a recursive raytrace object, we will not render it. + // As we don't want to rely on renderqueue to exclude the object from the list, + // we cull it by settings position to NaN value. + // TODO: provide a solution to filter dyanmically recursive raytrace object in the DrawRenderer + if (_EnableRecursiveRayTracing && _RayTracing > 0.0) + { + ZERO_INITIALIZE(VaryingsType, varyingsType); // Divide by 0 should produce a NaN and thus cull the primitive. + } + else +#endif + { + varyingsType.vmesh = VertMesh(inputMesh); + } + return PackVaryingsType(varyingsType); } diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassForward.hlsl b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassForward.hlsl index b9d548d1443..4a392bdfc40 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassForward.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassForward.hlsl @@ -35,7 +35,21 @@ PackedVaryingsToPS VertTesselation(VaryingsToDS input) PackedVaryingsType Vert(AttributesMesh inputMesh) { VaryingsType varyingsType; - varyingsType.vmesh = VertMesh(inputMesh); + +#if defined(HAVE_RECURSIVE_RENDERING) + // If we have a recursive raytrace object, we will not render it. + // As we don't want to rely on renderqueue to exclude the object from the list, + // we cull it by settings position to NaN value. + // TODO: provide a solution to filter dyanmically recursive raytrace object in the DrawRenderer + if (_EnableRecursiveRayTracing && _RayTracing > 0.0) + { + ZERO_INITIALIZE(VaryingsType, varyingsType); // Divide by 0 should produce a NaN and thus cull the primitive. + } + else +#endif + { + varyingsType.vmesh = VertMesh(inputMesh); + } return PackVaryingsType(varyingsType); } diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassGBuffer.hlsl b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassGBuffer.hlsl index aacfad5bb7a..852cb2afa6d 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassGBuffer.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassGBuffer.hlsl @@ -7,7 +7,22 @@ PackedVaryingsType Vert(AttributesMesh inputMesh) { VaryingsType varyingsType; - varyingsType.vmesh = VertMesh(inputMesh); + +#if defined(HAVE_RECURSIVE_RENDERING) + // If we have a recursive raytrace object, we will not render it. + // As we don't want to rely on renderqueue to exclude the object from the list, + // we cull it by settings position to NaN value. + // TODO: provide a solution to filter dyanmically recursive raytrace object in the DrawRenderer + if (_EnableRecursiveRayTracing && _RayTracing > 0.0) + { + ZERO_INITIALIZE(VaryingsType, varyingsType); // Divide by 0 should produce a NaN and thus cull the primitive. + } + else +#endif + { + varyingsType.vmesh = VertMesh(inputMesh); + } + return PackVaryingsType(varyingsType); } diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/VertMesh.hlsl b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/VertMesh.hlsl index e902906a95c..61d5ddbcb91 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/VertMesh.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/VertMesh.hlsl @@ -98,86 +98,67 @@ VaryingsToDS InterpolateWithBaryCoordsToDS(VaryingsToDS input0, VaryingsToDS inp #define PackVaryingsType PackVaryingsToPS #endif -#define TEST_RECURSIVE_RENDERING (SHADEROPTIONS_RAYTRACING && defined(HAVE_RECURSIVE_RENDERING) && (SHADERPASS == SHADERPASS_GBUFFER || SHADERPASS == SHADERPASS_FORWARD || (SHADERPASS == SHADERPASS_DEPTH_ONLY && !defined(SCENESELECTIONPASS)))) // TODO: Here we will also have all the vertex deformation (GPU skinning, vertex animation, morph target...) or we will need to generate a compute shaders instead (better! but require work to deal with unpacking like fp16) // Make it inout so that MotionVectorPass can get the modified input values later. VaryingsMeshType VertMesh(AttributesMesh input) { VaryingsMeshType output; - // If we have a recursive raytrace object, we will not render it. - // As we don't want to rely on renderqueue to exclude the object from the list, - // we cull it by settings position to NaN value. - // TODO: provide a solution to filter dyanmically recursive raytrace object in the DrawRenderer -#if TEST_RECURSIVE_RENDERING - // Note: Raytrace object can output in motion vector pass and shadow pass - if (_EnableRecursiveRayTracing && _RayTracing > 0.0) - { - ZERO_INITIALIZE(VaryingsMeshType, output); // Divide by 0 should produce a NaN and thus cull the primitive. - } - else - { -#endif - - UNITY_SETUP_INSTANCE_ID(input); - UNITY_TRANSFER_INSTANCE_ID(input, output); + UNITY_SETUP_INSTANCE_ID(input); + UNITY_TRANSFER_INSTANCE_ID(input, output); #if defined(HAVE_MESH_MODIFICATION) - input = ApplyMeshModification(input, _TimeParameters.xyz); + input = ApplyMeshModification(input, _TimeParameters.xyz); #endif - // This return the camera relative position (if enable) - float3 positionRWS = TransformObjectToWorld(input.positionOS); + // This return the camera relative position (if enable) + float3 positionRWS = TransformObjectToWorld(input.positionOS); #ifdef ATTRIBUTES_NEED_NORMAL - float3 normalWS = TransformObjectToWorldNormal(input.normalOS); + float3 normalWS = TransformObjectToWorldNormal(input.normalOS); #else - float3 normalWS = float3(0.0, 0.0, 0.0); // We need this case to be able to compile ApplyVertexModification that doesn't use normal. + float3 normalWS = float3(0.0, 0.0, 0.0); // We need this case to be able to compile ApplyVertexModification that doesn't use normal. #endif #ifdef ATTRIBUTES_NEED_TANGENT - float4 tangentWS = float4(TransformObjectToWorldDir(input.tangentOS.xyz), input.tangentOS.w); + float4 tangentWS = float4(TransformObjectToWorldDir(input.tangentOS.xyz), input.tangentOS.w); #endif - // Do vertex modification in camera relative space (if enable) + // Do vertex modification in camera relative space (if enable) #if defined(HAVE_VERTEX_MODIFICATION) - ApplyVertexModification(input, normalWS, positionRWS, _TimeParameters.xyz); + ApplyVertexModification(input, normalWS, positionRWS, _TimeParameters.xyz); #endif #ifdef TESSELLATION_ON - output.positionRWS = positionRWS; - output.normalWS = normalWS; + output.positionRWS = positionRWS; + output.normalWS = normalWS; #if defined(VARYINGS_NEED_TANGENT_TO_WORLD) || defined(VARYINGS_DS_NEED_TANGENT) - output.tangentWS = tangentWS; + output.tangentWS = tangentWS; #endif #else #ifdef VARYINGS_NEED_POSITION_WS - output.positionRWS = positionRWS; + output.positionRWS = positionRWS; #endif - output.positionCS = TransformWorldToHClip(positionRWS); + output.positionCS = TransformWorldToHClip(positionRWS); #ifdef VARYINGS_NEED_TANGENT_TO_WORLD - output.normalWS = normalWS; - output.tangentWS = tangentWS; + output.normalWS = normalWS; + output.tangentWS = tangentWS; #endif #endif #if defined(VARYINGS_NEED_TEXCOORD0) || defined(VARYINGS_DS_NEED_TEXCOORD0) - output.texCoord0 = input.uv0; + output.texCoord0 = input.uv0; #endif #if defined(VARYINGS_NEED_TEXCOORD1) || defined(VARYINGS_DS_NEED_TEXCOORD1) - output.texCoord1 = input.uv1; + output.texCoord1 = input.uv1; #endif #if defined(VARYINGS_NEED_TEXCOORD2) || defined(VARYINGS_DS_NEED_TEXCOORD2) - output.texCoord2 = input.uv2; + output.texCoord2 = input.uv2; #endif #if defined(VARYINGS_NEED_TEXCOORD3) || defined(VARYINGS_DS_NEED_TEXCOORD3) - output.texCoord3 = input.uv3; + output.texCoord3 = input.uv3; #endif #if defined(VARYINGS_NEED_COLOR) || defined(VARYINGS_DS_NEED_COLOR) - output.color = input.color; -#endif - -#if TEST_RECURSIVE_RENDERING - } + output.color = input.color; #endif return output; diff --git a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl index ca0ec010edf..ecb25da1edc 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl @@ -26,13 +26,7 @@ #define UNITY_LIGHTMODEL_AMBIENT (glstate_lightmodel_ambient * 2) -// This only defines the ray tracing macro on the platforms that support ray tracing this should be dx12 -#if (SHADEROPTIONS_RAYTRACING && (defined(SHADER_API_D3D11) || defined(SHADER_API_D3D12)) && !defined(SHADER_API_XBOXONE) && !defined(SHADER_API_PSSL)) -#define RAYTRACING_ENABLED (1) -#else -#define RAYTRACING_ENABLED (0) -#endif - +// Define the type for shadow (either colored shadow or monochrome shadow) #if SHADEROPTIONS_COLORED_SHADOW #define SHADOW_TYPE real3 #define SHADOW_TYPE_SWIZZLE xyz