Skip to content

Better management of max ray length for ray tracing effects (case 1279849). #1991

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Added Simple mode to Earth Preset for PBR Sky
- Added the export of normals during the prepass for shadow matte for proper SSAO calculation.
- Added the usage of SSAO for shadow matte unlit shader graph.

- 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)
- Fixed GPU hang on D3D12 on xbox.
Expand Down Expand Up @@ -150,6 +150,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- When trying to install the local configuration package, if another one is already present the user is now asked whether they want to keep it or not.
- Improved MSAA color resolve to fix issues when very bright and very dark samples are resolved together.
- Improve performance of GPU light AABB generation
- Removed the max clamp value for the RTR, RTAO and RTGI's ray length (case 1279849).

## [10.0.0] - 2019-06-10

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:<br/>&#8226; **Low**: A preset that emphasizes performance over quality.<br/>&#8226; **Medium**: A preset that balances performance and quality.<br/>&#8226; **High**: A preset that emphasizes quality over performance.<br/>&#8226; **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. |
Original file line number Diff line number Diff line change
Expand Up @@ -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.<br/>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:<br/>&#8226; **Low**: A preset that emphasizes performance over quality.<br/>&#8226; **Medium**: A preset that balances performance and quality.<br/>&#8226; **High**: A preset that emphasizes quality over performance.<br/>&#8226; **Custom**: Allows you to override each property individually.<br/>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. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:<br/>&#8226; **Low**: A preset that emphasizes performance over quality.<br/>&#8226; **Medium**: A preset that balances performance and quality.<br/>&#8226; **High**: A preset that emphasizes quality over performance.<br/>&#8226; **Custom**: Allows you to override each property individually.<br/>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. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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. |
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public override void OnInspectorGUI()
using (new EditorGUI.DisabledScope(!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."));
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -130,6 +131,7 @@ public override void OnInspectorGUI()
EditorGUI.indentLevel++;
using (new EditorGUI.DisabledScope(!useCustomValue))
{
PropertyField(m_RayLength, k_RayLengthText);
PropertyField(m_RayLength);
PropertyField(m_ClampValue);
PropertyField(m_FullResolution);
Expand All @@ -142,7 +144,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);
Expand All @@ -154,7 +156,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);
Expand All @@ -166,6 +168,7 @@ public override void OnInspectorGUI()
EditorGUI.indentLevel++;
using (new EditorGUI.DisabledScope(!useCustomValue))
{
PropertyField(m_RayLength, k_RayLengthText);
PropertyField(m_RayLength);
PropertyField(m_ClampValue);
PropertyField(m_FullResolution);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class RayTracingSettingsEditor : VolumeComponentEditor
SerializedDataParameter m_RayBias;
SerializedDataParameter m_ExtendShadowCulling;
SerializedDataParameter m_ExtendCameraCulling;
SerializedDataParameter m_DirectionalShadowRayLength;

public override void OnEnable()
{
Expand All @@ -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()
Expand All @@ -36,6 +38,7 @@ public override void OnInspectorGUI()
PropertyField(m_RayBias);
PropertyField(m_ExtendShadowCulling);
PropertyField(m_ExtendCameraCulling);
PropertyField(m_DirectionalShadowRayLength);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,6 @@ void RenderScreenSpaceShadows(HDCamera hdCamera, CommandBuffer cmd)
}
}


bool RenderLightScreenSpaceShadows(HDCamera hdCamera, CommandBuffer cmd)
{
using (new ProfilingScope(cmd, ProfilingSampler.Get(HDProfileId.RaytracingLightShadow)))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ struct RTShadowDirectionalTraceParameters
public bool softShadow;
public int numShadowSamples;
public bool colorShadow;
public float maxShadowLength;

// Kernels
public int clearShadowKernel;
Expand All @@ -33,6 +34,7 @@ struct RTShadowDirectionalTraceParameters
RTShadowDirectionalTraceParameters PrepareRTShadowDirectionalTraceParameters(HDCamera hdCamera, HDAdditionalLightData additionalLightData)
{
RTShadowDirectionalTraceParameters rtsdtParams = new RTShadowDirectionalTraceParameters();
RayTracingSettings rayTracingSettings = hdCamera.volumeStack.GetComponent<RayTracingSettings>();

// Set the camera parameters
rtsdtParams.texWidth = hdCamera.actualWidth;
Expand All @@ -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;
Expand Down Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/// <summary>
/// Controls the maximal ray length for ray traced shadows.
/// </summary>
[Tooltip("Controls the maximal ray length for ray traced directional shadows.")]
public MinFloatParameter directionalShadowRayLength = new MinFloatParameter(1000.0f, 0.01f);

/// <summary>
/// Default constructor for the ray tracing settings volume component.
/// </summary>
Expand Down
Loading