diff --git a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/702_DirectionalShadowFiltering.png b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/702_DirectionalShadowFiltering.png index 6f0c599251e..4cbf534387e 100644 --- a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/702_DirectionalShadowFiltering.png +++ b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/702_DirectionalShadowFiltering.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:04b281ad8d87dccea535d77985f8352dcea0ab98da172b01edc0c838eedb5bbc -size 29594 +oid sha256:448e2695a14041e8a62447a23c2d50f07046c04f3130f010ca8ddf7ac2a4d2c4 +size 31466 diff --git a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/702_PunctualShadowFiltering.png b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/702_PunctualShadowFiltering.png index 1507e26f823..728b68b56eb 100644 --- a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/702_PunctualShadowFiltering.png +++ b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/702_PunctualShadowFiltering.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9514fa7f7336f83e873abf990c3945200ee4178c5ddbdfb4abe8ad773d952483 -size 120046 +oid sha256:ed9359dd1c1660e3206f576344eacd2bed71f4d21fd62bce78e1bbb52f3ef52a +size 108105 diff --git a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/901_Materials_HDRP_Variants.png b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/901_Materials_HDRP_Variants.png index 7cf0632dd84..5f09247690d 100644 --- a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/901_Materials_HDRP_Variants.png +++ b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/901_Materials_HDRP_Variants.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:db5f0e08d7efe6aac0c85b76b9e0dfc436f6776ffec228ae658bb1dbe0739008 -size 247538 +oid sha256:05a2d60e398633dd391299cb7869f198fa6ffa89050546e271fdd899c79bf13d +size 257384 diff --git a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/902_Materials_SG_Variants_Fabric.png b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/902_Materials_SG_Variants_Fabric.png index d1f68381b14..025e78989b1 100644 --- a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/902_Materials_SG_Variants_Fabric.png +++ b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/902_Materials_SG_Variants_Fabric.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4258354dad6cad0831a0fd52b6b6eadefeb1339367043f4a5a04d7f3d898d65f -size 199611 +oid sha256:bbf12f069ec449085104b81a3ae534ce66c3552d3ab2f1f3ddb9bc2528f60ddc +size 202882 diff --git a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/902_Materials_SG_Variants_Hair.png b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/902_Materials_SG_Variants_Hair.png index 51148dc959d..b9a75184f39 100644 --- a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/902_Materials_SG_Variants_Hair.png +++ b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/902_Materials_SG_Variants_Hair.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c3a4b2b31261244e6d9298a5a245ab771b59b9d8ec9320ca80929ee83a43522d -size 101099 +oid sha256:02fb2ec1df7c3c3093288a9fd42c9be563c4514da198173866eb82f125ed16e3 +size 100926 diff --git a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/902_Materials_SG_Variants_Lit.png b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/902_Materials_SG_Variants_Lit.png index 43b20ea0474..278722ea566 100644 --- a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/902_Materials_SG_Variants_Lit.png +++ b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/902_Materials_SG_Variants_Lit.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6c6fce43cc34e3f73bb49fed374d37412cd889981677a6292d8ef2a8d1d8d6e3 -size 184113 +oid sha256:246a8f00236eb23e5a4cd3be49416d45be4e19ae04d9bec544167ae7143f1e23 +size 187939 diff --git a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/902_Materials_SG_Variants_StackLit.png b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/902_Materials_SG_Variants_StackLit.png index de03ae76440..f5b002442ff 100644 --- a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/902_Materials_SG_Variants_StackLit.png +++ b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/902_Materials_SG_Variants_StackLit.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d526cb23efeed5783cbfa60433e951d2403117802b96b08624434fa09587a232 -size 192145 +oid sha256:1a9aab258e2cdd27cd5cba43eac02f10aa24282744dbb51bc4142bdd037cb9a7 +size 197647 diff --git a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/902_Materials_SG_Variants_Unlit.png b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/902_Materials_SG_Variants_Unlit.png index 37dc2dcf067..e5face603c0 100644 --- a/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/902_Materials_SG_Variants_Unlit.png +++ b/TestProjects/HDRP_DXR_Tests/Assets/ReferenceImages/Linear/WindowsEditor/Direct3D12/None/902_Materials_SG_Variants_Unlit.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8786abb1966a8f091c306eff5635da3e1f6bafd87b9dbb6dce12b80ff8c1231f -size 134838 +oid sha256:45756dce593da89d02a66b36ea21c252db173789a8fc000bf5caa0bd66629345 +size 135722 diff --git a/com.unity.render-pipelines.high-definition/CHANGELOG.md b/com.unity.render-pipelines.high-definition/CHANGELOG.md index 1062fb1374e..462218537cb 100644 --- a/com.unity.render-pipelines.high-definition/CHANGELOG.md +++ b/com.unity.render-pipelines.high-definition/CHANGELOG.md @@ -836,6 +836,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Add color clear pass while rendering XR occlusion mesh to avoid leaks. - Only use one texture for ray traced reflection upscaling. - Adjust the upscale radius based on the roughness value. +- DXR: Changed the way the filter size is decided for directional, point and spot shadows. ## [7.1.1] - 2019-09-05 diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipelineRayTracingResources.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipelineRayTracingResources.cs index e5ec0812a6f..1c784b7f806 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipelineRayTracingResources.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDRenderPipelineRayTracingResources.cs @@ -86,9 +86,6 @@ partial class HDRenderPipelineRayTracingResources : ScriptableObject // Filtering for reflections [Reload("Runtime/RenderPipelineResources/Texture/ReflectionKernelMapping.png")] public Texture2D reflectionFilterMapping; - [Reload("Runtime/RenderPipelineResources/Texture/ShadowKernelMapping.asset")] - public Texture3D shadowFilterMapping; - #if UNITY_EDITOR [UnityEditor.CustomEditor(typeof(HDRenderPipelineRayTracingResources))] 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 416b9d06d01..0931b75f459 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/HDStringConstants.cs @@ -570,6 +570,7 @@ static class HDShaderIDs public static readonly int _DirectionalLightDirection = Shader.PropertyToID("_DirectionalLightDirection"); public static readonly int _SphereLightPosition = Shader.PropertyToID("_SphereLightPosition"); public static readonly int _SphereLightRadius = Shader.PropertyToID("_SphereLightRadius"); + public static readonly int _CameraFOV = Shader.PropertyToID("_CameraFOV"); // Ambient occlusion public static readonly int _RaytracingAOIntensity = Shader.PropertyToID("_RaytracingAOIntensity"); diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDDiffuseShadowDenoiser.cs b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDDiffuseShadowDenoiser.cs index 3123a19ea15..4072f065c7a 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDDiffuseShadowDenoiser.cs +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/HDDiffuseShadowDenoiser.cs @@ -8,7 +8,6 @@ class HDDiffuseShadowDenoiser // The resources quired by this component ComputeShader m_ShadowDenoiser; - Texture3D m_ShadowFilterMapping; // Kernels that we are using int m_BilateralFilterHSingleDirectionalKernel; @@ -30,7 +29,6 @@ public void Init(HDRenderPipelineRayTracingResources rpRTResources, SharedRTMana m_RenderPipeline = renderPipeline; m_ShadowDenoiser = rpRTResources.diffuseShadowDenoiserCS; - m_ShadowFilterMapping = rpRTResources.shadowFilterMapping; m_BilateralFilterHSingleDirectionalKernel = m_ShadowDenoiser.FindKernel("BilateralFilterHSingleDirectional"); m_BilateralFilterVSingleDirectionalKernel = m_ShadowDenoiser.FindKernel("BilateralFilterVSingleDirectional"); @@ -64,6 +62,7 @@ public void DenoiseBufferDirectional(CommandBuffer cmd, HDCamera hdCamera, // Convert the angular diameter of the directional light to radians (from degrees) float lightAngle = angularDiameter * Mathf.PI / 180.0f; + float cameraFOV = hdCamera.camera.fieldOfView * Mathf.PI / 180.0f; // Horizontal pass of the bilateral filter int m_KernelFilter = singleChannel ? m_BilateralFilterHSingleDirectionalKernel : m_BilateralFilterHColorDirectionalKernel; @@ -71,13 +70,13 @@ public void DenoiseBufferDirectional(CommandBuffer cmd, HDCamera hdCamera, // Bind input uniforms cmd.SetComputeFloatParam(m_ShadowDenoiser, HDShaderIDs._DirectionalLightAngle, lightAngle); cmd.SetComputeIntParam(m_ShadowDenoiser, HDShaderIDs._DenoiserFilterRadius, kernelSize); + cmd.SetComputeFloatParam(m_ShadowDenoiser, HDShaderIDs._CameraFOV, cameraFOV); // Bind Input Textures cmd.SetComputeTextureParam(m_ShadowDenoiser, m_KernelFilter, HDShaderIDs._DepthTexture, m_SharedRTManager.GetDepthStencilBuffer()); cmd.SetComputeTextureParam(m_ShadowDenoiser, m_KernelFilter, HDShaderIDs._NormalBufferTexture, m_SharedRTManager.GetNormalBuffer()); cmd.SetComputeTextureParam(m_ShadowDenoiser, m_KernelFilter, HDShaderIDs._DenoiseInputTexture, noisySignal); cmd.SetComputeTextureParam(m_ShadowDenoiser, m_KernelFilter, HDShaderIDs._DistanceTexture, distanceSignal); - cmd.SetComputeTextureParam(m_ShadowDenoiser, m_KernelFilter, HDShaderIDs._ShadowFilterMapping, m_ShadowFilterMapping); // Bind output textures cmd.SetComputeTextureParam(m_ShadowDenoiser, m_KernelFilter, HDShaderIDs._DenoiseOutputTextureRW, intermediateBuffer0); @@ -91,13 +90,13 @@ public void DenoiseBufferDirectional(CommandBuffer cmd, HDCamera hdCamera, // Bind input uniforms cmd.SetComputeIntParam(m_ShadowDenoiser, HDShaderIDs._DenoiserFilterRadius, kernelSize); cmd.SetComputeFloatParam(m_ShadowDenoiser, HDShaderIDs._DirectionalLightAngle, lightAngle); + cmd.SetComputeFloatParam(m_ShadowDenoiser, HDShaderIDs._CameraFOV, cameraFOV); // Bind Input Textures cmd.SetComputeTextureParam(m_ShadowDenoiser, m_KernelFilter, HDShaderIDs._DepthTexture, m_SharedRTManager.GetDepthStencilBuffer()); cmd.SetComputeTextureParam(m_ShadowDenoiser, m_KernelFilter, HDShaderIDs._NormalBufferTexture, m_SharedRTManager.GetNormalBuffer()); cmd.SetComputeTextureParam(m_ShadowDenoiser, m_KernelFilter, HDShaderIDs._DenoiseInputTexture, intermediateBuffer0); cmd.SetComputeTextureParam(m_ShadowDenoiser, m_KernelFilter, HDShaderIDs._DistanceTexture, distanceSignal); - cmd.SetComputeTextureParam(m_ShadowDenoiser, m_KernelFilter, HDShaderIDs._ShadowFilterMapping, m_ShadowFilterMapping); // Bind output textures cmd.SetComputeTextureParam(m_ShadowDenoiser, m_KernelFilter, HDShaderIDs._DenoiseOutputTextureRW, outputSignal); @@ -122,17 +121,19 @@ public void DenoiseBufferSphere(CommandBuffer cmd, HDCamera hdCamera, int numTilesX = (texWidth + (areaTileSize - 1)) / areaTileSize; int numTilesY = (texHeight + (areaTileSize - 1)) / areaTileSize; + float cameraFOV = hdCamera.camera.fieldOfView * Mathf.PI / 180.0f; + // Bind input uniforms cmd.SetComputeIntParam(m_ShadowDenoiser, HDShaderIDs._DenoiserFilterRadius, kernelSize); cmd.SetComputeVectorParam(m_ShadowDenoiser, HDShaderIDs._SphereLightPosition, lightPosition); cmd.SetComputeFloatParam(m_ShadowDenoiser, HDShaderIDs._SphereLightRadius, lightRadius); + cmd.SetComputeFloatParam(m_ShadowDenoiser, HDShaderIDs._CameraFOV, cameraFOV); // Bind Input Textures cmd.SetComputeTextureParam(m_ShadowDenoiser, m_BilateralFilterHSingleSphereKernel, HDShaderIDs._DepthTexture, m_SharedRTManager.GetDepthStencilBuffer()); cmd.SetComputeTextureParam(m_ShadowDenoiser, m_BilateralFilterHSingleSphereKernel, HDShaderIDs._NormalBufferTexture, m_SharedRTManager.GetNormalBuffer()); cmd.SetComputeTextureParam(m_ShadowDenoiser, m_BilateralFilterHSingleSphereKernel, HDShaderIDs._DenoiseInputTexture, noisySignal); cmd.SetComputeTextureParam(m_ShadowDenoiser, m_BilateralFilterHSingleSphereKernel, HDShaderIDs._DistanceTexture, distanceSignal); - cmd.SetComputeTextureParam(m_ShadowDenoiser, m_BilateralFilterHSingleSphereKernel, HDShaderIDs._ShadowFilterMapping, m_ShadowFilterMapping); // Bind output textures cmd.SetComputeTextureParam(m_ShadowDenoiser, m_BilateralFilterHSingleSphereKernel, HDShaderIDs._DenoiseOutputTextureRW, intermediateBuffer0); @@ -144,12 +145,12 @@ public void DenoiseBufferSphere(CommandBuffer cmd, HDCamera hdCamera, cmd.SetComputeIntParam(m_ShadowDenoiser, HDShaderIDs._DenoiserFilterRadius, kernelSize); cmd.SetComputeVectorParam(m_ShadowDenoiser, HDShaderIDs._SphereLightPosition, lightPosition); cmd.SetComputeFloatParam(m_ShadowDenoiser, HDShaderIDs._SphereLightRadius, lightRadius); + cmd.SetComputeFloatParam(m_ShadowDenoiser, HDShaderIDs._CameraFOV, cameraFOV); cmd.SetComputeTextureParam(m_ShadowDenoiser, m_BilateralFilterVSingleSphereKernel, HDShaderIDs._DenoiseInputTexture, intermediateBuffer0); cmd.SetComputeTextureParam(m_ShadowDenoiser, m_BilateralFilterVSingleSphereKernel, HDShaderIDs._DistanceTexture, distanceSignal); cmd.SetComputeTextureParam(m_ShadowDenoiser, m_BilateralFilterVSingleSphereKernel, HDShaderIDs._DepthTexture, m_SharedRTManager.GetDepthStencilBuffer()); cmd.SetComputeTextureParam(m_ShadowDenoiser, m_BilateralFilterVSingleSphereKernel, HDShaderIDs._NormalBufferTexture, m_SharedRTManager.GetNormalBuffer()); - cmd.SetComputeTextureParam(m_ShadowDenoiser, m_BilateralFilterVSingleSphereKernel, HDShaderIDs._ShadowFilterMapping, m_ShadowFilterMapping); // Bind output textures cmd.SetComputeTextureParam(m_ShadowDenoiser, m_BilateralFilterVSingleSphereKernel, HDShaderIDs._DenoiseOutputTextureRW, outputSignal); diff --git a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Denoising/DiffuseShadowDenoiser.compute b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Denoising/DiffuseShadowDenoiser.compute index 92d9c86d242..40c1800e1bd 100644 --- a/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Denoising/DiffuseShadowDenoiser.compute +++ b/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Denoising/DiffuseShadowDenoiser.compute @@ -24,13 +24,6 @@ // Tile size of this compute #define SHADOW_DENOISER_TILE_SIZE 8 -// Texture used to adjust the filter size to avoid overblurring -TEXTURE3D(_ShadowFilterMapping); - -// This value is the maximal distance value that the filter supports -#define RAY_TRACING_LIGHT_MAX_DISTANCE 50.0f -#define RAY_TRACING_OCCLUDER_MAX_DISTANCE 10.0f - // Ray tracing input textures TEXTURE2D_X(_DenoiseInputTexture); TEXTURE2D_X(_DistanceTexture); @@ -38,6 +31,9 @@ TEXTURE2D_X(_DistanceTexture); // Generic denoiser inputs int _DenoiserFilterRadius; +// Camera FOV +float _CameraFOV; + #if DIRECTIONAL_LIGHT // Inputs for directional lights float _DirectionalLightAngle; @@ -66,34 +62,38 @@ void BILATERAL_FILTER(uint3 dispatchThreadId : SV_DispatchThreadID, uint2 groupT // Read the center pixel0 const BilateralData center = TapBilateralData(centerCoord); - // Compute the normalized view vector - float distanceValue = clamp(length(_WorldSpaceCameraPos - center.position) / RAY_TRACING_LIGHT_MAX_DISTANCE, 0.0, 1.0); + // Get the world space positon of the center pixel to filter + const float3 positionWS = GetAbsolutePositionWS(center.position); #if DIRECTIONAL_LIGHT - // Evaluate the normalized solid angle of the light - float lightSolidAngle = _DirectionalLightAngle / (PI * 0.5f); + // For the directonal light, the solid angle can be used directly + float lightSolidAngle = _DirectionalLightAngle; #else // Compute the light vector - float lightPointDistance = clamp(length(_SphereLightPosition - GetAbsolutePositionWS(center.position)) / RAY_TRACING_LIGHT_MAX_DISTANCE, 0.0, 1.0); - + float lightPointDistance = length(_SphereLightPosition - positionWS); // Evaluate the normalized solid angle of the light - float lightSolidAngle = atan(_SphereLightRadius / lightPointDistance) / PI; + float lightSolidAngle = atan(_SphereLightRadius / lightPointDistance); #endif + // Compute the distances we need for our filtering + const float distanceCameraToPlane = length(positionWS - _WorldSpaceCameraPos); + const float distancePlaneToObject = LOAD_TEXTURE2D_X(_DistanceTexture, centerCoord).x; - // Grab the normalized/clamped distance between the point and its occluder - float averageSurfaceDistance = clamp(LOAD_TEXTURE2D_X(_DistanceTexture, centerCoord).x / RAY_TRACING_OCCLUDER_MAX_DISTANCE, 0.0, 1.0); + // Compute the cone footprint on the image reflection plane for this configuration + const float brdfConeRadius = tan(lightSolidAngle * 0.5) * distancePlaneToObject * 2.0f; - // Compute the 3d uv value that we shall be using - float3 mappingUV = float3(averageSurfaceDistance, lightSolidAngle, distanceValue); + // We need to compute the view cone radius + const float viewConeRadius = brdfConeRadius * distanceCameraToPlane / (distancePlaneToObject + distanceCameraToPlane); - // Fetch the shadow scaling value - float2 radiusScale = SAMPLE_TEXTURE3D_LOD(_ShadowFilterMapping, s_trilinear_clamp_sampler, mappingUV, 0.0f).xy; + // Compute the view cone's half angle. This matches the FOV angle to see exactly the half of the cone (The tangent could be precomputed in the table) + const float viewConeHalfAngle = FastATanPos(viewConeRadius / distanceCameraToPlane); + // Given the camera's fov and pixel resolution convert the viewConeHalfAngle to a number of pixels + const float pixelDistance = viewConeHalfAngle / _CameraFOV * _ScreenSize.x; // Evaluate the radius that should be used for the filter #if FINAL_PASS - const float radius = _DenoiserFilterRadius * radiusScale.x; + const float radius = clamp(pixelDistance, 1, _DenoiserFilterRadius); #else - const float radius = _DenoiserFilterRadius * radiusScale.y; + const float radius = clamp(pixelDistance, 1, _DenoiserFilterRadius); #endif // Compute the sigma value for our filter