From b9b92274469f720269b869792167ba685270d5f1 Mon Sep 17 00:00:00 2001 From: Anis Date: Thu, 24 Sep 2020 14:06:36 +0200 Subject: [PATCH] Added a new volume component parameter to control the max ray length of directional lights(case 1279849). Removed the max clamp value for the RTR, RTAO and RTGI's ray length (case 1279849). --- com.unity.render-pipelines.high-definition/CHANGELOG.md | 2 ++ .../Documentation~/Ray-Traced-Ambient-Occlusion.md | 2 +- .../Documentation~/Ray-Traced-Global-Illumination.md | 2 +- .../Documentation~/Ray-Traced-Reflections.md | 2 +- .../Documentation~/Ray-Tracing-Settings.md | 1 + .../Editor/Lighting/AmbientOcclusionEditor.cs | 2 +- .../Lighting/Reflection/HDScreenSpaceReflectionEditor.cs | 2 +- .../Raytracing/GlobalIlluminationEditor.cs | 9 +++++---- .../Raytracing/RayTracingSettingsEditor.cs | 3 +++ .../Runtime/Lighting/GlobalIllumination.cs | 3 +-- .../Lighting/ScreenSpaceLighting/AmbientOcclusion.cs | 2 +- .../ScreenSpaceLighting/ScreenSpaceReflection.cs | 3 +-- .../Runtime/Lighting/Shadow/ScreenSpaceShadowManager.cs | 1 - .../Shadow/ScreenSpaceShadowManagerDirectional.cs | 6 ++++++ .../Runtime/RenderPipeline/HDStringConstants.cs | 1 + .../RenderPipeline/Raytracing/RayTracingSettings.cs | 6 ++++++ .../Raytracing/Shaders/Shadows/RaytracingShadow.raytrace | 8 ++++---- 17 files changed, 36 insertions(+), 19 deletions(-) diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 518105d4800..896b9122c68 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Added an optional check in the HDRP DXR Wizard to verify 64 bits target architecture - Added option to display timing stats in the debug menu as an average over 1 second. - Added a light unit slider to provide users more context when authoring physically based values. +- Added a new volume component parameter to control the max ray length of directional lights(case 1279849). ### Fixed - Fixed several issues with physically-based DoF (TAA ghosting of the CoC buffer, smooth layer transitions, etc) @@ -106,6 +107,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Replaced the Density Volume Texture Tool with the new 3D Texture Importer. - Rename Raytracing Node to Raytracing Quality Keyword and rename high and low inputs as default and raytraced. All raytracing effects now use the raytraced mode but path tracing. - Moved diffusion profile list to the HDRP default settings panel. +- Removed the max clamp value for the RTR, RTAO and RTGI's ray length (case 1279849). ## [10.0.0] - 2019-06-10 diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Ray-Traced-Ambient-Occlusion.md b/com.unity.render-pipelines.high-definition/Documentation~/Ray-Traced-Ambient-Occlusion.md index 105afe19a9f..45c4ac3958f 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Ray-Traced-Ambient-Occlusion.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Ray-Traced-Ambient-Occlusion.md @@ -62,7 +62,7 @@ Ray-Traced Ambient Occlusion uses the [Volume](Volumes.md) framework, so to enab | **Direct Lighting Strength** | Controls how much the ambient occlusion affects direct lighting. | | **LayerMask** | Defines the layers that HDRP processes this ray-traced effect for. | | **Quality** | Specifies the preset HDRP uses to populate the values of the following nested properties. The options are:
• **Low**: A preset that emphasizes performance over quality.
• **Medium**: A preset that balances performance and quality.
• **High**: A preset that emphasizes quality over performance.
• **Custom**: Allows you to override each property individually. | -| - **Ray Length** | Controls the length of the rays that HDRP uses for ray tracing. This allows you to have smaller scale, local, ambient occlusion. | +| - **Max Ray Length** | Controls the maximal ray length of the rays that HDRP uses for ray traced ambient occlusion. This allows you to have smaller scale, local, ambient occlusion. | | - **Sample Count** | Controls the number of rays that HDRP uses per pixel, per frame. Increasing this value increases execution time linearly. | | - **Denoise** | Enables the spatio-temporal filter that HDRP uses to remove noise from the ambient occlusion. | | - - **Denoiser Radius** | Controls the radius of the spatio-temporal filter. A higher value reduces noise further. | diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Ray-Traced-Global-Illumination.md b/com.unity.render-pipelines.high-definition/Documentation~/Ray-Traced-Global-Illumination.md index 5ad3e4dad4a..9ad0873edb9 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Ray-Traced-Global-Illumination.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Ray-Traced-Global-Illumination.md @@ -49,7 +49,7 @@ Alongside the standard properties, Unity makes different properties available de | **LayerMask** | Defines the layers that HDRP processes this ray-traced effect for. | | **Mode** | Defines if HDRP should evaluate the effect in **Performance** or **Quality** mode.
This property only appears if you select set **Supported Ray Tracing Mode** in your HDRP Asset to **Both**. | | **Quality** | Specifies the preset HDRP uses to populate the values of the following nested properties. The options are:
• **Low**: A preset that emphasizes performance over quality.
• **Medium**: A preset that balances performance and quality.
• **High**: A preset that emphasizes quality over performance.
• **Custom**: Allows you to override each property individually.
This property only appears in [Performance](Ray-Tracing-Getting-Started.md#ray-tracing-mode) mode. | -| **Ray Length** | Set a value to control the length of the rays that HDRP uses for ray tracing. If a ray doesn't find an intersection, then the ray returns the color of the sky. | +| **Max Ray Length** | Controls the maximal length of reflection rays. The higher this value is, the more expensive ray traced reflections are. If a ray doesn't find an intersection, then the ray returns the color of the sky if Reflect Sky is enabled, or black if not. | | **Clamp Value** | Set a value to control the threshold that HDRP uses to clamp the pre-exposed value. This reduces the range of values and makes the global illumination more stable to denoise, but reduces quality. | | **Denoise** | Enable this to enable the spatio-temporal filter that HDRP uses to remove noise from the Ray-Traced Global Illumination. | | - **Half Resolution Denoiser** | Enable this feature to evaluate the spatio-temporal filter in half resolution. This decreases the resource intensity of denoising but reduces quality. | diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Ray-Traced-Reflections.md b/com.unity.render-pipelines.high-definition/Documentation~/Ray-Traced-Reflections.md index 089e91e5a81..9725cbc7d21 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Ray-Traced-Reflections.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Ray-Traced-Reflections.md @@ -66,7 +66,7 @@ Alongside the standard properties, Unity exposes extra properties depending on t | **Quality** | Specifies the preset HDRP uses to populate the values of the following nested properties. The options are:
• **Low**: A preset that emphasizes performance over quality.
• **Medium**: A preset that balances performance and quality.
• **High**: A preset that emphasizes quality over performance.
• **Custom**: Allows you to override each property individually.
This property only appears in [Performance](Ray-Tracing-Getting-Started.md#ray-tracing-mode) mode. | | **Minimum Smoothness** | Controls the minimum smoothness value for a pixel at which HDRP processes ray-traced reflections. If the smoothness value of the pixel is lower than this value, HDRP falls back to the next available reflection method in the [reflection hierarchy](Reflection-in-HDRP.md#ReflectionHierarchy). | | **Smoothness Fade Start** | Controls the smoothness value at which the smoothness controlled fade out starts. The fade is in the range [Minimum Smoothness, Smoothness Fade Start]. | -| **Ray Length** | Controls the length of the rays that HDRP uses for ray tracing. If a ray doesn't find an intersection, then the ray returns the color of the sky if Reflect Sky is enabled, or black if not. | +| **Max Ray Length** | Controls the maximal length of global illumination rays. The higher this value is, the more expensive ray traced global illumination is. If a ray doesn't find an intersection. | | **Clamp Value** | Controls the threshold that HDRP uses to clamp the pre-exposed value. This reduces the range of values and makes the reflections more stable to denoise, but reduces quality. | | **Denoise** | Enables the spatio-temporal filter that HDRP uses to remove noise from the reflections. | | - **Denoiser Radius** | Controls the radius of the spatio-temporal filter. Increasing this value results in a more blurry result and a higher execution time. | diff --git a/com.unity.render-pipelines.high-definition/Documentation~/Ray-Tracing-Settings.md b/com.unity.render-pipelines.high-definition/Documentation~/Ray-Tracing-Settings.md index f0007113233..32bab15a3c8 100644 --- a/com.unity.render-pipelines.high-definition/Documentation~/Ray-Tracing-Settings.md +++ b/com.unity.render-pipelines.high-definition/Documentation~/Ray-Tracing-Settings.md @@ -14,3 +14,4 @@ In the High Definition Render Pipeline (HDRP), various ray-traced effects share | **Ray Bias** | Specifies the bias value HDRP applies when casting rays for all effects. This value should remain unchained unless your scene scale is significantly smaller or larger than average. | | **Extend Shadow Culling** | Extends the sets of GameObjects that HDRP includes in shadow maps for more accurate shadows in ray traced effects. | | **Extend Camera Culling** | Extends the sets of GameObjects that HDRP includes in the rendering. This is a way to force skinned mesh animations for GameObjects that are not in the frustum. | +| **Directional Shadow Ray Length** | Controls the maximal ray length for ray traced directional shadows. | \ No newline at end of file diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/AmbientOcclusionEditor.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/AmbientOcclusionEditor.cs index 5946c569edc..06baaa9ff18 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Lighting/AmbientOcclusionEditor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/AmbientOcclusionEditor.cs @@ -87,7 +87,7 @@ public override void OnInspectorGUI() GUI.enabled = useCustomValue; { EditorGUI.indentLevel++; - PropertyField(m_RayLength, EditorGUIUtility.TrTextContent("Ray Length", "Controls the length of ambient occlusion rays.")); + PropertyField(m_RayLength, EditorGUIUtility.TrTextContent("Max Ray Length", "Controls the maximal length of ambient occlusion rays. The higher this value is, the more expensive ray traced ambient occlusion is.")); PropertyField(m_SampleCount, EditorGUIUtility.TrTextContent("Sample Count", "Number of samples for ray traced ambient occlusion.")); PropertyField(m_Denoise, EditorGUIUtility.TrTextContent("Denoise", "Enable denoising on the ray traced ambient occlusion.")); { diff --git a/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDScreenSpaceReflectionEditor.cs b/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDScreenSpaceReflectionEditor.cs index 1a1d9457be6..4b105c7e9cd 100644 --- a/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDScreenSpaceReflectionEditor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDScreenSpaceReflectionEditor.cs @@ -80,7 +80,7 @@ public override void OnEnable() static public readonly GUIContent k_ScreenFaceDistanceText = EditorGUIUtility.TrTextContent("Screen Edge Fade Distance", "Controls the distance at which HDRP fades out SSR near the edge of the screen."); static public readonly GUIContent k_DepthBufferThicknessText = EditorGUIUtility.TrTextContent("Object Thickness", "Controls the typical thickness of objects the reflection rays may pass behind."); static public readonly GUIContent k_RayMaxIterationsText = EditorGUIUtility.TrTextContent("Max Ray Steps", "Sets the maximum number of steps HDRP uses for raytracing. Affects both correctness and performance."); - static public readonly GUIContent k_RayLengthText = EditorGUIUtility.TrTextContent("Ray Length", "Controls the length of reflection rays."); + static public readonly GUIContent k_RayLengthText = EditorGUIUtility.TrTextContent("Max Ray Length", "Controls the maximal length of reflection rays. The higher this value is, the more expensive ray traced reflections are."); static public readonly GUIContent k_ClampValueText = EditorGUIUtility.TrTextContent("Clamp Value", "Clamps the exposed intensity."); static public readonly GUIContent k_SampleCountText = EditorGUIUtility.TrTextContent("Sample Count", "Number of samples for reflections."); static public readonly GUIContent k_BounceCountText = EditorGUIUtility.TrTextContent("Bounce Count", "Number of bounces for reflection rays."); diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/GlobalIlluminationEditor.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/GlobalIlluminationEditor.cs index 6983bba265d..5b7e96b6b23 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/GlobalIlluminationEditor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/GlobalIlluminationEditor.cs @@ -75,6 +75,7 @@ public override void OnEnable() m_SecondDenoiserPass = Unpack(o.Find(x => x.secondDenoiserPass)); } + static public readonly GUIContent k_RayLengthText = EditorGUIUtility.TrTextContent("Max Ray Length", "Controls the maximal length of global illumination rays. The higher this value is, the more expensive ray traced global illumination is."); static public readonly GUIContent k_DepthBufferThicknessText = EditorGUIUtility.TrTextContent("Object Thickness", "Controls the typical thickness of objects the global illumination rays may pass behind."); public void DenoiserGUI() @@ -129,7 +130,7 @@ public override void OnInspectorGUI() base.OnInspectorGUI(); // Quality Setting EditorGUI.indentLevel++; GUI.enabled = useCustomValue; - PropertyField(m_RayLength); + PropertyField(m_RayLength, k_RayLengthText); PropertyField(m_ClampValue); PropertyField(m_FullResolution); PropertyField(m_UpscaleRadius); @@ -141,7 +142,7 @@ public override void OnInspectorGUI() break; case RayTracingMode.Quality: { - PropertyField(m_RayLength); + PropertyField(m_RayLength, k_RayLengthText); PropertyField(m_ClampValue); PropertyField(m_SampleCount); PropertyField(m_BounceCount); @@ -153,7 +154,7 @@ public override void OnInspectorGUI() } else if (currentAsset.currentPlatformRenderPipelineSettings.supportedRayTracingMode == RenderPipelineSettings.SupportedRayTracingMode.Quality) { - PropertyField(m_RayLength); + PropertyField(m_RayLength, k_RayLengthText); PropertyField(m_ClampValue); PropertyField(m_SampleCount); PropertyField(m_BounceCount); @@ -164,7 +165,7 @@ public override void OnInspectorGUI() base.OnInspectorGUI(); // Quality Setting EditorGUI.indentLevel++; GUI.enabled = useCustomValue; - PropertyField(m_RayLength); + PropertyField(m_RayLength, k_RayLengthText); PropertyField(m_ClampValue); PropertyField(m_FullResolution); PropertyField(m_UpscaleRadius); diff --git a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/RayTracingSettingsEditor.cs b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/RayTracingSettingsEditor.cs index e115aaa952a..23a8b7eb84a 100644 --- a/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/RayTracingSettingsEditor.cs +++ b/com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Raytracing/RayTracingSettingsEditor.cs @@ -11,6 +11,7 @@ class RayTracingSettingsEditor : VolumeComponentEditor SerializedDataParameter m_RayBias; SerializedDataParameter m_ExtendShadowCulling; SerializedDataParameter m_ExtendCameraCulling; + SerializedDataParameter m_DirectionalShadowRayLength; public override void OnEnable() { @@ -21,6 +22,7 @@ public override void OnEnable() m_RayBias = Unpack(o.Find(x => x.rayBias)); m_ExtendShadowCulling = Unpack(o.Find(x => x.extendShadowCulling)); m_ExtendCameraCulling = Unpack(o.Find(x => x.extendCameraCulling)); + m_DirectionalShadowRayLength = Unpack(o.Find(x => x.directionalShadowRayLength)); } public override void OnInspectorGUI() @@ -36,6 +38,7 @@ public override void OnInspectorGUI() PropertyField(m_RayBias); PropertyField(m_ExtendShadowCulling); PropertyField(m_ExtendCameraCulling); + PropertyField(m_DirectionalShadowRayLength); } } } diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/GlobalIllumination.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/GlobalIllumination.cs index 0ecb713eca7..97c9528f841 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/GlobalIllumination.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/GlobalIllumination.cs @@ -241,8 +241,7 @@ public bool secondDenoiserPass // RTGI [SerializeField, FormerlySerializedAs("rayLength")] - [Tooltip("Controls the length of GI rays.")] - private ClampedFloatParameter m_RayLength = new ClampedFloatParameter(50.0f, 0f, 50f); + private MinFloatParameter m_RayLength = new MinFloatParameter(50.0f, 0.01f); [SerializeField, FormerlySerializedAs("clampValue")] [Tooltip("Controls the clamp of intensity.")] diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.cs index 18d9e6b437f..7df500e1186 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/AmbientOcclusion.cs @@ -211,7 +211,7 @@ public int directionCount // RTAO [SerializeField, FormerlySerializedAs("rayLength")] - private ClampedFloatParameter m_RayLength = new ClampedFloatParameter(0.5f, 0f, 50f); + private MinFloatParameter m_RayLength = new MinFloatParameter(50.0f, 0.01f); [SerializeField, FormerlySerializedAs("sampleCount")] private ClampedIntParameter m_SampleCount = new ClampedIntParameter(1, 1, 64); [SerializeField, FormerlySerializedAs("denoise")] diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ScreenSpaceReflection.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ScreenSpaceReflection.cs index eebc3628114..9689447edd5 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ScreenSpaceReflection.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/ScreenSpaceLighting/ScreenSpaceReflection.cs @@ -213,8 +213,7 @@ public int rayMaxIterations private IntParameter m_RayMaxIterations = new IntParameter(32); [SerializeField, FormerlySerializedAs("rayLength")] - [Tooltip("Controls the length of reflection rays.")] - private ClampedFloatParameter m_RayLength = new ClampedFloatParameter(50.0f, 0f, 50f); + private MinFloatParameter m_RayLength = new MinFloatParameter(50.0f, 0.01f); [SerializeField, FormerlySerializedAs("clampValue")] [Tooltip("Controls the clamp of intensity.")] diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ScreenSpaceShadowManager.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ScreenSpaceShadowManager.cs index 0560a8a7ae3..250e8b39050 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ScreenSpaceShadowManager.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ScreenSpaceShadowManager.cs @@ -285,7 +285,6 @@ void RenderScreenSpaceShadows(HDCamera hdCamera, CommandBuffer cmd) cmd.SetGlobalTexture(HDShaderIDs._ScreenSpaceShadowsTexture, m_ScreenSpaceShadowTextureArray); } } - bool RenderLightScreenSpaceShadows(HDCamera hdCamera, CommandBuffer cmd) { diff --git a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ScreenSpaceShadowManagerDirectional.cs b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ScreenSpaceShadowManagerDirectional.cs index 4bf4697e72c..c06a41d12cf 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ScreenSpaceShadowManagerDirectional.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/Lighting/Shadow/ScreenSpaceShadowManagerDirectional.cs @@ -17,6 +17,7 @@ struct RTShadowDirectionalTraceParameters public bool softShadow; public int numShadowSamples; public bool colorShadow; + public float maxShadowLength; // Kernels public int clearShadowKernel; @@ -33,6 +34,7 @@ struct RTShadowDirectionalTraceParameters RTShadowDirectionalTraceParameters PrepareRTShadowDirectionalTraceParameters(HDCamera hdCamera, HDAdditionalLightData additionalLightData) { RTShadowDirectionalTraceParameters rtsdtParams = new RTShadowDirectionalTraceParameters(); + RayTracingSettings rayTracingSettings = hdCamera.volumeStack.GetComponent(); // Set the camera parameters rtsdtParams.texWidth = hdCamera.actualWidth; @@ -44,6 +46,7 @@ RTShadowDirectionalTraceParameters PrepareRTShadowDirectionalTraceParameters(HDC // If the surface is infinitively small, we force it to one sample. rtsdtParams.numShadowSamples = rtsdtParams.softShadow ? additionalLightData.numRayTracingSamples : 1; rtsdtParams.colorShadow = m_CurrentSunLightAdditionalLightData.colorShadow; + rtsdtParams.maxShadowLength = rayTracingSettings.directionalShadowRayLength.value; // Kernels rtsdtParams.clearShadowKernel = m_ClearShadowTexture; @@ -151,6 +154,9 @@ static void ExecuteSSSDirectionalTrace(CommandBuffer cmd, RTShadowDirectionalTra // Define the shader pass to use for the shadow pass cmd.SetRayTracingShaderPass(rtsdtParams.screenSpaceShadowRT, "VisibilityDXR"); + // Input Uniforms + cmd.SetRayTracingFloatParam(rtsdtParams.screenSpaceShadowRT, HDShaderIDs._DirectionalMaxRayLength, rtsdtParams.maxShadowLength); + // Set ray count texture cmd.SetRayTracingTextureParam(rtsdtParams.screenSpaceShadowRT, HDShaderIDs._RayCountTexture, rtsdtResources.rayCountTexture); diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs index e0c8883b760..1763a0a51d2 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs @@ -567,6 +567,7 @@ static class HDShaderIDs public static readonly int _RaytracedColorShadowIntegration = Shader.PropertyToID("_RaytracedColorShadowIntegration"); public static readonly int _DirectionalLightAngle = Shader.PropertyToID("_DirectionalLightAngle"); + public static readonly int _DirectionalMaxRayLength = Shader.PropertyToID("_DirectionalMaxRayLength"); public static readonly int _DirectionalLightDirection = Shader.PropertyToID("_DirectionalLightDirection"); public static readonly int _SphereLightPosition = Shader.PropertyToID("_SphereLightPosition"); public static readonly int _SphereLightRadius = Shader.PropertyToID("_SphereLightRadius"); diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/RayTracingSettings.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/RayTracingSettings.cs index eb38922da4b..3426f42bfaa 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/RayTracingSettings.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/RayTracingSettings.cs @@ -28,6 +28,12 @@ public sealed class RayTracingSettings : VolumeComponent [Tooltip("Enables the override of the camera culling. This increases the validity area of animated skinned mesh that are outside of the frustum.")] public BoolParameter extendCameraCulling = new BoolParameter(false); + /// + /// Controls the maximal ray length for ray traced shadows. + /// + [Tooltip("Controls the maximal ray length for ray traced directional shadows.")] + public MinFloatParameter directionalShadowRayLength = new MinFloatParameter(1000.0f, 0.01f); + /// /// Default constructor for the ray tracing settings volume component. /// 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 794d68efb98..bd265bf7a45 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 @@ -361,7 +361,7 @@ void RayGenAreaShadowSingle() RW_TEXTURE2D_X(float, _RaytracedShadowIntegration); RW_TEXTURE2D_X(float, _RaytracingDistanceBufferRW); RW_TEXTURE2D_X(float, _VelocityBuffer); -float _DirectionalLightAngle; +float _DirectionalMaxRayLength; [shader("raygeneration")] void RayGenDirectionalShadowSingle() @@ -411,7 +411,7 @@ void RayGenDirectionalShadowSingle() rayDescriptor.Origin = rayOrigin; rayDescriptor.Direction = rayDirection; rayDescriptor.TMin = 0.0; - rayDescriptor.TMax = 1000.0; + rayDescriptor.TMax = _DirectionalMaxRayLength; // Create and init the RayIntersection structure for this RayIntersection rayIntersection; @@ -478,7 +478,7 @@ void RayGenDirectionalColorShadowSingle() rayDescriptor.Origin = rayOrigin; rayDescriptor.Direction = rayDirection; rayDescriptor.TMin = 0.0; - rayDescriptor.TMax = 1000.0; + rayDescriptor.TMax = _DirectionalMaxRayLength; // Create and init the RayIntersection structure for this RayIntersection rayIntersection; @@ -495,7 +495,7 @@ void RayGenDirectionalColorShadowSingle() rayDescriptor.Origin = rayOrigin; rayDescriptor.Direction = rayDirection; rayDescriptor.TMin = 0.0; - rayDescriptor.TMax = 1000.0; + rayDescriptor.TMax = _DirectionalMaxRayLength; rayIntersection.color = float3(1.0, 1.0, 1.0); rayIntersection.t = MISS_RAY_TRACING_SHADOW_DISTANCE;