@ -1,3 +1,5 @@
#pragma kernel CS
//============================================================================================================
//============================================================================================================
//
//
//
//
@ -8,23 +10,23 @@
float FastLanczos(float base)
float FastLanczos(float base)
{
{
float y = base - 1.0f;
float y2 = y * y;
float y_temp = 0.75f * y + y2;
return y_temp * y2;
float y = base - 1.0f;
float y2 = y * y;
float y_temp = 0.75f * y + y2;
return y_temp * y2;
}
}
float3 DecodeColor(uint sample32)
float3 DecodeColor(uint sample32)
{
{
uint x11 = sample32 >> 21u;
uint y11 = sample32 & (2047u << 10u);
uint z10 = sample32 & 1023u;
float3 samplecolor;
samplecolor.x = (float(x11) * (1.0 / 2047.5));
samplecolor.y = (float(y11) * (4.76953602e-7)) - 0.5;
samplecolor.z = (float(z10) * (1.0 / 1023.5)) - 0.5;
uint x11 = sample32 >> 21u;
uint y11 = sample32 & (2047u << 10u);
uint z10 = sample32 & 1023u;
float3 samplecolor;
samplecolor.x = (float(x11) * (1.0 / 2047.5));
samplecolor.y = (float(y11) * (4.76953602e-7)) - 0.5;
samplecolor.z = (float(z10) * (1.0 / 1023.5)) - 0.5;
return samplecolor;
return samplecolor;
}
}
Texture2D PrevHistoryOutput : register(t0);
Texture2D PrevHistoryOutput : register(t0);
@ -266,9 +268,9 @@ void CS(uint3 globalInvocationID : SV_DispatchThreadID)
Upsampledcw.xyz = clamp(Upsampledcw.xyz / Upsampledcw.w, rectboxmin-0.05f, rectboxmax+0.05f);
Upsampledcw.xyz = clamp(Upsampledcw.xyz / Upsampledcw.w, rectboxmin-0.05f, rectboxmax+0.05f);
Upsampledcw.w = Upsampledcw.w * (1.0f / 3.0f) ;
Upsampledcw.w = Upsampledcw.w * (1.0f / 3.0f) ;
float tcontribute = history_value * clamp(rectboxvar.x * 10.0f, 0.0, 1.0);
float OneMinusWfactor = 1.0f - Wfactor;
tcontribute = tcontribute * OneMinusWfactor;
float tcontribute = history_value * clamp(rectboxvar.x * 10.0f, 0.0, 1.0);
float OneMinusWfactor = 1.0f - Wfactor;
tcontribute = tcontribute * OneMinusWfactor;
float baseupdate = OneMinusWfactor - OneMinusWfactor * depthfactor;
float baseupdate = OneMinusWfactor - OneMinusWfactor * depthfactor;
baseupdate = min(baseupdate, lerp(baseupdate, Upsampledcw.w *10.0f, clamp(10.0f* motion_viewport_len, 0.0, 1.0)));
baseupdate = min(baseupdate, lerp(baseupdate, Upsampledcw.w *10.0f, clamp(10.0f* motion_viewport_len, 0.0, 1.0)));
@ -285,9 +287,9 @@ void CS(uint3 globalInvocationID : SV_DispatchThreadID)
rectboxmin = max(rectboxmin, boxmin);
rectboxmin = max(rectboxmin, boxmin);
float3 clampedcolor = clamp(HistoryColor, rectboxmin, rectboxmax);
float3 clampedcolor = clamp(HistoryColor, rectboxmin, rectboxmax);
float lerpcontribution = (any(rectboxmin > HistoryColor) || any(HistoryColor > rectboxmax)) ? tcontribute : 1.0f;
lerpcontribution = lerpcontribution - lerpcontribution * sqrt(alphamask);
HistoryColor = lerp(clampedcolor, HistoryColor, clamp(lerpcontribution, 0.0, 1.0));
float lerpcontribution = (any(rectboxmin > HistoryColor) || any(HistoryColor > rectboxmax)) ? tcontribute : 1.0f;
lerpcontribution = lerpcontribution - lerpcontribution * sqrt(alphamask);
HistoryColor = lerp(clampedcolor, HistoryColor, clamp(lerpcontribution, 0.0, 1.0));
float basemin = min(basealpha, 0.1f);
float basemin = min(basealpha, 0.1f);
basealpha = lerp(basemin, basealpha, clamp(lerpcontribution, 0.0, 1.0));
basealpha = lerp(basemin, basealpha, clamp(lerpcontribution, 0.0, 1.0));