From c006e6dc6d7f32b956fa079897cb310bdc850e97 Mon Sep 17 00:00:00 2001 From: sebastienlagarde Date: Wed, 17 Jun 2020 02:28:34 +0200 Subject: [PATCH 01/11] Change code to have a indirectDiffuseMode and start to clean RaytracingMacro --- .../Runtime/ShaderConfig.cs.hlsl | 8 --- .../Runtime/Lighting/LightEvaluation.hlsl | 17 +++--- .../Runtime/Lighting/LightLoop/LightLoop.cs | 5 -- .../Lighting/LightLoop/LightLoop.cs.hlsl | 3 -- .../Runtime/Lighting/LightLoop/LightLoop.hlsl | 27 +++++++--- .../ScreenSpaceGlobalIllumination.cs | 29 +++++++--- .../ScreenSpaceGlobalIllumination.cs.hlsl | 15 ++++++ ...ScreenSpaceGlobalIllumination.cs.hlsl.meta | 10 ++++ .../Runtime/Material/BuiltinGIUtilities.hlsl | 28 ++++++---- .../Runtime/Material/BuiltinUtilities.hlsl | 10 ---- .../SubsurfaceScatteringManager.cs | 2 +- .../HDRenderPipeline.RenderGraph.cs | 1 + .../RenderPipeline/HDRenderPipeline.cs | 53 +++++++------------ .../Raytracing/HDRaytracingIndirectDiffuse.cs | 12 ----- .../RenderPipeline/Settings/FrameSettings.cs | 3 +- .../ShaderLibrary/ShaderVariablesGlobal.cs | 4 +- .../ShaderVariablesGlobal.cs.hlsl | 4 +- 17 files changed, 118 insertions(+), 113 deletions(-) create mode 100644 com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ScreenSpaceGlobalIllumination.cs.hlsl create mode 100644 com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ScreenSpaceGlobalIllumination.cs.hlsl.meta 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 index a593822cbef..6b354cd380c 100644 --- 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 @@ -4,13 +4,6 @@ #ifndef SHADERCONFIG_CS_HLSL #define SHADERCONFIG_CS_HLSL -// -// UnityEngine.Rendering.HighDefinition.HDShadowFilteringQuality: static fields -// -#define HDSHADOWFILTERINGQUALITY_LOW (0) -#define HDSHADOWFILTERINGQUALITY_MEDIUM (1) -#define HDSHADOWFILTERINGQUALITY_HIGH (2) - // // UnityEngine.Rendering.HighDefinition.ProbeVolumesEvaluationModes: static fields // @@ -45,7 +38,6 @@ #define SHADEROPTIONS_PROBE_VOLUMES_BILATERAL_FILTERING_MODE (1) #define SHADEROPTIONS_PROBE_VOLUMES_ENCODING_MODE (1) #define SHADEROPTIONS_AREA_LIGHTS (1) -#define SHADEROPTIONS_DEFERRED_SHADOW_FILTERING (1) #define SHADEROPTIONS_BARN_DOOR (0) 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 706a9e1787b..3e93f753279 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightEvaluation.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightEvaluation.hlsl @@ -526,20 +526,17 @@ void EvaluateLight_EnvIntersection(float3 positionWS, float3 normalWS, EnvLightD void InversePreExposeSsrLighting(inout float4 ssrLighting) { - float prevExposureInvMultiplier = GetInversePreviousExposureMultiplier(); - -#if SHADEROPTIONS_RAYTRACING - if (!_UseRayTracedReflections) -#endif - ssrLighting.rgb *= prevExposureInvMultiplier; + // Raytrace reflection use the current frame exposure - TODO: currently the buffer don't use pre-exposure. + // Screen space reflection reuse color buffer from previous frame + float exposureMultiplier = _EnableRayTracedReflections ? 1.0 : GetInversePreviousExposureMultiplier(); + ssrLighting.rgb *= exposureMultiplier; } void ApplyScreenSpaceReflectionWeight(inout float4 ssrLighting) { // Note: RGB is already premultiplied by A for SSR -#if SHADEROPTIONS_RAYTRACING - if (_UseRayTracedReflections) - ssrLighting.rgb *= ssrLighting.a; -#endif + // TODO: check why it isn't consistent between SSR and RTR + float weight = _EnableRayTracedReflections ? 1.0 : ssrLighting.a; + ssrLighting.rgb *= ssrLighting.a; } #endif 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 950f7f75f05..e5cfe8f807a 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 @@ -121,11 +121,6 @@ class LightDefinitions public static uint s_ScreenSpaceColorShadowFlag = 0x100; public static uint s_InvalidScreenSpaceShadow = 0xff; public static uint s_ScreenSpaceShadowIndexMask = 0xff; - - // Indirect diffuse flags - public static int k_IndirectDiffuseFlagOff = 0x00; - public static int k_ScreenSpaceIndirectDiffuseFlag = 0x01; - public static int k_RayTracedIndirectDiffuseFlag = 0x02; } [GenerateHLSL] diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs.hlsl index 63b4a6b8c86..b13cb8c12e9 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs.hlsl @@ -59,9 +59,6 @@ #define SCREEN_SPACE_COLOR_SHADOW_FLAG (256) #define INVALID_SCREEN_SPACE_SHADOW (255) #define SCREEN_SPACE_SHADOW_INDEX_MASK (255) -#define INDIRECT_DIFFUSE_FLAG_OFF (0) -#define SCREEN_SPACE_INDIRECT_DIFFUSE_FLAG (1) -#define RAY_TRACED_INDIRECT_DIFFUSE_FLAG (2) // Generated from UnityEngine.Rendering.HighDefinition.SFiniteLightBound // PackingRules = Exact 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 a182d07ec53..1ffc924088f 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 @@ -2,6 +2,9 @@ #if SHADEROPTIONS_PROBE_VOLUMES_EVALUATION_MODE == PROBEVOLUMESEVALUATIONMODES_LIGHT_LOOP #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl" +#else +// Required to have access to the indirectDiffuseMode enum in forward pass where we don't include BuiltinUtilities +#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ScreenSpaceGlobalIllumination.cs.hlsl" #endif // We perform scalarization only for forward rendering as for deferred loads will already be scalar since tiles will match waves and therefore all threads will read from the same tile. @@ -534,15 +537,23 @@ void LightLoop( float3 V, PositionInputs posInput, PreLightData preLightData, BS #if !defined(_SURFACE_TYPE_TRANSPARENT) // If we use the texture ssgi for ssgi or rtgi, we want to combine it with the value in the bake diffuse lighting value - if (_UseIndirectDiffuse != INDIRECT_DIFFUSE_FLAG_OFF) + if (_IndirectDiffuseMode != INDIRECTDIFFUSEMODE_OFF) { - BuiltinData builtInDataSSGI; - ZERO_INITIALIZE(BuiltinData, builtInDataSSGI); - builtInDataSSGI.bakeDiffuseLighting = LOAD_TEXTURE2D_X(_IndirectDiffuseTexture, posInput.positionSS).xyz * GetInverseCurrentExposureMultiplier(); - float indirectDiffuseMultiplier = GetIndirectDiffuseMultiplier(builtinData.renderingLayers); - builtInDataSSGI.bakeDiffuseLighting *= indirectDiffuseMultiplier; - ModifyBakedDiffuseLighting(V, posInput, preLightData, bsdfData, builtInDataSSGI); - builtinData.bakeDiffuseLighting += builtInDataSSGI.bakeDiffuseLighting; + BuiltinData builtinDataSSGI; + ZERO_INITIALIZE(BuiltinData, builtinDataSSGI); + builtinDataSSGI.bakeDiffuseLighting = LOAD_TEXTURE2D_X(_IndirectDiffuseTexture, posInput.positionSS).xyz * GetInverseCurrentExposureMultiplier(); + builtinDataSSGI.bakeDiffuseLighting *= GetIndirectDiffuseMultiplier(builtinData.renderingLayers); + + // TODO: try to see if we can share code with probe volume +#ifdef MODIFY_BAKED_DIFFUSE_LIGHTING +#ifdef DEBUG_DISPLAY + // When the lux meter is enabled, we don't want the albedo of the material to modify the diffuse baked lighting + if (_DebugLightingMode != DEBUGLIGHTINGMODE_LUX_METER) +#endif + ModifyBakedDiffuseLighting(V, posInput, preLightData, bsdfData, builtinDataSSGI); + +#endif + builtinData.bakeDiffuseLighting += builtinDataSSGI.bakeDiffuseLighting; } #endif diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ScreenSpaceGlobalIllumination.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ScreenSpaceGlobalIllumination.cs index 4d48d36f971..fa7a5956b10 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ScreenSpaceGlobalIllumination.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ScreenSpaceGlobalIllumination.cs @@ -2,6 +2,15 @@ namespace UnityEngine.Rendering.HighDefinition { + [GenerateHLSL] + // Define if we use SSGI, RTGI or none + enum IndirectDiffuseMode + { + Off, + ScreenSpace, + Raytrace + } + public partial class HDRenderPipeline { // Buffers used for the evaluation @@ -52,13 +61,21 @@ void ReleaseScreenSpaceGlobalIllumination() } // This is shared between SSGI and RTGI - bool ValidIndirectDiffuseState(HDCamera hdCamera) + IndirectDiffuseMode GetIndirectDiffuseMode(HDCamera hdCamera) { - var settings = hdCamera.volumeStack.GetComponent(); - return m_Asset.currentPlatformRenderPipelineSettings.supportSSGI - && hdCamera.camera.cameraType != CameraType.Reflection - && hdCamera.frameSettings.IsEnabled(FrameSettingsField.SSGI) - && settings.enable.value; + IndirectDiffuseMode mode = IndirectDiffuseMode.Off; + + if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.SSGI)) + { + var settings = hdCamera.volumeStack.GetComponent(); + if (settings.enable.value) + { + // RTGI is only valid if raytracing is enabled + bool raytracing = hdCamera.frameSettings.IsEnabled(FrameSettingsField.RayTracing) && settings.rayTracing.value; + mode = raytracing ? IndirectDiffuseMode.Raytrace : IndirectDiffuseMode.ScreenSpace; + } + } + return mode; } // Bind the indirect diffuse texture for the lightloop to read from it diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ScreenSpaceGlobalIllumination.cs.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ScreenSpaceGlobalIllumination.cs.hlsl new file mode 100644 index 00000000000..f592dfe6892 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ScreenSpaceGlobalIllumination.cs.hlsl @@ -0,0 +1,15 @@ +// +// This file was automatically generated. Please don't edit by hand. +// + +#ifndef SCREENSPACEGLOBALILLUMINATION_CS_HLSL +#define SCREENSPACEGLOBALILLUMINATION_CS_HLSL +// +// UnityEngine.Rendering.HighDefinition.IndirectDiffuseMode: static fields +// +#define INDIRECTDIFFUSEMODE_OFF (0) +#define INDIRECTDIFFUSEMODE_SCREEN_SPACE (1) +#define INDIRECTDIFFUSEMODE_RAYTRACE (2) + + +#endif diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ScreenSpaceGlobalIllumination.cs.hlsl.meta b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ScreenSpaceGlobalIllumination.cs.hlsl.meta new file mode 100644 index 00000000000..08a3fdb9904 --- /dev/null +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ScreenSpaceGlobalIllumination.cs.hlsl.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 27b3afeb6fce1d4498775965a8582439 +ShaderImporter: + externalObjects: {} + defaultTextures: [] + nonModifiableTextures: [] + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinGIUtilities.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinGIUtilities.hlsl index 1bba1ad2a07..cab6d66d264 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinGIUtilities.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinGIUtilities.hlsl @@ -1,6 +1,9 @@ #ifndef __BUILTINGIUTILITIES_HLSL__ #define __BUILTINGIUTILITIES_HLSL__ +// Include the IndirectDiffuseMode enum +#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ScreenSpaceGlobalIllumination.cs.hlsl" + #ifdef SHADERPASS #if ((SHADEROPTIONS_PROBE_VOLUMES_EVALUATION_MODE == PROBEVOLUMESEVALUATIONMODES_MATERIAL_PASS) && (SHADERPASS == SHADERPASS_GBUFFER || SHADERPASS == SHADERPASS_FORWARD)) || \ ((SHADEROPTIONS_PROBE_VOLUMES_EVALUATION_MODE == PROBEVOLUMESEVALUATIONMODES_LIGHT_LOOP) && (SHADERPASS == SHADERPASS_DEFERRED_LIGHTING || SHADERPASS == SHADERPASS_FORWARD)) @@ -83,14 +86,8 @@ void EvaluateLightProbeBuiltin(float3 positionRWS, float3 normalWS, float3 backN } else { -#if RAYTRACING_ENABLED - if (unity_ProbeVolumeParams.w == 1.0) - SampleProbeVolumeSH9(TEXTURE3D_ARGS(unity_ProbeVolumeSH, samplerunity_ProbeVolumeSH), positionRWS, normalWS, backNormalWS, GetProbeVolumeWorldToObject(), - unity_ProbeVolumeParams.y, unity_ProbeVolumeParams.z, unity_ProbeVolumeMin.xyz, unity_ProbeVolumeSizeInv.xyz, bakeDiffuseLighting, backBakeDiffuseLighting); - else -#endif - SampleProbeVolumeSH4(TEXTURE3D_ARGS(unity_ProbeVolumeSH, samplerunity_ProbeVolumeSH), positionRWS, normalWS, backNormalWS, GetProbeVolumeWorldToObject(), - unity_ProbeVolumeParams.y, unity_ProbeVolumeParams.z, unity_ProbeVolumeMin.xyz, unity_ProbeVolumeSizeInv.xyz, bakeDiffuseLighting, backBakeDiffuseLighting); + SampleProbeVolumeSH4(TEXTURE3D_ARGS(unity_ProbeVolumeSH, samplerunity_ProbeVolumeSH), positionRWS, normalWS, backNormalWS, GetProbeVolumeWorldToObject(), + unity_ProbeVolumeParams.y, unity_ProbeVolumeParams.z, unity_ProbeVolumeMin.xyz, unity_ProbeVolumeSizeInv.xyz, bakeDiffuseLighting, backBakeDiffuseLighting); } } @@ -105,6 +102,18 @@ void SampleBakedGI( out float3 bakeDiffuseLighting, out float3 backBakeDiffuseLighting) { + bakeDiffuseLighting = float3(0, 0, 0); + backBakeDiffuseLighting = float3(0, 0, 0); + + // Check if we are RTGI in which case we don't want to read GI at all (We rely fully on the raytrace effect) + // The check need to be here to work with both regular shader and shader graph + // Note: with Probe volume it will prevent to add the UNINITIALIZED_GI tag and + // the ProbeVolume will not be evaluate in the lightloop which is the desired behavior +#if !defined(_SURFACE_TYPE_TRANSPARENT) + if (_IndirectDiffuseMode == INDIRECTDIFFUSEMODE_RAYTRACE) + return ; +#endif + float3 positionRWS = posInputs.positionWS; #define SAMPLE_LIGHTMAP (defined(LIGHTMAP_ON) || defined(DYNAMICLIGHTMAP_ON)) @@ -112,9 +121,6 @@ void SampleBakedGI( && (!SAMPLE_LIGHTMAP || SHADEROPTIONS_PROBE_VOLUMES_ADDITIVE_BLENDING) #define SAMPLE_PROBEVOLUME_BUILTIN (!SAMPLE_LIGHTMAP && !SAMPLE_PROBEVOLUME) - bakeDiffuseLighting = float3(0, 0, 0); - backBakeDiffuseLighting = float3(0, 0, 0); - #if SAMPLE_LIGHTMAP EvaluateLightmap(positionRWS, normalWS, backNormalWS, uvStaticLightmap, uvDynamicLightmap, bakeDiffuseLighting, backBakeDiffuseLighting); #endif diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl index 60ec640bba0..5b2bd9f44c4 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/BuiltinUtilities.hlsl @@ -46,16 +46,6 @@ void InitBuiltinData(PositionInputs posInput, float alpha, float3 normalWS, floa builtinData.backBakeDiffuseLighting = 0.0; SampleBakedGI( posInput, normalWS, backNormalWS, builtinData.renderingLayers, texCoord1.xy, texCoord2.xy, builtinData.bakeDiffuseLighting, builtinData.backBakeDiffuseLighting); - - // We only want to read the screen space buffer that holds the indirect diffuse signal if this is not a transparent surface -#if RAYTRACING_ENABLED && ((SHADERPASS == SHADERPASS_GBUFFER) || (SHADERPASS == SHADERPASS_FORWARD)) && !defined(_SURFACE_TYPE_TRANSPARENT) - if (_UseIndirectDiffuse == RAY_TRACED_INDIRECT_DIFFUSE_FLAG) - { - // Incase we shall be using raytraced indirect diffuse, we want to make sure to not add the other forms of indirect lighting to avoid - // double contribution. - builtinData.bakeDiffuseLighting = float3(0.0, 0.0, 0.0); - } -#endif #ifdef SHADOWS_SHADOWMASK float4 shadowMask = SampleShadowMask(posInput.positionWS, texCoord1.xy); diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/SubsurfaceScattering/SubsurfaceScatteringManager.cs b/com.unity.render-pipelines.high-definition/Runtime/Material/SubsurfaceScattering/SubsurfaceScatteringManager.cs index 05a93901fbd..250732fcf0e 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/SubsurfaceScattering/SubsurfaceScatteringManager.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/SubsurfaceScattering/SubsurfaceScatteringManager.cs @@ -390,7 +390,7 @@ void RenderSubsurfaceScattering(HDCamera hdCamera, CommandBuffer cmd, RTHandle c // Now based on the mask, we need to blend the subsurface and the diffuse lighting - bool validSSGI = ValidIndirectDiffuseState(hdCamera); + bool validSSGI = GetIndirectDiffuseMode(hdCamera) != IndirectDiffuseMode.Off; int m_CombineSubSurfaceKernel = rayTracingSubSurfaceCS.FindKernel(validSSGI ? "BlendSubSurfaceDataWithGI" : "BlendSubSurfaceData"); cmd.SetComputeTextureParam(rayTracingSubSurfaceCS, m_CombineSubSurfaceKernel, HDShaderIDs._SubSurfaceLightingBuffer, intermediateBuffer0); cmd.SetComputeTextureParam(rayTracingSubSurfaceCS, m_CombineSubSurfaceKernel, HDShaderIDs._DiffuseLightingTextureRW, diffuseBufferRT); diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs index fd432eb5872..a3c5b74b9f4 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.RenderGraph.cs @@ -102,6 +102,7 @@ void ExecuteWithRenderGraph( RenderRequest renderRequest, // lightCluster.EvaluateClusterDebugView(cmd, hdCamera); // } + // TODO: check code, everything have change // bool validIndirectDiffuse = ValidIndirectDiffuseState(hdCamera); // if (validIndirectDiffuse) // { diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs index 58a8e2fdd1b..9f40df332eb 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -1266,21 +1266,21 @@ void UpdateShaderVariablesGlobalCB(HDCamera hdCamera, CommandBuffer cmd) m_ShaderVariablesGlobalCB._CoarseStencilBufferSize = new Vector4(coarseStencilWidth, coarseStencilHeight, 1.0f / coarseStencilWidth, 1.0f / coarseStencilHeight); m_ShaderVariablesGlobalCB._RaytracingFrameIndex = RayTracingFrameIndex(hdCamera); + m_ShaderVariablesGlobalCB._IndirectDiffuseMode = (int)GetIndirectDiffuseMode(hdCamera); + if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.RayTracing)) { // Check if recursive rendering is enabled or not. This will control the cull of primitive // during the gbuffer and forward pass - RecursiveRendering recursiveSettings = hdCamera.volumeStack.GetComponent(); ScreenSpaceReflection settings = hdCamera.volumeStack.GetComponent(); - bool usesRaytracedReflections = hdCamera.frameSettings.IsEnabled(FrameSettingsField.RayTracing) && settings.rayTracing.value; - m_ShaderVariablesGlobalCB._UseRayTracedReflections = usesRaytracedReflections ? 1 : 0; - m_ShaderVariablesGlobalCB._UseIndirectDiffuse = ValidIndirectDiffuseState(hdCamera) ? (RayTracedIndirectDiffuseState(hdCamera) ? LightDefinitions.k_RayTracedIndirectDiffuseFlag : LightDefinitions.k_ScreenSpaceIndirectDiffuseFlag) : LightDefinitions.k_IndirectDiffuseFlagOff; + bool enableRaytracedReflections = hdCamera.frameSettings.IsEnabled(FrameSettingsField.RayTracing) && settings.rayTracing.value; + m_ShaderVariablesGlobalCB._EnableRayTracedReflections = enableRaytracedReflections ? 1 : 0; + RecursiveRendering recursiveSettings = hdCamera.volumeStack.GetComponent(); m_ShaderVariablesGlobalCB._EnableRecursiveRayTracing = recursiveSettings.enable.value ? 1u : 0u; } else { - m_ShaderVariablesGlobalCB._UseRayTracedReflections = 0; - m_ShaderVariablesGlobalCB._UseIndirectDiffuse = ValidIndirectDiffuseState(hdCamera) ? LightDefinitions.k_ScreenSpaceIndirectDiffuseFlag : LightDefinitions.k_IndirectDiffuseFlagOff; + m_ShaderVariablesGlobalCB._EnableRayTracedReflections = 0; m_ShaderVariablesGlobalCB._EnableRecursiveRayTracing = 0; } @@ -2603,37 +2603,22 @@ void AsyncSSAODispatch(CommandBuffer c, HDGPUAsyncTaskParams a) HDRaytracingLightCluster lightCluster = RequestLightCluster(); lightCluster.EvaluateClusterDebugView(cmd, hdCamera); } - - bool validIndirectDiffuse = ValidIndirectDiffuseState(hdCamera); - if (validIndirectDiffuse) - { - if (RayTracedIndirectDiffuseState(hdCamera)) - { - RenderRayTracedIndirectDiffuse(hdCamera, cmd, renderContext, m_FrameCount); - } - else - { - RenderSSGI(hdCamera, cmd, renderContext, m_FrameCount); - BindIndirectDiffuseTexture(cmd); - } - } - else - { - BindBlackIndirectDiffuseTexture(cmd); - } } - else + + switch (GetIndirectDiffuseMode(hdCamera)) { - bool validIndirectDiffuse = ValidIndirectDiffuseState(hdCamera); - if (validIndirectDiffuse) - { + case IndirectDiffuseMode.Off: + BindBlackIndirectDiffuseTexture(cmd); + break; + + case IndirectDiffuseMode.ScreenSpace: RenderSSGI(hdCamera, cmd, renderContext, m_FrameCount); BindIndirectDiffuseTexture(cmd); - } - else - { - BindBlackIndirectDiffuseTexture(cmd); - } + break; + + case IndirectDiffuseMode.Raytrace: + RenderRayTracedIndirectDiffuse(hdCamera, cmd, renderContext, m_FrameCount); + break; } if (!hdCamera.frameSettings.SSRRunsAsync()) @@ -5308,7 +5293,7 @@ void SendGeometryGraphicsBuffers(CommandBuffer cmd, HDCamera hdCamera) VFXCameraBufferTypes neededVFXBuffers = VFXManager.IsCameraBufferNeeded(hdCamera.camera); needNormalBuffer |= ((neededVFXBuffers & VFXCameraBufferTypes.Normal) != 0 || (externalAccess & HDAdditionalCameraData.BufferAccessType.Normal) != 0); needDepthBuffer |= ((neededVFXBuffers & VFXCameraBufferTypes.Depth) != 0 || (externalAccess & HDAdditionalCameraData.BufferAccessType.Depth) != 0); - if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.RayTracing) && GetRayTracingState() || ValidIndirectDiffuseState(hdCamera)) + if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.RayTracing) && GetRayTracingState() || GetIndirectDiffuseMode(hdCamera) != IndirectDiffuseMode.Off) { needNormalBuffer = true; needDepthBuffer = true; diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingIndirectDiffuse.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingIndirectDiffuse.cs index fd34ac79eb1..e9d5614e5f0 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingIndirectDiffuse.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDRaytracingIndirectDiffuse.cs @@ -15,14 +15,6 @@ void ReleaseRayTracedIndirectDiffuse() { } - bool RayTracedIndirectDiffuseState(HDCamera hdCamera) - { - var settings = hdCamera.volumeStack.GetComponent(); - return ValidIndirectDiffuseState(hdCamera) - && settings.rayTracing.value - && hdCamera.frameSettings.IsEnabled(FrameSettingsField.RayTracing); - } - RTHandle IndirectDiffuseHistoryBufferAllocatorFunction(string viewName, int frameIndex, RTHandleSystem rtHandleSystem) { return rtHandleSystem.Alloc(Vector2.one, TextureXR.slices, colorFormat: GraphicsFormat.R16G16B16A16_SFloat, dimension: TextureXR.dimension, @@ -32,10 +24,6 @@ RTHandle IndirectDiffuseHistoryBufferAllocatorFunction(string viewName, int fram void RenderRayTracedIndirectDiffuse(HDCamera hdCamera, CommandBuffer cmd, ScriptableRenderContext renderContext, int frameCount) { - // If we are not supposed to evaluate the ray traced indirect diffuse term, quit right away - if (!RayTracedIndirectDiffuseState(hdCamera)) - return; - GlobalIllumination giSettings = hdCamera.volumeStack.GetComponent(); // Based on what the asset supports, follow the volume or force the right mode. diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs index 8a73cbd7881..4fa21c32f16 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs @@ -745,7 +745,8 @@ internal static void Sanitize(ref FrameSettings sanitizedFrameSettings, Camera c sanitizedFrameSettings.bitDatas[(int)FrameSettingsField.TransparentSSR] &= renderPipelineSettings.supportSSRTransparent && sanitizedFrameSettings.bitDatas[(int)FrameSettingsField.SSR]; sanitizedFrameSettings.bitDatas[(int)FrameSettingsField.Refraction] &= !preview; sanitizedFrameSettings.bitDatas[(int)FrameSettingsField.SSAO] &= renderPipelineSettings.supportSSAO && !preview; - sanitizedFrameSettings.bitDatas[(int)FrameSettingsField.SSGI] &= renderPipelineSettings.supportSSGI && !preview; + // SSGI is disabled for reflection camera + sanitizedFrameSettings.bitDatas[(int)FrameSettingsField.SSGI] &= renderPipelineSettings.supportSSGI && !preview && !reflection; sanitizedFrameSettings.bitDatas[(int)FrameSettingsField.SubsurfaceScattering] &= renderPipelineSettings.supportSubsurfaceScattering; // We must take care of the scene view fog flags in the editor diff --git a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs index 11c4a407f0e..f6a6201fcdf 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs @@ -240,8 +240,8 @@ unsafe struct ShaderVariablesGlobal public Vector4 _CoarseStencilBufferSize; - public int _UseIndirectDiffuse; // Uniform variables that defines if we should be using the raytraced indirect diffuse - public int _UseRayTracedReflections; + public int _IndirectDiffuseMode; // Match IndirectDiffuseMode enum in LightLoop.cs + public int _EnableRayTracedReflections; public int _RaytracingFrameIndex; // Index of the current frame [0, 7] public uint _EnableRecursiveRayTracing; diff --git a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs.hlsl b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs.hlsl index ebe3ecad8b0..15c4a6b84f3 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs.hlsl @@ -133,8 +133,8 @@ GLOBAL_CBUFFER_START(ShaderVariablesGlobal, b0) uint _XRViewCount; int _FrameCount; float4 _CoarseStencilBufferSize; - int _UseIndirectDiffuse; - int _UseRayTracedReflections; + int _IndirectDiffuseMode; + int _EnableRayTracedReflections; int _RaytracingFrameIndex; uint _EnableRecursiveRayTracing; float4 _ProbeVolumeAtlasResolutionAndSliceCount; From 9c1b65761ce14c1ae8cc0221a24caf30fdfcaaf7 Mon Sep 17 00:00:00 2001 From: sebastienlagarde Date: Wed, 17 Jun 2020 11:15:00 +0200 Subject: [PATCH 02/11] Little extra cleanup --- .../Runtime/RenderPipeline/HDRenderPipeline.cs | 11 ++++++++++- .../Runtime/RenderPipeline/Settings/FrameSettings.cs | 3 +-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs index 9f40df332eb..7a1a6f77ef6 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipeline.cs @@ -5293,7 +5293,16 @@ void SendGeometryGraphicsBuffers(CommandBuffer cmd, HDCamera hdCamera) VFXCameraBufferTypes neededVFXBuffers = VFXManager.IsCameraBufferNeeded(hdCamera.camera); needNormalBuffer |= ((neededVFXBuffers & VFXCameraBufferTypes.Normal) != 0 || (externalAccess & HDAdditionalCameraData.BufferAccessType.Normal) != 0); needDepthBuffer |= ((neededVFXBuffers & VFXCameraBufferTypes.Depth) != 0 || (externalAccess & HDAdditionalCameraData.BufferAccessType.Depth) != 0); - if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.RayTracing) && GetRayTracingState() || GetIndirectDiffuseMode(hdCamera) != IndirectDiffuseMode.Off) + IndirectDiffuseMode indirectDiffuseMode = GetIndirectDiffuseMode(hdCamera); + + // SSGI required the depth of the previous frame + if (indirectDiffuseMode == IndirectDiffuseMode.ScreenSpace) + { + needDepthBuffer = true; + } + + // Raytracing require both normal and depth from previous frame. + if (hdCamera.frameSettings.IsEnabled(FrameSettingsField.RayTracing) && GetRayTracingState()) { needNormalBuffer = true; needDepthBuffer = true; diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs index 4fa21c32f16..8a73cbd7881 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Settings/FrameSettings.cs @@ -745,8 +745,7 @@ internal static void Sanitize(ref FrameSettings sanitizedFrameSettings, Camera c sanitizedFrameSettings.bitDatas[(int)FrameSettingsField.TransparentSSR] &= renderPipelineSettings.supportSSRTransparent && sanitizedFrameSettings.bitDatas[(int)FrameSettingsField.SSR]; sanitizedFrameSettings.bitDatas[(int)FrameSettingsField.Refraction] &= !preview; sanitizedFrameSettings.bitDatas[(int)FrameSettingsField.SSAO] &= renderPipelineSettings.supportSSAO && !preview; - // SSGI is disabled for reflection camera - sanitizedFrameSettings.bitDatas[(int)FrameSettingsField.SSGI] &= renderPipelineSettings.supportSSGI && !preview && !reflection; + sanitizedFrameSettings.bitDatas[(int)FrameSettingsField.SSGI] &= renderPipelineSettings.supportSSGI && !preview; sanitizedFrameSettings.bitDatas[(int)FrameSettingsField.SubsurfaceScattering] &= renderPipelineSettings.supportSubsurfaceScattering; // We must take care of the scene view fog flags in the editor From 60f5c5d64b36401c5f11b596772712df1c2e5e1a Mon Sep 17 00:00:00 2001 From: sebastienlagarde Date: Wed, 17 Jun 2020 14:16:32 +0200 Subject: [PATCH 03/11] Clean area shadow code and remove usless macro --- .../Runtime/ShaderConfig.cs | 1 + .../Runtime/ShaderConfig.cs.hlsl | 1 + .../Runtime/Debug/DebugDisplay.hlsl | 2 +- .../Runtime/Lighting/LightEvaluation.hlsl | 65 +++++++++++++++---- .../Runtime/Lighting/LightLoop/HDShadow.hlsl | 2 +- .../Lighting/LightLoop/HDShadowLoop.hlsl | 2 +- .../Runtime/Lighting/LightLoop/LightLoop.hlsl | 4 +- .../Lighting/LightLoop/LightLoopDef.hlsl | 4 +- .../Runtime/Lighting/SurfaceShading.hlsl | 4 +- .../VolumetricLighting.compute | 6 +- .../Runtime/Material/Eye/Eye.hlsl | 38 +---------- .../Material/LayeredLit/LayeredLit.shader | 1 - .../Runtime/Material/Lit/Lit.hlsl | 53 ++------------- .../Runtime/Material/StackLit/StackLit.hlsl | 45 +------------ .../Shaders/Shadows/RaytracingShadow.compute | 2 +- .../Shaders/Shadows/RaytracingShadow.raytrace | 4 +- .../ShaderLibrary/ShaderVariables.hlsl | 10 ++- 17 files changed, 93 insertions(+), 151 deletions(-) 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 f08a3d2a206..ac8b3435e33 100644 --- a/com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs +++ b/com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs @@ -31,6 +31,7 @@ public enum ProbeVolumesBilateralFilteringModes [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 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 445d13dda83..76dee93d683 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 @@ -35,6 +35,7 @@ // // 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) diff --git a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl index 064a1b0fb3d..f2d3722fb16 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Debug/DebugDisplay.hlsl @@ -13,7 +13,7 @@ // Local shader variables -static DirectionalShadowType g_DebugShadowAttenuation = 0; +static SHADOW_TYPE g_DebugShadowAttenuation = 0; StructuredBuffer _DebugDepthPyramidOffsets; 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 3e93f753279..63d5f6bf80f 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightEvaluation.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightEvaluation.hlsl @@ -237,13 +237,13 @@ float4 EvaluateLight_Directional(LightLoopContext lightLoopContext, PositionInpu return color; } -DirectionalShadowType EvaluateShadow_Directional(LightLoopContext lightLoopContext, PositionInputs posInput, - DirectionalLightData light, BuiltinData builtinData, float3 N) +SHADOW_TYPE EvaluateShadow_Directional( LightLoopContext lightLoopContext, PositionInputs posInput, + DirectionalLightData light, BuiltinData builtinData, float3 N) { #ifndef LIGHT_EVALUATION_NO_SHADOWS - DirectionalShadowType shadow = 1.0; - float shadowMask = 1.0; - float NdotL = dot(N, -light.forward); // Disable contact shadow and shadow mask when facing away from light (i.e transmission) + SHADOW_TYPE shadow = 1.0; + float shadowMask = 1.0; + float NdotL = dot(N, -light.forward); // Disable contact shadow and shadow mask when facing away from light (i.e transmission) #ifdef SHADOWS_SHADOWMASK // shadowMaskSelector.x is -1 if there is no shadow mask @@ -417,14 +417,13 @@ float4 EvaluateLight_Punctual(LightLoopContext lightLoopContext, PositionInputs } // distances = {d, d^2, 1/d, d_proj}, where d_proj = dot(lightToSample, light.forward). -float EvaluateShadow_Punctual(LightLoopContext lightLoopContext, PositionInputs posInput, - LightData light, BuiltinData builtinData, float3 N, float3 L, float4 distances) +SHADOW_TYPE EvaluateShadow_Punctual(LightLoopContext lightLoopContext, PositionInputs posInput, + LightData light, BuiltinData builtinData, float3 N, float3 L, float4 distances) { #ifndef LIGHT_EVALUATION_NO_SHADOWS - 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) - + SHADOW_TYPE 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) #ifdef SHADOWS_SHADOWMASK // shadowMaskSelector.x is -1 if there is no shadow mask @@ -472,6 +471,50 @@ float EvaluateShadow_Punctual(LightLoopContext lightLoopContext, PositionInputs #endif } + +SHADOW_TYPE EvaluateShadow_RectArea( LightLoopContext lightLoopContext, PositionInputs posInput, + LightData light, BuiltinData builtinData, float3 N, float3 L, float dist) +{ +#ifndef LIGHT_EVALUATION_NO_SHADOWS + SHADOW_TYPE 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) + +#ifdef SHADOWS_SHADOWMASK + // shadowMaskSelector.x is -1 if there is no shadow mask + // Note that we override shadow value (in case we don't have any dynamic shadow) + 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 ((light.screenSpaceShadowIndex & SCREEN_SPACE_SHADOW_INDEX_MASK) != INVALID_SCREEN_SPACE_SHADOW) + { + shadow = GetScreenSpaceShadow(posInput, light.screenSpaceShadowIndex); + } + else +#endif + if ((light.shadowIndex >= 0) && (light.shadowDimmer > 0)) + { + // light.positionRWS now contains the Light vector. + shadow = GetRectAreaShadowAttenuation(lightLoopContext.shadowContext, posInput.positionSS, posInput.positionWS, N, light.shadowIndex, L, dist); + +#ifdef SHADOWS_SHADOWMASK + // See comment for punctual light shadow mask + shadow = light.nonLightMappedOnly ? min(shadowMask, shadow) : shadow; +#endif + shadow = lerp(shadowMask, shadow, light.shadowDimmer); + } + +#ifdef DEBUG_DISPLAY + if (_DebugShadowMapMode == SHADOWMAPDEBUGMODE_SINGLE_SHADOW && light.shadowIndex == _DebugSingleShadowIndex) + g_DebugShadowAttenuation = shadow; +#endif + return shadow; +#else // LIGHT_EVALUATION_NO_SHADOWS + return 1.0; +#endif +} + //----------------------------------------------------------------------------- // Reflection probe evaluation helper //----------------------------------------------------------------------------- diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/HDShadow.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/HDShadow.hlsl index 2800a261dfa..a277098a46f 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/HDShadow.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/HDShadow.hlsl @@ -90,7 +90,7 @@ float GetPunctualShadowClosestDistance(HDShadowContext shadowContext, SamplerSta } } -float GetAreaLightAttenuation(HDShadowContext shadowContext, float2 positionSS, float3 positionWS, float3 normalWS, int shadowDataIndex, float3 L, float L_dist) +float GetRectAreaShadowAttenuation(HDShadowContext shadowContext, float2 positionSS, float3 positionWS, float3 normalWS, int shadowDataIndex, float3 L, float L_dist) { #if (defined(PLATFORM_SUPPORTS_WAVE_INTRINSICS) && !defined(LIGHTLOOP_DISABLE_TILE_AND_CLUSTER)) shadowDataIndex = WaveReadLaneFirst(shadowDataIndex); diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/HDShadowLoop.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/HDShadowLoop.hlsl index 6013592f3c0..467bfae44e8 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/HDShadowLoop.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/HDShadowLoop.hlsl @@ -197,7 +197,7 @@ void ShadowLoopMin(HDShadowContext shadowContext, PositionInputs posInput, float if (distances.x < lightData.range && coef > 0.0) { - float shadowA = GetAreaLightAttenuation(shadowContext, posInput.positionSS, posInput.positionWS, normalWS, lightData.shadowIndex, normalize(lightData.positionRWS), length(lightData.positionRWS)); + float shadowA = GetRectAreaShadowAttenuation(shadowContext, posInput.positionSS, posInput.positionWS, normalWS, lightData.shadowIndex, normalize(lightData.positionRWS), length(lightData.positionRWS)); #ifdef SHADOW_LOOP_MULTIPLY shadow *= lerp(lightData.shadowTint, float3(1, 1, 1), shadowA); 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 1ffc924088f..a708eb4fc20 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 @@ -113,7 +113,7 @@ void ApplyDebug(LightLoopContext context, PositionInputs posInput, BSDFData bsdf int shadowSplitIndex = EvalShadow_GetSplitIndex(context.shadowContext, _DirectionalShadowIndex, posInput.positionWS, alpha, cascadeCount); if (shadowSplitIndex >= 0) { - DirectionalShadowType shadow = 1.0; + SHADOW_TYPE shadow = 1.0; if (_DirectionalShadowIndex >= 0) { DirectionalLightData light = _DirectionalLightDatas[_DirectionalShadowIndex]; @@ -193,7 +193,7 @@ void LightLoop( float3 V, PositionInputs posInput, PreLightData preLightData, BS #if defined(SCREEN_SPACE_SHADOWS) && !defined(_SURFACE_TYPE_TRANSPARENT) if ((light.screenSpaceShadowIndex & SCREEN_SPACE_SHADOW_INDEX_MASK) != INVALID_SCREEN_SPACE_SHADOW) { - context.shadowValue = GetScreenSpaceColorShadow(posInput, light.screenSpaceShadowIndex); + context.shadowValue = GetScreenSpaceColorShadow(posInput, light.screenSpaceShadowIndex).SHADOW_TYPE_SWIZZLE; } else #endif 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 bb43e4b44f7..5d9ed86d962 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 @@ -24,8 +24,8 @@ struct LightLoopContext HDShadowContext shadowContext; uint contactShadow; // a bit mask of 24 bits that tell if the pixel is in a contact shadow or not - real contactShadowFade; // combined fade factor of all contact shadows - DirectionalShadowType shadowValue; // Stores the value of the cascade shadow map + real contactShadowFade; // combined fade factor of all contact shadows + SHADOW_TYPE shadowValue; // Stores the value of the cascade shadow map }; // LightLoopOutput is the output of the LightLoop fuction call. diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/SurfaceShading.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Lighting/SurfaceShading.hlsl index dd52a6f9e94..bd1e63138f7 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/SurfaceShading.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/SurfaceShading.hlsl @@ -92,7 +92,7 @@ DirectLighting ShadeSurface_Directional(LightLoopContext lightLoopContext, else #endif { - DirectionalShadowType shadow = EvaluateShadow_Directional(lightLoopContext, posInput, light, builtinData, GetNormalForShadowBias(bsdfData)); + SHADOW_TYPE shadow = EvaluateShadow_Directional(lightLoopContext, posInput, light, builtinData, GetNormalForShadowBias(bsdfData)); float NdotL = dot(bsdfData.normalWS, L); // No microshadowing when facing away from light (use for thin transmission as well) shadow *= NdotL >= 0.0 ? ComputeMicroShadowing(GetAmbientOcclusionForMicroShadowing(bsdfData), NdotL, _MicroShadowOpacity) : 1.0; lightColor.rgb *= ComputeShadowColor(shadow, light.shadowTint, light.penumbraTint); @@ -176,7 +176,7 @@ DirectLighting ShadeSurface_Punctual(LightLoopContext lightLoopContext, #endif { // This code works for both surface reflection and thin object transmission. - float shadow = EvaluateShadow_Punctual(lightLoopContext, posInput, light, builtinData, GetNormalForShadowBias(bsdfData), L, distances); + SHADOW_TYPE shadow = EvaluateShadow_Punctual(lightLoopContext, posInput, light, builtinData, GetNormalForShadowBias(bsdfData), L, distances); lightColor.rgb *= ComputeShadowColor(shadow, light.shadowTint, light.penumbraTint); #ifdef DEBUG_DISPLAY diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumetricLighting.compute b/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumetricLighting.compute index 7c36569d84d..b9be1a26c11 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumetricLighting.compute +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/VolumetricLighting/VolumetricLighting.compute @@ -203,7 +203,7 @@ VoxelLighting EvaluateVoxelLightingDirectional(LightLoopContext context, uint fe #endif // SHADOW_VIEW_BIAS // This code works for both surface reflection and thin object transmission. - DirectionalShadowType shadow = EvaluateShadow_Directional(context, posInput, light, unused, shadowN); + SHADOW_TYPE shadow = EvaluateShadow_Directional(context, posInput, light, unused, shadowN); lightColor.rgb *= ComputeShadowColor(shadow, light.shadowTint, light.penumbraTint); // Important: @@ -322,7 +322,7 @@ VoxelLighting EvaluateVoxelLightingLocal(LightLoopContext context, uint featureF float3 shadowN = 0; // No bias #endif // SHADOW_VIEW_BIAS - float shadow = EvaluateShadow_Punctual(context, posInput, light, unused, shadowN, L, distances); + SHADOW_TYPE shadow = EvaluateShadow_Punctual(context, posInput, light, unused, shadowN, L, distances); lightColor.rgb *= ComputeShadowColor(shadow, light.shadowTint, light.penumbraTint); @@ -407,7 +407,7 @@ VoxelLighting EvaluateVoxelLightingLocal(LightLoopContext context, uint featureF float3 shadowN = 0; // No bias #endif // SHADOW_VIEW_BIAS - float shadow = EvaluateShadow_Punctual(context, posInput, light, unused, shadowN, L, distances); + SHADOW_TYPE shadow = EvaluateShadow_Punctual(context, posInput, light, unused, shadowN, L, distances); lightColor.rgb *= ComputeShadowColor(shadow, light.shadowTint, light.penumbraTint); diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Eye/Eye.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/Eye/Eye.hlsl index 0cf77d6a9c1..8c036dbb548 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/Eye/Eye.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Eye/Eye.hlsl @@ -647,6 +647,9 @@ DirectLighting EvaluateBSDF_Rect( LightLoopContext lightLoopContext, // This value is what we store in specularFGD, so reuse it lighting.specular += preLightData.specularFGD * ltcValue; + SHADOW_TYPE shadow = EvaluateShadow_RectArea(lightLoopContext, posInput, lightData, builtinData, bsdfData.normalWS, normalize(lightData.positionRWS), length(lightData.positionRWS)); + lightData.color.rgb *= ComputeShadowColor(shadow, lightData.shadowTint, lightData.penumbraTint); + // Save ALU by applying 'lightData.color' only once. lighting.diffuse *= lightData.color; lighting.specular *= lightData.color; @@ -664,41 +667,6 @@ DirectLighting EvaluateBSDF_Rect( LightLoopContext lightLoopContext, } - float shadow = 1.0; - float shadowMask = 1.0; -#ifdef SHADOWS_SHADOWMASK - // shadowMaskSelector.x is -1 if there is no shadow mask - // Note that we override shadow value (in case we don't have any dynamic shadow) - shadow = shadowMask = (lightData.shadowMaskSelector.x >= 0.0) ? dot(BUILTIN_DATA_SHADOW_MASK, lightData.shadowMaskSelector) : 1.0; -#endif - - #if defined(SCREEN_SPACE_SHADOWS) && !defined(_SURFACE_TYPE_TRANSPARENT) - if (lightData.screenSpaceShadowIndex >= 0) - { - shadow = GetScreenSpaceShadow(posInput, lightData.screenSpaceShadowIndex); - } - else -#endif // ENABLE_RAYTRACING - if (lightData.shadowIndex != -1) - { -#if RASTERIZED_AREA_LIGHT_SHADOWS - // lightData.positionRWS now contains the Light vector. - shadow = GetAreaLightAttenuation(lightLoopContext.shadowContext, posInput.positionSS, posInput.positionWS, bsdfData.normalWS, lightData.shadowIndex, normalize(lightData.positionRWS), length(lightData.positionRWS)); -#ifdef SHADOWS_SHADOWMASK - // See comment for punctual light shadow mask - shadow = lightData.nonLightMappedOnly ? min(shadowMask, shadow) : shadow; -#endif - shadow = lerp(shadowMask, shadow, lightData.shadowDimmer); - - #endif - } - - #if RASTERIZED_AREA_LIGHT_SHADOWS || SUPPORTS_RAYTRACED_AREA_SHADOWS - float3 shadowColor = ComputeShadowColor(shadow, lightData.shadowTint, lightData.penumbraTint); - lighting.diffuse *= shadowColor; - lighting.specular *= shadowColor; -#endif - return lighting; } 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 62c1c36601e..aaae7ac5a08 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 @@ -1077,7 +1077,6 @@ Shader "HDRP/LayeredLit" #pragma multi_compile _ DIRLIGHTMAP_COMBINED #define SHADERPASS SHADERPASS_PATH_TRACING - #define SKIP_RASTERIZED_SHADOWS // We use the low shadow maps for raytracing #define SHADOW_LOW diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl index 89b05cde86c..1a9d2e4202e 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl @@ -28,12 +28,6 @@ // #define LIT_DISPLAY_REFERENCE_IBL #endif -#ifndef SKIP_RASTERIZED_SHADOWS -#define RASTERIZED_AREA_LIGHT_SHADOWS 1 -#else -#define RASTERIZED_AREA_LIGHT_SHADOWS 0 -#endif - //----------------------------------------------------------------------------- // Texture and constant buffer declaration //----------------------------------------------------------------------------- @@ -80,8 +74,6 @@ TEXTURE2D_X(_ShadowMaskTexture); // Alias for shadow mask, so we don't need to k #define HAS_REFRACTION (defined(_REFRACTION_PLANE) || defined(_REFRACTION_SPHERE) || defined(_REFRACTION_THIN)) -#define SUPPORTS_RAYTRACED_AREA_SHADOWS (RAYTRACING_ENABLED && (SHADERPASS == SHADERPASS_DEFERRED_LIGHTING)) - // It is safe to include this file after the G-Buffer macros above. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/MaterialGBufferMacros.hlsl" @@ -1532,7 +1524,6 @@ DirectLighting EvaluateBSDF_Rect( LightLoopContext lightLoopContext, if (dot(lightData.forward, unL) < FLT_EPS) { - // Rotate the light direction into the light space. float3x3 lightToWorld = float3x3(lightData.right, lightData.up, -lightData.forward); unL = mul(unL, transpose(lightToWorld)); @@ -1671,6 +1662,13 @@ DirectLighting EvaluateBSDF_Rect( LightLoopContext lightLoopContext, lighting.specular += preLightData.coatIblF * ltcValue; } + // Raytracing shadow algorithm require to evaluate lighting without shadow, so it defined SKIP_AREA_RASTERIZED_SHADOWS + // This is only present in Lit Material as it is the only one using the improved shadow algorithm. + #ifndef SKIP_AREA_RASTERIZED_SHADOWS + SHADOW_TYPE shadow = EvaluateShadow_RectArea(lightLoopContext, posInput, lightData, builtinData, bsdfData.normalWS, normalize(lightData.positionRWS), length(lightData.positionRWS)); + lightData.color.rgb *= ComputeShadowColor(shadow, lightData.shadowTint, lightData.penumbraTint); + #endif + // Save ALU by applying 'lightData.color' only once. lighting.diffuse *= lightData.color; lighting.specular *= lightData.color; @@ -1685,45 +1683,8 @@ DirectLighting EvaluateBSDF_Rect( LightLoopContext lightLoopContext, } #endif } - - } - - float shadow = 1.0; - float shadowMask = 1.0; -#ifdef SHADOWS_SHADOWMASK - // shadowMaskSelector.x is -1 if there is no shadow mask - // Note that we override shadow value (in case we don't have any dynamic shadow) - shadow = shadowMask = (lightData.shadowMaskSelector.x >= 0.0) ? dot(BUILTIN_DATA_SHADOW_MASK, lightData.shadowMaskSelector) : 1.0; -#endif - -#if defined(SCREEN_SPACE_SHADOWS) && !defined(_SURFACE_TYPE_TRANSPARENT) - if ((lightData.screenSpaceShadowIndex & SCREEN_SPACE_SHADOW_INDEX_MASK) != INVALID_SCREEN_SPACE_SHADOW) - { - shadow = GetScreenSpaceShadow(posInput, lightData.screenSpaceShadowIndex); - } - else -#endif // ENABLE_RAYTRACING - if (lightData.shadowIndex != -1) - { -#if RASTERIZED_AREA_LIGHT_SHADOWS - // lightData.positionRWS now contains the Light vector. - shadow = GetAreaLightAttenuation(lightLoopContext.shadowContext, posInput.positionSS, posInput.positionWS, bsdfData.normalWS, lightData.shadowIndex, normalize(lightData.positionRWS), length(lightData.positionRWS)); -#ifdef SHADOWS_SHADOWMASK - // See comment for punctual light shadow mask - shadow = lightData.nonLightMappedOnly ? min(shadowMask, shadow) : shadow; -#endif - shadow = lerp(shadowMask, shadow, lightData.shadowDimmer); - -#endif } -#if RASTERIZED_AREA_LIGHT_SHADOWS || SUPPORTS_RAYTRACED_AREA_SHADOWS - float3 shadowColor = ComputeShadowColor(shadow, lightData.shadowTint, lightData.penumbraTint); - lighting.diffuse *= shadowColor; - lighting.specular *= shadowColor; -#endif - - #endif // LIT_DISPLAY_REFERENCE_AREA return lighting; diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/StackLit/StackLit.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/StackLit/StackLit.hlsl index 07e07bb258d..ed41218715a 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/StackLit/StackLit.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/StackLit/StackLit.hlsl @@ -31,12 +31,6 @@ // #define STACK_LIT_DISPLAY_REFERENCE_IBL #endif -#ifndef SKIP_RASTERIZED_SHADOWS -#define RASTERIZED_AREA_LIGHT_SHADOWS 1 -#else -#define RASTERIZED_AREA_LIGHT_SHADOWS 0 -#endif - //----------------------------------------------------------------------------- // Texture and constant buffer declaration //----------------------------------------------------------------------------- @@ -4111,7 +4105,9 @@ DirectLighting EvaluateBSDF_Rect( LightLoopContext lightLoopContext, } } lighting.specular *= lightData.specularDimmer; - + + SHADOW_TYPE shadow = EvaluateShadow_RectArea(lightLoopContext, posInput, lightData, builtinData, bsdfData.normalWS, normalize(lightData.positionRWS), length(lightData.positionRWS)); + lightData.color.rgb *= ComputeShadowColor(shadow, lightData.shadowTint, lightData.penumbraTint); // Save ALU by applying 'lightData.color' only once. lighting.diffuse *= lightData.color; @@ -4140,41 +4136,6 @@ DirectLighting EvaluateBSDF_Rect( LightLoopContext lightLoopContext, } // if light not back-facing - float shadow = 1.0; - float shadowMask = 1.0; -#ifdef SHADOWS_SHADOWMASK - // shadowMaskSelector.x is -1 if there is no shadow mask - // Note that we override shadow value (in case we don't have any dynamic shadow) - shadow = shadowMask = (lightData.shadowMaskSelector.x >= 0.0) ? dot(BUILTIN_DATA_SHADOW_MASK, lightData.shadowMaskSelector) : 1.0; -#endif - -#if defined(SCREEN_SPACE_SHADOWS) && !defined(_SURFACE_TYPE_TRANSPARENT) - if ((lightData.screenSpaceShadowIndex & SCREEN_SPACE_SHADOW_INDEX_MASK) != INVALID_SCREEN_SPACE_SHADOW) - { - shadow = GetScreenSpaceShadow(posInput, lightData.screenSpaceShadowIndex); - } - else -#endif // ENABLE_RAYTRACING - if (lightData.shadowIndex != -1) - { -#if RASTERIZED_AREA_LIGHT_SHADOWS - // lightData.positionRWS now contains the Light vector. - shadow = GetAreaLightAttenuation(lightLoopContext.shadowContext, posInput.positionSS, posInput.positionWS, bsdfData.normalWS, lightData.shadowIndex, normalize(lightData.positionRWS), length(lightData.positionRWS)); -#ifdef SHADOWS_SHADOWMASK - // See comment for punctual light shadow mask - shadow = lightData.nonLightMappedOnly ? min(shadowMask, shadow) : shadow; -#endif - shadow = lerp(shadowMask, shadow, lightData.shadowDimmer); - -#endif - } - -#if RASTERIZED_AREA_LIGHT_SHADOWS || SUPPORTS_RAYTRACED_AREA_SHADOWS - float3 shadowColor = ComputeShadowColor(shadow, lightData.shadowTint, lightData.penumbraTint); - lighting.diffuse *= shadowColor; - lighting.specular *= shadowColor; -#endif - #endif // STACK_LIT_DISPLAY_REFERENCE_AREA return lighting; diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Shadows/RaytracingShadow.compute b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Shadows/RaytracingShadow.compute index 65f45e2f235..c8e67f8ed1e 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Shadows/RaytracingShadow.compute +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Shadows/RaytracingShadow.compute @@ -11,7 +11,7 @@ #define HAS_LIGHTLOOP // Given that the algorithm requires BSDF evaluation, we need to define this macro -#define SKIP_RASTERIZED_SHADOWS +#define SKIP_AREA_RASTERIZED_SHADOWS // Given that this pass does not use the shadow algorithm multi-compile, we need to define SHADOW_LOW to quite the shadow algorithm error #define SHADOW_LOW diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Shadows/RaytracingShadow.raytrace b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Shadows/RaytracingShadow.raytrace index fea469a6773..f6b00e3940a 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Shadows/RaytracingShadow.raytrace +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Shadows/RaytracingShadow.raytrace @@ -8,7 +8,7 @@ #define HAS_LIGHTLOOP // Given that the algorithm requires BSDF evaluation, we need to define this macro -#define SKIP_RASTERIZED_SHADOWS +#define SKIP_AREA_RASTERIZED_SHADOWS // Given that this pass does not use the shadow algorithm multi-compile, we need to define SHADOW_LOW to quite the shadow algorithm error #define SHADOW_LOW @@ -63,6 +63,8 @@ void MissShaderShadowsColor(inout RayIntersection rayIntersection : SV_RayPayloa // Does nothing intentionally } +// This code below is the "high quality shadow" but it is not used currently. We use the compute version which is more efficient +// and which do a good enough approximation. [shader("raygeneration")] void RayGenAreaShadows() { 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 373797bb73d..ca0ec010edf 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl @@ -29,10 +29,16 @@ // 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) -#define DirectionalShadowType float3 #else #define RAYTRACING_ENABLED (0) -#define DirectionalShadowType float +#endif + +#if SHADEROPTIONS_COLORED_SHADOW +#define SHADOW_TYPE real3 +#define SHADOW_TYPE_SWIZZLE xyz +#else +#define SHADOW_TYPE real +#define SHADOW_TYPE_SWIZZLE x #endif #if defined(SHADER_STAGE_RAY_TRACING) From 0b50b338a698d5c6f44fc56778af9c0cada03fba Mon Sep 17 00:00:00 2001 From: sebastienlagarde Date: Wed, 17 Jun 2020 14:35:00 +0200 Subject: [PATCH 04/11] update shader config files for projects --- .../Runtime/ShaderConfig.cs | 1 + .../Runtime/ShaderConfig.cs.hlsl | 1 + .../Runtime/ShaderConfig.cs.hlsl | 8 -------- 3 files changed, 2 insertions(+), 8 deletions(-) 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 index f08a3d2a206..ac8b3435e33 100644 --- 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 @@ -31,6 +31,7 @@ public enum ProbeVolumesBilateralFilteringModes [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 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 index 6b354cd380c..b21ea94c319 100644 --- 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 @@ -28,6 +28,7 @@ // // 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) 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 76dee93d683..efc6d322dac 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 @@ -4,13 +4,6 @@ #ifndef SHADERCONFIG_CS_HLSL #define SHADERCONFIG_CS_HLSL -// -// UnityEngine.Rendering.HighDefinition.HDShadowFilteringQuality: static fields -// -#define HDSHADOWFILTERINGQUALITY_LOW (0) -#define HDSHADOWFILTERINGQUALITY_MEDIUM (1) -#define HDSHADOWFILTERINGQUALITY_HIGH (2) - // // UnityEngine.Rendering.HighDefinition.ProbeVolumesEvaluationModes: static fields // @@ -46,7 +39,6 @@ #define SHADEROPTIONS_PROBE_VOLUMES_BILATERAL_FILTERING_MODE (1) #define SHADEROPTIONS_PROBE_VOLUMES_ENCODING_MODE (1) #define SHADEROPTIONS_AREA_LIGHTS (1) -#define SHADEROPTIONS_DEFERRED_SHADOW_FILTERING (1) #define SHADEROPTIONS_BARN_DOOR (0) From 29b9a121563b57e518f95bbf8102631d2a690f55 Mon Sep 17 00:00:00 2001 From: sebastienlagarde Date: Wed, 17 Jun 2020 14:38:18 +0200 Subject: [PATCH 05/11] Better naming for SKIP_RASTERIZED_AREA_SHADOWS --- .../Runtime/Material/Lit/Lit.hlsl | 4 ++-- .../Raytracing/Shaders/Shadows/RaytracingShadow.compute | 2 +- .../Raytracing/Shaders/Shadows/RaytracingShadow.raytrace | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl index 1a9d2e4202e..f944e94b1be 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl @@ -1662,9 +1662,9 @@ DirectLighting EvaluateBSDF_Rect( LightLoopContext lightLoopContext, lighting.specular += preLightData.coatIblF * ltcValue; } - // Raytracing shadow algorithm require to evaluate lighting without shadow, so it defined SKIP_AREA_RASTERIZED_SHADOWS + // Raytracing shadow algorithm require to evaluate lighting without shadow, so it defined SKIP_RASTERIZED_AREA_SHADOWS // This is only present in Lit Material as it is the only one using the improved shadow algorithm. - #ifndef SKIP_AREA_RASTERIZED_SHADOWS + #ifndef SKIP_RASTERIZED_AREA_SHADOWS SHADOW_TYPE shadow = EvaluateShadow_RectArea(lightLoopContext, posInput, lightData, builtinData, bsdfData.normalWS, normalize(lightData.positionRWS), length(lightData.positionRWS)); lightData.color.rgb *= ComputeShadowColor(shadow, lightData.shadowTint, lightData.penumbraTint); #endif diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Shadows/RaytracingShadow.compute b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Shadows/RaytracingShadow.compute index c8e67f8ed1e..d7b340f136d 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Shadows/RaytracingShadow.compute +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Shadows/RaytracingShadow.compute @@ -11,7 +11,7 @@ #define HAS_LIGHTLOOP // Given that the algorithm requires BSDF evaluation, we need to define this macro -#define SKIP_AREA_RASTERIZED_SHADOWS +#define SKIP_RASTERIZED_AREA_SHADOWS // Given that this pass does not use the shadow algorithm multi-compile, we need to define SHADOW_LOW to quite the shadow algorithm error #define SHADOW_LOW diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Shadows/RaytracingShadow.raytrace b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Shadows/RaytracingShadow.raytrace index f6b00e3940a..ee2b27af396 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Shadows/RaytracingShadow.raytrace +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Shadows/RaytracingShadow.raytrace @@ -8,7 +8,7 @@ #define HAS_LIGHTLOOP // Given that the algorithm requires BSDF evaluation, we need to define this macro -#define SKIP_AREA_RASTERIZED_SHADOWS +#define SKIP_RASTERIZED_AREA_SHADOWS // Given that this pass does not use the shadow algorithm multi-compile, we need to define SHADOW_LOW to quite the shadow algorithm error #define SHADOW_LOW From 3bc4d52d84e52b9ff2c59de0e7c8ca17ddb616bc Mon Sep 17 00:00:00 2001 From: sebastienlagarde Date: Wed, 17 Jun 2020 14:47:03 +0200 Subject: [PATCH 06/11] Update Upgrading-from-2020.1-to-2020.2.md --- .../Documentation~/Upgrading-from-2020.1-to-2020.2.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2020.1-to-2020.2.md b/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2020.1-to-2020.2.md index 54f5a4e40be..86cc8613c78 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2020.1-to-2020.2.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Upgrading-from-2020.1-to-2020.2.md @@ -41,6 +41,7 @@ The shader function `SampleShadow_PCSS` now requires you to pass in an additiona From Unity 2020.2, due to the change of shadow map, the enum HDShadowFilteringQuality have been moved to HDShadowManager.cs and the variables ShaderConfig.s_DeferredShadowFiltering as well as the option ShaderOptions.DeferredShadowFiltering have been removed from the code as they have no impact anymore. +From Unity 2020.2, a new option is available name ColoredShadow. It allow to control if the shadow will be chromatic or monochrome. ColoredShadow have a performance cost. ColoredShadow are the default and currently only work with Raytrace shadow. ## Shader code @@ -72,6 +73,9 @@ BSDFData bsdfData = ConvertSurfaceDataToBSDFData(posInput.positionSS, surfaceDat PreLightData preLightData = GetPreLightData(V, posInput, bsdfData); ``` + +From Unity 2020.2, a new rectangular area shadow have been introduce EvaluateShadow_RectArea and the function GetAreaLightAttenuation() have been rename to GetRectAreaShadowAttenuation(). Also the type DirectionalShadowType have been renamed SHADOW_TYPE. + ## Custom pass API The signature of the Execute function has changed to simplify the parameters, now it only takes a CustomPassContext as its input: From 547f9a492b21cf0e3a4024c230eac5d9a44ffb74 Mon Sep 17 00:00:00 2001 From: sebastienlagarde Date: Wed, 17 Jun 2020 15:41:22 +0200 Subject: [PATCH 07/11] remove useless comment --- .../Runtime/Lighting/LightEvaluation.hlsl | 1 - 1 file changed, 1 deletion(-) 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 63d5f6bf80f..c3497fd9162 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightEvaluation.hlsl +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightEvaluation.hlsl @@ -495,7 +495,6 @@ SHADOW_TYPE EvaluateShadow_RectArea( LightLoopContext lightLoopContext, Position #endif if ((light.shadowIndex >= 0) && (light.shadowDimmer > 0)) { - // light.positionRWS now contains the Light vector. shadow = GetRectAreaShadowAttenuation(lightLoopContext.shadowContext, posInput.positionSS, posInput.positionWS, N, light.shadowIndex, L, dist); #ifdef SHADOWS_SHADOWMASK From 133d9fcda0514a00b5111557d80ae9268ff734ad Mon Sep 17 00:00:00 2001 From: sebastienlagarde Date: Wed, 17 Jun 2020 18:15:05 +0200 Subject: [PATCH 08/11] cleanup have deferred rendering --- .../ShaderPass/ShaderPassDepthOnly.hlsl | 17 ++++- .../ShaderPass/ShaderPassForward.hlsl | 16 ++++- .../ShaderPass/ShaderPassGBuffer.hlsl | 17 ++++- .../RenderPipeline/ShaderPass/VertMesh.hlsl | 63 +++++++------------ 4 files changed, 69 insertions(+), 44 deletions(-) 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; From d39f7c191455932d1876b947eb7c081e23f23c83 Mon Sep 17 00:00:00 2001 From: sebastienlagarde Date: Thu, 18 Jun 2020 00:24:16 +0200 Subject: [PATCH 09/11] Clean RaytracingIndirectDiffuse.compute code --- .../Runtime/Lighting/LightLoop/LightLoop.hlsl | 2 +- .../Shaders/IndirectDiffuse/RaytracingIndirectDiffuse.compute | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) 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..a8ea53446f8 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 @@ -121,7 +121,7 @@ void ApplyDebug(LightLoopContext context, PositionInputs posInput, BSDFData bsdf #if defined(SCREEN_SPACE_SHADOWS) && !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 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 } From 6a43e17fe29f959ecea78e8b1cce4b864d21cbc6 Mon Sep 17 00:00:00 2001 From: sebastienlagarde Date: Thu, 18 Jun 2020 01:56:08 +0200 Subject: [PATCH 10/11] Move screen space shadow to a multicompile + remove Raytracing macro --- .../Runtime/ShaderConfig.cs | 6 +-- .../Runtime/ShaderConfig.cs.hlsl | 1 - .../BuildProcessors/HDRPPreprocessShaders.cs | 48 +++++++++++++------ .../DefaultScene/HDWizard.Configuration.cs | 37 -------------- .../Editor/DefaultScene/HDWizard.Window.cs | 3 -- .../Editor/Material/BaseShaderPreprocessor.cs | 6 +++ .../Editor/Material/ShaderGraph/HDTarget.cs | 15 ++++++ .../Runtime/Lighting/Deferred.shader | 1 + .../Runtime/Lighting/LightEvaluation.hlsl | 8 ++-- .../Lighting/LightLoop/Deferred.compute | 1 + .../Lighting/LightLoop/DeferredTile.shader | 1 + .../Runtime/Lighting/LightLoop/LightLoop.cs | 17 +++++++ .../Runtime/Lighting/LightLoop/LightLoop.hlsl | 4 +- .../Lighting/LightLoop/LightLoopDef.hlsl | 6 --- .../Runtime/Material/AxF/AxF.shader | 1 + .../Material/LayeredLit/LayeredLit.shader | 1 + .../LayeredLit/LayeredLitTessellation.shader | 1 + .../Runtime/Material/Lit/Lit.shader | 2 + .../Material/Lit/LitTessellation.shader | 2 + .../Material/TerrainLit/TerrainLit.shader | 1 + .../TerrainLit/TerrainLit_Basemap.shader | 1 + .../ShaderLibrary/ShaderVariables.hlsl | 8 +--- 22 files changed, 92 insertions(+), 79 deletions(-) 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 a8ea53446f8..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,7 +118,7 @@ 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_TYPE_SWIZZLE; @@ -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/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 From e424ce8b99624ff081cd123aaa401b29b026d2b7 Mon Sep 17 00:00:00 2001 From: sebastienlagarde Date: Thu, 18 Jun 2020 01:56:43 +0200 Subject: [PATCH 11/11] Remove config package from DXR Test --- .../Runtime.meta | 8 -- .../Runtime/ShaderConfig.cs | 85 ------------------- .../Runtime/ShaderConfig.cs.hlsl | 45 ---------- .../Runtime/ShaderConfig.cs.hlsl.meta | 9 -- .../Runtime/ShaderConfig.cs.meta | 12 --- ...lines.HighDefinition.Config.Runtime.asmdef | 14 --- ....HighDefinition.Config.Runtime.asmdef.meta | 7 -- .../package.json | 11 --- .../package.json.meta | 7 -- .../HDRP_DXR_Tests/Packages/manifest.json | 2 +- 10 files changed, 1 insertion(+), 199 deletions(-) delete mode 100644 TestProjects/HDRP_DXR_Tests/LocalPackages/com.unity.render-pipelines.high-definition-config/Runtime.meta delete mode 100644 TestProjects/HDRP_DXR_Tests/LocalPackages/com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs delete mode 100644 TestProjects/HDRP_DXR_Tests/LocalPackages/com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs.hlsl delete mode 100644 TestProjects/HDRP_DXR_Tests/LocalPackages/com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs.hlsl.meta delete mode 100644 TestProjects/HDRP_DXR_Tests/LocalPackages/com.unity.render-pipelines.high-definition-config/Runtime/ShaderConfig.cs.meta delete mode 100644 TestProjects/HDRP_DXR_Tests/LocalPackages/com.unity.render-pipelines.high-definition-config/Runtime/Unity.RenderPipelines.HighDefinition.Config.Runtime.asmdef delete mode 100644 TestProjects/HDRP_DXR_Tests/LocalPackages/com.unity.render-pipelines.high-definition-config/Runtime/Unity.RenderPipelines.HighDefinition.Config.Runtime.asmdef.meta delete mode 100644 TestProjects/HDRP_DXR_Tests/LocalPackages/com.unity.render-pipelines.high-definition-config/package.json delete mode 100644 TestProjects/HDRP_DXR_Tests/LocalPackages/com.unity.render-pipelines.high-definition-config/package.json.meta 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",