44 lines
2.1 KiB
HLSL
44 lines
2.1 KiB
HLSL
#define _UpsampleTolerance 1e-7f
|
|
#define _NoiseFilterStrength 0.99999f
|
|
|
|
// This table references the set of pixels that are used for bilateral upscale based on the expected order
|
|
static const int2 UpscaleBilateralPixels[16] = {int2(0, 0), int2(0, -1), int2(-1, -1), int2(-1, 0)
|
|
, int2(0, 0), int2(0, -1), int2(1, -1), int2(1, 0)
|
|
, int2(0, 0) , int2(-1, 0), int2(-1, 1), int2(0, 1)
|
|
, int2(0, 0), int2(1, 0), int2(1, 1), int2(0, 1), };
|
|
|
|
// THe bilateral upscale fonction (color3 version)
|
|
float3 BilUpColor3(float HiDepth, float4 LowDepths, float3 lowValue0, float3 lowValue1, float3 lowValue2, float3 lowValue3)
|
|
{
|
|
float4 weights = float4(9, 3, 1, 3) / (abs(HiDepth - LowDepths) + _UpsampleTolerance);
|
|
float TotalWeight = dot(weights, 1) + _NoiseFilterStrength;
|
|
float3 WeightedSum = lowValue0 * weights.x
|
|
+ lowValue1 * weights.y
|
|
+ lowValue2 * weights.z
|
|
+ lowValue3 * weights.w
|
|
+ _NoiseFilterStrength;
|
|
return WeightedSum / TotalWeight;
|
|
}
|
|
|
|
// THe bilateral upscale fonction (color4 version)
|
|
float4 BilUpColor(float HiDepth, float4 LowDepths, float4 lowValue0, float4 lowValue1, float4 lowValue2, float4 lowValue3)
|
|
{
|
|
float4 weights = float4(9, 3, 1, 3) / (abs(HiDepth - LowDepths) + _UpsampleTolerance);
|
|
float TotalWeight = dot(weights, 1) + _NoiseFilterStrength;
|
|
float4 WeightedSum = lowValue0 * weights.x
|
|
+ lowValue1 * weights.y
|
|
+ lowValue2 * weights.z
|
|
+ lowValue3 * weights.w
|
|
+ _NoiseFilterStrength;
|
|
return WeightedSum / TotalWeight;
|
|
}
|
|
|
|
// THe bilateral upscale fonction (single channel version)
|
|
float BilUpSingle(float HiDepth, float4 LowDepths, float4 lowValue)
|
|
{
|
|
float4 weights = float4(9, 3, 1, 3) / (abs(HiDepth - LowDepths) + _UpsampleTolerance);
|
|
float TotalWeight = dot(weights, 1) + _NoiseFilterStrength;
|
|
float WeightedSum = dot(lowValue, weights) + _NoiseFilterStrength;
|
|
return WeightedSum / TotalWeight;
|
|
}
|