Browse Source

React to changes in resolution settings and fixed depth sampling in bilateral upscale pass.

master
Nico de Poel 2 years ago
parent
commit
3dc31924da
  1. 12
      com.unity.render-pipelines.high-definition/Runtime/FidelityFX/HDRenderPipeline.FidelityFX.Cacao.cs
  2. 10
      com.unity.render-pipelines.high-definition/Runtime/FidelityFX/ffx_cacao_common_hdrp.cginc
  3. 26
      com.unity.render-pipelines.high-definition/Runtime/FidelityFX/shaders/cacao/ffx_cacao_callbacks_hlsl.h

12
com.unity.render-pipelines.high-definition/Runtime/FidelityFX/HDRenderPipeline.FidelityFX.Cacao.cs

@ -7,6 +7,8 @@ namespace UnityEngine.Rendering.HighDefinition
public partial class HDRenderPipeline
{
private CacaoContext m_CacaoContext;
private Vector2Int m_CacaoPrevResolution;
private bool m_CacaoPrevDownsample;
class RenderCacaoParameters
{
@ -47,17 +49,25 @@ namespace UnityEngine.Rendering.HighDefinition
bilateralUpscale = runtimeShaders.cacaoBilateralUpscale,
reinterleave = runtimeShaders.cacaoReinterleave,
});
}
// Detect changes in resolution parameters and reinitialize context if necessary
if (parameters.resolution.x != m_CacaoPrevResolution.x || parameters.resolution.y != m_CacaoPrevResolution.y || parameters.downsample != m_CacaoPrevDownsample)
{
m_CacaoContext.DestroyScreenSizeDependentResources();
m_CacaoContext.InitScreenSizeDependentResources(new Cacao.ScreenSizeInfo
{
Width = (uint)parameters.resolution.x,
Height = (uint)parameters.resolution.y,
UseDownsampledSsao = parameters.downsample,
});
m_CacaoPrevResolution = parameters.resolution;
m_CacaoPrevDownsample = parameters.downsample;
}
// TODO: init m_CacaoContext with data from parameters
// TODO: detect changes in parameters and reinit m_CacaoContext if necessary
m_CacaoContext.UpdateSettings(parameters.settings);
using (var builder = renderGraph.AddRenderPass<RenderCacaoPassData>("FidelityFX CACAO", out var passData, ProfilingSampler.Get(HDProfileId.AmbientOcclusion)))

10
com.unity.render-pipelines.high-definition/Runtime/FidelityFX/ffx_cacao_common_hdrp.cginc

@ -44,6 +44,16 @@ float4 FFX_CACAO_Prepare_GatherDepthOffset(float2 uv, int2 offset)
return _CameraDepthTexture.GatherRed(s_point_clamp_sampler, UV_TEXTURE2D_X(uv), offset);
}
float4 FFX_CACAO_BilateralUpscale_LoadDepths(int2 coord)
{
float4 depths;
depths.x = _CameraDepthTexture.Load(COORD_TEXTURE2D_X_LOD(coord, 0), int2(0, 0)).r;
depths.y = _CameraDepthTexture.Load(COORD_TEXTURE2D_X_LOD(coord, 0), int2(1, 0)).r;
depths.z = _CameraDepthTexture.Load(COORD_TEXTURE2D_X_LOD(coord, 0), int2(0, 1)).r;
depths.w = _CameraDepthTexture.Load(COORD_TEXTURE2D_X_LOD(coord, 0), int2(1, 1)).r;
return depths;
}
float3 LoadSceneNormals(int2 coord)
{
NormalData normalData;

26
com.unity.render-pipelines.high-definition/Runtime/FidelityFX/shaders/cacao/ffx_cacao_callbacks_hlsl.h

@ -858,19 +858,19 @@ FfxFloat32x2 FFX_CACAO_BilateralUpscale_LoadSSAO(FfxUInt32x2 coord, FfxUInt32 in
#endif
}
FfxFloat32x4 FFX_CACAO_BilateralUpscale_LoadDepths(FfxUInt32x2 coord)
{
FfxFloat32x4 depths;
#if defined CACAO_BIND_SRV_DEPTH_IN
depths.x = g_DepthIn.Load(FfxInt32x3(coord, 0), FfxInt32x2(0, 0));
depths.y = g_DepthIn.Load(FfxInt32x3(coord, 0), FfxInt32x2(1, 0));
depths.z = g_DepthIn.Load(FfxInt32x3(coord, 0), FfxInt32x2(0, 1));
depths.w = g_DepthIn.Load(FfxInt32x3(coord, 0), FfxInt32x2(1, 1));
return depths;
#else
return FfxFloat32x4(0, 0, 0, 0);
#endif
}
// FfxFloat32x4 FFX_CACAO_BilateralUpscale_LoadDepths(FfxUInt32x2 coord)
// {
// FfxFloat32x4 depths;
// #if defined CACAO_BIND_SRV_DEPTH_IN
// depths.x = g_DepthIn.Load(FfxInt32x3(coord, 0), FfxInt32x2(0, 0));
// depths.y = g_DepthIn.Load(FfxInt32x3(coord, 0), FfxInt32x2(1, 0));
// depths.z = g_DepthIn.Load(FfxInt32x3(coord, 0), FfxInt32x2(0, 1));
// depths.w = g_DepthIn.Load(FfxInt32x3(coord, 0), FfxInt32x2(1, 1));
// return depths;
// #else
// return FfxFloat32x4(0, 0, 0, 0);
// #endif
// }
FfxFloat32 FFX_CACAO_BilateralUpscale_LoadDownscaledDepth(FfxUInt32x2 coord, FfxUInt32 index)
{

Loading…
Cancel
Save