@ -112,6 +112,8 @@
FfxFloat32x2 g_FFX_CACAO_DeinterleavedDepthBufferNormalisedOffset ;
float4x4 g_FFX_CACAO_NormalsWorldToViewspaceMatrix ;
FfxFloat32x4 g_FFX_CACAO_RTHandleScale ;
} ;
# define FFX_CACAO_CONSTANT_BUFFER_1_SIZE 172 / / Number of 32-bit values. This must be kept in sync with max( cbRCAS , cbSPD) size.
@ -428,6 +430,15 @@ float4x4 NormalsWorldToViewspaceMatrix(){
# endif
}
float2 ClampAndScaleUV ( float2 UV )
{
# if defined(CACAO_BIND_CB_CACAO)
return min ( UV , 1.0f ) * g_FFX_CACAO_RTHandleScale . xy ;
# else
return UV ;
# endif
}
# if defined(FFX_GPU)
# define FFX_CACAO_ROOTSIG_STRINGIFY(p) FFX_CACAO_ROOTSIG_STR(p)
# define FFX_CACAO_ROOTSIG_STR(p) #p
@ -645,18 +656,20 @@ FfxFloat32x2 FFX_CACAO_Apply_LoadSSAOPass(FfxUInt32x2 coord, FfxUInt32 passnum)
# endif
}
/ / void FFX_CACAO_Apply_StoreOutput ( FfxUInt32x2 coord , FfxFloat32 val )
/ / {
void FFX_CACAO_Apply_StoreOutput ( FfxUInt32x2 coord , FfxFloat32 val )
{
FFX_CACAO_Apply_StoreOutput_Unity ( coord , val ) ;
/ / # if defined CACAO_BIND_UAV_OUTPUT
/ / g_RwOutput [ coord ] = val ;
/ / # endif
/ / }
}
/ / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
/ / Prepare
/ / FfxFloat32x4 FFX_CACAO_Prepare_SampleDepthOffsets ( FfxFloat32x2 uv )
/ / {
FfxFloat32x4 FFX_CACAO_Prepare_SampleDepthOffsets ( FfxFloat32x2 uv )
{
return FFX_CACAO_Prepare_SampleDepthOffsets_Unity ( ClampAndScaleUV ( uv ) ) ;
/ / # if defined CACAO_BIND_SRV_DEPTH_IN
/ / FfxFloat32x4 samples ;
/ / samples . x = g_DepthIn . SampleLevel ( g_PointClampSampler , uv , 0.0f , FfxInt32x2 ( 0 , 2 ) ) ;
@ -667,49 +680,53 @@ FfxFloat32x2 FFX_CACAO_Apply_LoadSSAOPass(FfxUInt32x2 coord, FfxUInt32 passnum)
/ / # else
/ / return FfxFloat32x4 ( 0 , 0 , 0 , 0 ) ;
/ / # endif
/ / }
/ /
/ / FfxFloat32x4 FFX_CACAO_Prepare_GatherDepth ( FfxFloat32x2 uv )
/ / {
}
FfxFloat32x4 FFX_CACAO_Prepare_GatherDepth ( FfxFloat32x2 uv )
{
return FFX_CACAO_Prepare_GatherDepth_Unity ( uv ) ;
/ / # if defined CACAO_BIND_SRV_DEPTH_IN
/ / return g_DepthIn . GatherRed ( g_PointClampSampler , uv ) ;
/ / # else
/ / return FfxFloat32x4 ( 0 , 0 , 0 , 0 ) ;
/ / # endif
/ / }
/ /
/ / FfxFloat32 FFX_CACAO_Prepare_LoadDepth ( FfxUInt32x2 coord )
/ / {
}
FfxFloat32 FFX_CACAO_Prepare_LoadDepth ( FfxUInt32x2 coord )
{
return FFX_CACAO_Prepare_LoadDepth_Unity ( coord ) ;
/ / # if defined CACAO_BIND_SRV_DEPTH_IN
/ / return g_DepthIn . Load ( FfxInt32x3 ( coord , 0 ) ) ;
/ / # else
/ / return 0 ;
/ / # endif
/ / }
/ /
/ / FfxFloat32 FFX_CACAO_Prepare_LoadDepthOffset ( FfxUInt32x2 coord , FfxInt32x2 offset )
/ / {
}
FfxFloat32 FFX_CACAO_Prepare_LoadDepthOffset ( FfxUInt32x2 coord , FfxInt32x2 offset )
{
return FFX_CACAO_Prepare_LoadDepthOffset_Unity ( coord , offset ) ;
/ / # if defined CACAO_BIND_SRV_DEPTH_IN
/ / return g_DepthIn . Load ( FfxInt32x3 ( coord , 0 ) , offset ) ;
/ / # else
/ / return 0 ;
/ / # endif
/ / }
/ /
/ / FfxFloat32x4 FFX_CACAO_Prepare_GatherDepthOffset ( FfxFloat32x2 uv , FfxInt32x2 offset )
/ / {
}
FfxFloat32x4 FFX_CACAO_Prepare_GatherDepthOffset ( FfxFloat32x2 uv , FfxInt32x2 offset )
{
return FFX_CACAO_Prepare_GatherDepthOffset_Unity ( ClampAndScaleUV ( uv ) , offset ) ;
/ / # if defined CACAO_BIND_SRV_DEPTH_IN
/ / return g_DepthIn . GatherRed ( g_PointClampSampler , uv , offset ) ;
/ / # else
/ / return FfxFloat32x4 ( 0 , 0 , 0 , 0 ) ;
/ / # endif
/ / }
}
FfxFloat32x3 FFX_CACAO_Prepare_LoadNormal ( FfxUInt32x2 coord )
{
# if defined CACAO_BIND_SRV_NORMAL_IN
/ / FfxFloat32x3 normal = g_NormalIn . Load ( FfxInt32x3 ( coord , 0 ) ) . xyz ;
FfxFloat32x3 normal = LoadSceneNormals ( coord ) ;
FfxFloat32x3 normal = LoadSceneNormals_Unity ( coord ) ;
/ / normal = normal * NormalsUnpackMul ( ) . xxx + NormalsUnpackAdd ( ) . xxx ;
normal = mul ( normal , ( float3x3 ) NormalsWorldToViewspaceMatrix ( ) ) . xyz ;
/ / normal = normalize ( normal ) ;
@ -824,12 +841,13 @@ void FFX_CACAO_Importance_LoadCounterInterlockedAdd(FfxUInt32 val)
/ / These resources ping / pong which is handled by schedule dispatch
/ / void FFX_CACAO_BilateralUpscale_StoreOutput ( FfxUInt32x2 coord , FfxInt32x2 offset , FfxFloat32 val )
/ / {
void FFX_CACAO_BilateralUpscale_StoreOutput ( FfxUInt32x2 coord , FfxInt32x2 offset , FfxFloat32 val )
{
FFX_CACAO_BilateralUpscale_StoreOutput_Unity ( coord , offset , val ) ;
/ / # if defined CACAO_BIND_UAV_OUTPUT
/ / g_RwOutput [ coord + offset ] = val ;
/ / # endif
/ / }
}
FfxFloat32 FFX_CACAO_BilateralUpscale_SampleSSAOLinear ( FfxFloat32x2 uv , FfxUInt32 index )
{
@ -858,8 +876,9 @@ FfxFloat32x2 FFX_CACAO_BilateralUpscale_LoadSSAO(FfxUInt32x2 coord, FfxUInt32 in
# endif
}
/ / FfxFloat32x4 FFX_CACAO_BilateralUpscale_LoadDepths ( FfxUInt32x2 coord )
/ / {
FfxFloat32x4 FFX_CACAO_BilateralUpscale_LoadDepths ( FfxUInt32x2 coord )
{
return FFX_CACAO_BilateralUpscale_LoadDepths_Unity ( coord ) ;
/ / FfxFloat32x4 depths ;
/ / # if defined CACAO_BIND_SRV_DEPTH_IN
/ / depths . x = g_DepthIn . Load ( FfxInt32x3 ( coord , 0 ) , FfxInt32x2 ( 0 , 0 ) ) ;
@ -870,7 +889,7 @@ FfxFloat32x2 FFX_CACAO_BilateralUpscale_LoadSSAO(FfxUInt32x2 coord, FfxUInt32 in
/ / # else
/ / return FfxFloat32x4 ( 0 , 0 , 0 , 0 ) ;
/ / # endif
/ / }
}
FfxFloat32 FFX_CACAO_BilateralUpscale_LoadDownscaledDepth ( FfxUInt32x2 coord , FfxUInt32 index )
{