You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
2.9 KiB
74 lines
2.9 KiB
#pragma warning(disable: 3556) // Integer divides might be much slower, try using uints if possible.
|
|
#pragma warning(disable: 3205) // In the conversion from larger type to smaller, a loss of data might occur.
|
|
#pragma warning(disable: 3571) // pow(f, e) will not work for negative f, use abs(f) or conditionally handle negative values if you expect them.
|
|
|
|
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/NormalBuffer.hlsl"
|
|
|
|
#if defined(USE_TEXTURE2D_X_AS_ARRAY)
|
|
#define UV_TEXTURE2D_X(uv) float3(uv, SLICE_ARRAY_INDEX)
|
|
#define COORD_TEXTURE2D_X_LOD(coord, lod) uint4(coord, SLICE_ARRAY_INDEX, lod)
|
|
#else
|
|
#define UV_TEXTURE2D_X(uv) uv
|
|
#define COORD_TEXTURE2D_X_LOD(coord, lod) uint3(coord, lod)
|
|
#endif
|
|
|
|
float4 FFX_CACAO_Prepare_SampleDepthOffsets(float2 uv)
|
|
{
|
|
float4 samples;
|
|
samples.x = _CameraDepthTexture.SampleLevel(s_point_clamp_sampler, UV_TEXTURE2D_X(uv), 0.0f, int2(0, 2)).r;
|
|
samples.y = _CameraDepthTexture.SampleLevel(s_point_clamp_sampler, UV_TEXTURE2D_X(uv), 0.0f, int2(2, 2)).r;
|
|
samples.z = _CameraDepthTexture.SampleLevel(s_point_clamp_sampler, UV_TEXTURE2D_X(uv), 0.0f, int2(2, 0)).r;
|
|
samples.w = _CameraDepthTexture.SampleLevel(s_point_clamp_sampler, UV_TEXTURE2D_X(uv), 0.0f, int2(0, 0)).r;
|
|
return samples;
|
|
}
|
|
|
|
float4 FFX_CACAO_Prepare_GatherDepth(float2 uv)
|
|
{
|
|
return _CameraDepthTexture.GatherRed(s_point_clamp_sampler, UV_TEXTURE2D_X(uv));
|
|
}
|
|
|
|
float FFX_CACAO_Prepare_LoadDepth(int2 coord)
|
|
{
|
|
return _CameraDepthTexture.Load(COORD_TEXTURE2D_X_LOD(coord, 0)).r;
|
|
}
|
|
|
|
float FFX_CACAO_Prepare_LoadDepthOffset(int2 coord, int2 offset)
|
|
{
|
|
return _CameraDepthTexture.Load(COORD_TEXTURE2D_X_LOD(coord, 0), offset).r;
|
|
}
|
|
|
|
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;
|
|
DecodeFromNormalBuffer(coord, normalData);
|
|
return normalData.normalWS;
|
|
}
|
|
|
|
RW_TEXTURE2D_X(float, _OcclusionTexture);
|
|
|
|
void FFX_CACAO_Apply_StoreOutput(uint2 coord, float val)
|
|
{
|
|
_OcclusionTexture[COORD_TEXTURE2D_X(coord)] = 1.0 - val;
|
|
}
|
|
|
|
void FFX_CACAO_BilateralUpscale_StoreOutput(uint2 coord, int2 offset, float val)
|
|
{
|
|
_OcclusionTexture[COORD_TEXTURE2D_X(coord + offset)] = 1.0 - val;
|
|
}
|