|
|
|
@ -9,56 +9,31 @@ |
|
|
|
// |
|
|
|
//============================================================================================================ |
|
|
|
|
|
|
|
precision mediump float; |
|
|
|
precision highp int; |
|
|
|
//precision mediump float; |
|
|
|
//precision highp int; |
|
|
|
|
|
|
|
float FastLanczos(float base) |
|
|
|
{ |
|
|
|
float y = base - 1.0f; |
|
|
|
float y2 = y * y; |
|
|
|
float y_temp = 0.75f * y + y2; |
|
|
|
return y_temp * y2; |
|
|
|
} |
|
|
|
|
|
|
|
layout(location = 0) out mediump vec4 Output; |
|
|
|
layout(location = 0) in highp vec2 texCoord; |
|
|
|
|
|
|
|
layout(set = 0, binding = 1) uniform mediump sampler2D PrevOutput; |
|
|
|
layout(set = 0, binding = 2) uniform mediump sampler2D MotionDepthClipAlphaBuffer; |
|
|
|
layout(set = 0, binding = 3) uniform mediump sampler2D InputColor; |
|
|
|
TYPED_TEXTURE2D_X(half4, PrevOutput); |
|
|
|
TYPED_TEXTURE2D_X(half4, MotionDepthClipAlphaBuffer); |
|
|
|
TYPED_TEXTURE2D_X(half4, InputColor); |
|
|
|
|
|
|
|
layout(std140, set = 0, binding = 0) uniform readonly Params |
|
|
|
void sgsr2_upscale(v2f_img i, out half4 Output: SV_Target) |
|
|
|
{ |
|
|
|
highp vec4 clipToPrevClip[4]; |
|
|
|
highp vec2 renderSize; |
|
|
|
highp vec2 outputSize; |
|
|
|
highp vec2 renderSizeRcp; |
|
|
|
highp vec2 outputSizeRcp; |
|
|
|
highp vec2 jitterOffset; |
|
|
|
highp vec2 scaleRatio; |
|
|
|
highp float cameraFovAngleHor; |
|
|
|
highp float minLerpContribution; |
|
|
|
highp float reset; |
|
|
|
uint bSameCamera; |
|
|
|
} params; |
|
|
|
const half2 texCoord = i.uv; |
|
|
|
half Biasmax_viewportXScale = scaleRatio.x; |
|
|
|
half scalefactor = scaleRatio.y; |
|
|
|
|
|
|
|
void main() |
|
|
|
{ |
|
|
|
float Biasmax_viewportXScale = params.scaleRatio.x; |
|
|
|
float scalefactor = params.scaleRatio.y; |
|
|
|
|
|
|
|
highp vec2 Hruv = texCoord; |
|
|
|
float2 Hruv = texCoord; |
|
|
|
|
|
|
|
highp vec2 Jitteruv; |
|
|
|
Jitteruv.x = clamp(Hruv.x + (params.jitterOffset.x * params.outputSizeRcp.x), 0.0, 1.0); |
|
|
|
Jitteruv.y = clamp(Hruv.y + (params.jitterOffset.y * params.outputSizeRcp.y), 0.0, 1.0); |
|
|
|
float2 Jitteruv; |
|
|
|
Jitteruv.x = clamp(Hruv.x + (jitterOffset.x * displaySizeRcp.x), 0.0, 1.0); |
|
|
|
Jitteruv.y = clamp(Hruv.y + (jitterOffset.y * displaySizeRcp.y), 0.0, 1.0); |
|
|
|
|
|
|
|
highp ivec2 InputPos = ivec2(Jitteruv * params.renderSize); |
|
|
|
int2 InputPos = int2(Jitteruv * renderSize); |
|
|
|
|
|
|
|
highp vec3 mda = textureLod(MotionDepthClipAlphaBuffer, Jitteruv, 0.0).xyz; |
|
|
|
highp vec2 Motion = mda.xy; |
|
|
|
float3 mda = SAMPLE_TEXTURE2D_X_LOD(MotionDepthClipAlphaBuffer, S_LINEAR_CLAMP, Jitteruv, 0.0).xyz; |
|
|
|
float2 Motion = mda.xy; |
|
|
|
|
|
|
|
highp vec2 PrevUV; |
|
|
|
float2 PrevUV; |
|
|
|
PrevUV.x = clamp(-0.5 * Motion.x + Hruv.x, 0.0, 1.0); |
|
|
|
#ifdef REQUEST_NDC_Y_UP |
|
|
|
PrevUV.y = clamp(0.5 * Motion.y + Hruv.y, 0.0, 1.0); |
|
|
|
@ -66,110 +41,110 @@ void main() |
|
|
|
PrevUV.y = clamp(-0.5 * Motion.y + Hruv.y, 0.0, 1.0); |
|
|
|
#endif |
|
|
|
|
|
|
|
float depthfactor = mda.z; |
|
|
|
half depthfactor = mda.z; |
|
|
|
|
|
|
|
vec3 HistoryColor = textureLod(PrevOutput, PrevUV, 0.0).xyz; |
|
|
|
half3 HistoryColor = SAMPLE_TEXTURE2D_X_LOD(PrevOutput, S_LINEAR_CLAMP, PrevUV, 0.0).xyz; |
|
|
|
|
|
|
|
/////upsample and compute box |
|
|
|
vec4 Upsampledcw = vec4(0.0); |
|
|
|
float biasmax = Biasmax_viewportXScale ; |
|
|
|
float biasmin = max(1.0f, 0.3 + 0.3 * biasmax); |
|
|
|
float biasfactor = 0.25f * depthfactor; |
|
|
|
float kernelbias = mix(biasmax, biasmin, biasfactor); |
|
|
|
float motion_viewport_len = length(Motion * params.outputSize); |
|
|
|
float curvebias = mix(-2.0, -3.0, clamp(motion_viewport_len * 0.02, 0.0, 1.0)); |
|
|
|
|
|
|
|
vec3 rectboxcenter = vec3(0.0); |
|
|
|
vec3 rectboxvar = vec3(0.0); |
|
|
|
float rectboxweight = 0.0; |
|
|
|
highp vec2 srcpos = vec2(InputPos) + vec2(0.5) - params.jitterOffset; |
|
|
|
half4 Upsampledcw = 0.0f; |
|
|
|
half biasmax = Biasmax_viewportXScale ; |
|
|
|
half biasmin = max(1.0f, 0.3 + 0.3 * biasmax); |
|
|
|
half biasfactor = 0.25f * depthfactor; |
|
|
|
half kernelbias = lerp(biasmax, biasmin, biasfactor); |
|
|
|
half motion_viewport_len = length(Motion * displaySize); |
|
|
|
half curvebias = lerp(-2.0, -3.0, clamp(motion_viewport_len * 0.02, 0.0, 1.0)); |
|
|
|
|
|
|
|
half3 rectboxcenter = 0.0f; |
|
|
|
half3 rectboxvar = 0.0f; |
|
|
|
half rectboxweight = 0.0; |
|
|
|
float2 srcpos = half2(InputPos) + 0.5f - jitterOffset; |
|
|
|
|
|
|
|
kernelbias *= 0.5f; |
|
|
|
float kernelbias2 = kernelbias * kernelbias; |
|
|
|
vec2 srcpos_srcOutputPos = srcpos - Hruv * params.renderSize; //srcOutputPos = Hruv * params.renderSize; |
|
|
|
vec3 rectboxmin; |
|
|
|
vec3 rectboxmax; |
|
|
|
vec3 topMid = texelFetch(InputColor, InputPos + ivec2(0, 1), 0).xyz; |
|
|
|
half kernelbias2 = kernelbias * kernelbias; |
|
|
|
half2 srcpos_srcOutputPos = srcpos - Hruv * renderSize; //srcOutputPos = Hruv * params.renderSize; |
|
|
|
half3 rectboxmin; |
|
|
|
half3 rectboxmax; |
|
|
|
half3 topMid = LOAD_TEXTURE2D_X(InputColor, InputPos + int2(0, 1)).xyz; |
|
|
|
{ |
|
|
|
|
|
|
|
vec3 samplecolor = topMid; |
|
|
|
vec2 baseoffset = srcpos_srcOutputPos + vec2(0.0, 1.0); |
|
|
|
float baseoffset_dot = dot(baseoffset, baseoffset); |
|
|
|
float base = clamp(baseoffset_dot * kernelbias2, 0.0f, 1.0f); |
|
|
|
float weight = FastLanczos(base); |
|
|
|
Upsampledcw += vec4(samplecolor * weight, weight); |
|
|
|
float boxweight = exp(baseoffset_dot * curvebias); |
|
|
|
half3 samplecolor = topMid; |
|
|
|
half2 baseoffset = srcpos_srcOutputPos + half2(0.0, 1.0); |
|
|
|
half baseoffset_dot = dot(baseoffset, baseoffset); |
|
|
|
half base = clamp(baseoffset_dot * kernelbias2, 0.0f, 1.0f); |
|
|
|
half weight = FastLanczos(base); |
|
|
|
Upsampledcw += half4(samplecolor * weight, weight); |
|
|
|
half boxweight = exp(baseoffset_dot * curvebias); |
|
|
|
rectboxmin = samplecolor; |
|
|
|
rectboxmax = samplecolor; |
|
|
|
vec3 wsample = samplecolor * boxweight; |
|
|
|
half3 wsample = samplecolor * boxweight; |
|
|
|
rectboxcenter += wsample; |
|
|
|
rectboxvar += (samplecolor * wsample); |
|
|
|
rectboxweight += boxweight; |
|
|
|
} |
|
|
|
vec3 rightMid = texelFetch(InputColor, InputPos + ivec2(1, 0), 0).xyz; |
|
|
|
half3 rightMid = LOAD_TEXTURE2D_X(InputColor, InputPos + int2(1, 0)).xyz; |
|
|
|
{ |
|
|
|
|
|
|
|
vec3 samplecolor = rightMid; |
|
|
|
vec2 baseoffset = srcpos_srcOutputPos + vec2(1.0, 0.0); |
|
|
|
float baseoffset_dot = dot(baseoffset, baseoffset); |
|
|
|
float base = clamp(baseoffset_dot * kernelbias2, 0.0f, 1.0f); |
|
|
|
float weight = FastLanczos(base); |
|
|
|
Upsampledcw += vec4(samplecolor * weight, weight); |
|
|
|
float boxweight = exp(baseoffset_dot * curvebias); |
|
|
|
half3 samplecolor = rightMid; |
|
|
|
half2 baseoffset = srcpos_srcOutputPos + half2(1.0, 0.0); |
|
|
|
half baseoffset_dot = dot(baseoffset, baseoffset); |
|
|
|
half base = clamp(baseoffset_dot * kernelbias2, 0.0f, 1.0f); |
|
|
|
half weight = FastLanczos(base); |
|
|
|
Upsampledcw += half4(samplecolor * weight, weight); |
|
|
|
half boxweight = exp(baseoffset_dot * curvebias); |
|
|
|
rectboxmin = min(rectboxmin, samplecolor); |
|
|
|
rectboxmax = max(rectboxmax, samplecolor); |
|
|
|
vec3 wsample = samplecolor * boxweight; |
|
|
|
half3 wsample = samplecolor * boxweight; |
|
|
|
rectboxcenter += wsample; |
|
|
|
rectboxvar += (samplecolor * wsample); |
|
|
|
rectboxweight += boxweight; |
|
|
|
} |
|
|
|
vec3 leftMid = texelFetch(InputColor, InputPos + ivec2(-1, 0) , 0).xyz; |
|
|
|
half3 leftMid = LOAD_TEXTURE2D_X(InputColor, InputPos + int2(-1, 0)).xyz; |
|
|
|
{ |
|
|
|
|
|
|
|
vec3 samplecolor = leftMid; |
|
|
|
vec2 baseoffset = srcpos_srcOutputPos + vec2(-1.0, 0.0); |
|
|
|
float baseoffset_dot = dot(baseoffset, baseoffset); |
|
|
|
float base = clamp(baseoffset_dot * kernelbias2, 0.0f, 1.0f); |
|
|
|
float weight = FastLanczos(base); |
|
|
|
Upsampledcw += vec4(samplecolor * weight, weight); |
|
|
|
float boxweight = exp(baseoffset_dot * curvebias); |
|
|
|
half3 samplecolor = leftMid; |
|
|
|
half2 baseoffset = srcpos_srcOutputPos + half2(-1.0, 0.0); |
|
|
|
half baseoffset_dot = dot(baseoffset, baseoffset); |
|
|
|
half base = clamp(baseoffset_dot * kernelbias2, 0.0f, 1.0f); |
|
|
|
half weight = FastLanczos(base); |
|
|
|
Upsampledcw += half4(samplecolor * weight, weight); |
|
|
|
half boxweight = exp(baseoffset_dot * curvebias); |
|
|
|
rectboxmin = min(rectboxmin, samplecolor); |
|
|
|
rectboxmax = max(rectboxmax, samplecolor); |
|
|
|
vec3 wsample = samplecolor * boxweight; |
|
|
|
half3 wsample = samplecolor * boxweight; |
|
|
|
rectboxcenter += wsample; |
|
|
|
rectboxvar += (samplecolor * wsample); |
|
|
|
rectboxweight += boxweight; |
|
|
|
} |
|
|
|
vec3 centerMid = texelFetch(InputColor, InputPos + ivec2(0, 0) , 0).xyz; |
|
|
|
half3 centerMid = LOAD_TEXTURE2D_X(InputColor, InputPos + int2(0, 0)).xyz; |
|
|
|
{ |
|
|
|
|
|
|
|
vec3 samplecolor = centerMid; |
|
|
|
vec2 baseoffset = srcpos_srcOutputPos; |
|
|
|
float baseoffset_dot = dot(baseoffset, baseoffset); |
|
|
|
float base = clamp(baseoffset_dot * kernelbias2, 0.0f, 1.0f); |
|
|
|
float weight = FastLanczos(base); |
|
|
|
Upsampledcw += vec4(samplecolor * weight, weight); |
|
|
|
float boxweight = exp(baseoffset_dot * curvebias); |
|
|
|
half3 samplecolor = centerMid; |
|
|
|
half2 baseoffset = srcpos_srcOutputPos; |
|
|
|
half baseoffset_dot = dot(baseoffset, baseoffset); |
|
|
|
half base = clamp(baseoffset_dot * kernelbias2, 0.0f, 1.0f); |
|
|
|
half weight = FastLanczos(base); |
|
|
|
Upsampledcw += half4(samplecolor * weight, weight); |
|
|
|
half boxweight = exp(baseoffset_dot * curvebias); |
|
|
|
rectboxmin = min(rectboxmin, samplecolor); |
|
|
|
rectboxmax = max(rectboxmax, samplecolor); |
|
|
|
vec3 wsample = samplecolor * boxweight; |
|
|
|
half3 wsample = samplecolor * boxweight; |
|
|
|
rectboxcenter += wsample; |
|
|
|
rectboxvar += (samplecolor * wsample); |
|
|
|
rectboxweight += boxweight; |
|
|
|
} |
|
|
|
vec3 btmMid = texelFetch(InputColor, InputPos + ivec2(0, -1) , 0).xyz; |
|
|
|
half3 btmMid = LOAD_TEXTURE2D_X(InputColor, InputPos + int2(0, -1)).xyz; |
|
|
|
{ |
|
|
|
|
|
|
|
vec3 samplecolor = btmMid; |
|
|
|
vec2 baseoffset = srcpos_srcOutputPos + vec2(0.0, -1.0); |
|
|
|
float baseoffset_dot = dot(baseoffset, baseoffset); |
|
|
|
float base = clamp(baseoffset_dot * kernelbias2, 0.0f, 1.0f); |
|
|
|
float weight = FastLanczos(base); |
|
|
|
Upsampledcw += vec4(samplecolor * weight, weight); |
|
|
|
float boxweight = exp(baseoffset_dot * curvebias); |
|
|
|
half3 samplecolor = btmMid; |
|
|
|
half2 baseoffset = srcpos_srcOutputPos + half2(0.0, -1.0); |
|
|
|
half baseoffset_dot = dot(baseoffset, baseoffset); |
|
|
|
half base = clamp(baseoffset_dot * kernelbias2, 0.0f, 1.0f); |
|
|
|
half weight = FastLanczos(base); |
|
|
|
Upsampledcw += half4(samplecolor * weight, weight); |
|
|
|
half boxweight = exp(baseoffset_dot * curvebias); |
|
|
|
rectboxmin = min(rectboxmin, samplecolor); |
|
|
|
rectboxmax = max(rectboxmax, samplecolor); |
|
|
|
vec3 wsample = samplecolor * boxweight; |
|
|
|
half3 wsample = samplecolor * boxweight; |
|
|
|
rectboxcenter += wsample; |
|
|
|
rectboxvar += (samplecolor * wsample); |
|
|
|
rectboxweight += boxweight; |
|
|
|
@ -179,66 +154,66 @@ void main() |
|
|
|
if (false) //maybe disable this for ultra performance, true could generate more realistic output |
|
|
|
{ |
|
|
|
{ |
|
|
|
vec3 topRight = texelFetch(InputColor, InputPos + ivec2(1, 1), 0).xyz; |
|
|
|
vec3 samplecolor = topRight; |
|
|
|
vec2 baseoffset = srcpos_srcOutputPos + vec2(1.0, 1.0); |
|
|
|
float baseoffset_dot = dot(baseoffset, baseoffset); |
|
|
|
float base = clamp(baseoffset_dot * kernelbias2, 0.0, 1.0); |
|
|
|
float weight = FastLanczos(base); |
|
|
|
Upsampledcw += vec4(samplecolor * weight, weight); |
|
|
|
float boxweight = exp(baseoffset_dot * curvebias); |
|
|
|
half3 topRight = LOAD_TEXTURE2D_X(InputColor, InputPos + int2(1, 1)).xyz; |
|
|
|
half3 samplecolor = topRight; |
|
|
|
half2 baseoffset = srcpos_srcOutputPos + half2(1.0, 1.0); |
|
|
|
half baseoffset_dot = dot(baseoffset, baseoffset); |
|
|
|
half base = clamp(baseoffset_dot * kernelbias2, 0.0, 1.0); |
|
|
|
half weight = FastLanczos(base); |
|
|
|
Upsampledcw += half4(samplecolor * weight, weight); |
|
|
|
half boxweight = exp(baseoffset_dot * curvebias); |
|
|
|
rectboxmin = min(rectboxmin, samplecolor); |
|
|
|
rectboxmax = max(rectboxmax, samplecolor); |
|
|
|
vec3 wsample = samplecolor * boxweight; |
|
|
|
half3 wsample = samplecolor * boxweight; |
|
|
|
rectboxcenter += wsample; |
|
|
|
rectboxvar += (samplecolor * wsample); |
|
|
|
rectboxweight += boxweight; |
|
|
|
} |
|
|
|
{ |
|
|
|
vec3 topLeft = texelFetch(InputColor, InputPos + ivec2(-1, 1), 0).xyz; |
|
|
|
vec3 samplecolor = topLeft; |
|
|
|
vec2 baseoffset = srcpos_srcOutputPos + vec2(-1.0, 1.0); |
|
|
|
float baseoffset_dot = dot(baseoffset, baseoffset); |
|
|
|
float base = clamp(baseoffset_dot * kernelbias2, 0.0f, 1.0f); |
|
|
|
float weight = FastLanczos(base); |
|
|
|
Upsampledcw += vec4(samplecolor * weight, weight); |
|
|
|
float boxweight = exp(baseoffset_dot * curvebias); |
|
|
|
half3 topLeft = LOAD_TEXTURE2D_X(InputColor, InputPos + int2(-1, 1)).xyz; |
|
|
|
half3 samplecolor = topLeft; |
|
|
|
half2 baseoffset = srcpos_srcOutputPos + half2(-1.0, 1.0); |
|
|
|
half baseoffset_dot = dot(baseoffset, baseoffset); |
|
|
|
half base = clamp(baseoffset_dot * kernelbias2, 0.0f, 1.0f); |
|
|
|
half weight = FastLanczos(base); |
|
|
|
Upsampledcw += half4(samplecolor * weight, weight); |
|
|
|
half boxweight = exp(baseoffset_dot * curvebias); |
|
|
|
rectboxmin = min(rectboxmin, samplecolor); |
|
|
|
rectboxmax = max(rectboxmax, samplecolor); |
|
|
|
vec3 wsample = samplecolor * boxweight; |
|
|
|
half3 wsample = samplecolor * boxweight; |
|
|
|
rectboxcenter += wsample; |
|
|
|
rectboxvar += (samplecolor * wsample); |
|
|
|
rectboxweight += boxweight; |
|
|
|
} |
|
|
|
{ |
|
|
|
vec3 btmRight = texelFetch(InputColor, InputPos + ivec2(1, -1) , 0).xyz; |
|
|
|
vec3 samplecolor = btmRight; |
|
|
|
vec2 baseoffset = srcpos_srcOutputPos + vec2(1.0, -1.0); |
|
|
|
float baseoffset_dot = dot(baseoffset, baseoffset); |
|
|
|
float base = clamp(baseoffset_dot * kernelbias2, 0.0f, 1.0f); |
|
|
|
float weight = FastLanczos(base); |
|
|
|
Upsampledcw += vec4(samplecolor * weight, weight); |
|
|
|
float boxweight = exp(baseoffset_dot * curvebias); |
|
|
|
half3 btmRight = LOAD_TEXTURE2D_X(InputColor, InputPos + int2(1, -1)).xyz; |
|
|
|
half3 samplecolor = btmRight; |
|
|
|
half2 baseoffset = srcpos_srcOutputPos + half2(1.0, -1.0); |
|
|
|
half baseoffset_dot = dot(baseoffset, baseoffset); |
|
|
|
half base = clamp(baseoffset_dot * kernelbias2, 0.0f, 1.0f); |
|
|
|
half weight = FastLanczos(base); |
|
|
|
Upsampledcw += half4(samplecolor * weight, weight); |
|
|
|
half boxweight = exp(baseoffset_dot * curvebias); |
|
|
|
rectboxmin = min(rectboxmin, samplecolor); |
|
|
|
rectboxmax = max(rectboxmax, samplecolor); |
|
|
|
vec3 wsample = samplecolor * boxweight; |
|
|
|
half3 wsample = samplecolor * boxweight; |
|
|
|
rectboxcenter += wsample; |
|
|
|
rectboxvar += (samplecolor * wsample); |
|
|
|
rectboxweight += boxweight; |
|
|
|
} |
|
|
|
|
|
|
|
{ |
|
|
|
vec3 btmLeft = texelFetch(InputColor, InputPos + ivec2(-1, -1) , 0).xyz; |
|
|
|
vec3 samplecolor = btmLeft; |
|
|
|
vec2 baseoffset = srcpos_srcOutputPos + vec2(-1.0, -1.0); |
|
|
|
float baseoffset_dot = dot(baseoffset, baseoffset); |
|
|
|
float base = clamp(baseoffset_dot * kernelbias2, 0.0f, 1.0f); |
|
|
|
float weight = FastLanczos(base); |
|
|
|
Upsampledcw += vec4(samplecolor * weight, weight); |
|
|
|
float boxweight = exp(baseoffset_dot * curvebias); |
|
|
|
half3 btmLeft = LOAD_TEXTURE2D_X(InputColor, InputPos + int2(-1, -1)).xyz; |
|
|
|
half3 samplecolor = btmLeft; |
|
|
|
half2 baseoffset = srcpos_srcOutputPos + half2(-1.0, -1.0); |
|
|
|
half baseoffset_dot = dot(baseoffset, baseoffset); |
|
|
|
half base = clamp(baseoffset_dot * kernelbias2, 0.0f, 1.0f); |
|
|
|
half weight = FastLanczos(base); |
|
|
|
Upsampledcw += half4(samplecolor * weight, weight); |
|
|
|
half boxweight = exp(baseoffset_dot * curvebias); |
|
|
|
rectboxmin = min(rectboxmin, samplecolor); |
|
|
|
rectboxmax = max(rectboxmax, samplecolor); |
|
|
|
vec3 wsample = samplecolor * boxweight; |
|
|
|
half3 wsample = samplecolor * boxweight; |
|
|
|
rectboxcenter += wsample; |
|
|
|
rectboxvar += (samplecolor * wsample); |
|
|
|
rectboxweight += boxweight; |
|
|
|
@ -250,37 +225,36 @@ void main() |
|
|
|
rectboxvar *= rectboxweight; |
|
|
|
rectboxvar = sqrt(abs(rectboxvar - rectboxcenter * rectboxcenter)); |
|
|
|
|
|
|
|
Upsampledcw.xyz = clamp(Upsampledcw.xyz / Upsampledcw.w, rectboxmin-vec3(0.075), rectboxmax+vec3(0.075)); |
|
|
|
Upsampledcw.xyz = clamp(Upsampledcw.xyz / Upsampledcw.w, rectboxmin-0.075f, rectboxmax+0.075f); |
|
|
|
Upsampledcw.w = Upsampledcw.w * (1.0f / 3.0f) ; |
|
|
|
|
|
|
|
float baseupdate = 1.0f - depthfactor; |
|
|
|
baseupdate = min(baseupdate, mix(baseupdate, Upsampledcw.w *10.0f, clamp(10.0f* motion_viewport_len, 0.0, 1.0))); |
|
|
|
baseupdate = min(baseupdate, mix(baseupdate, Upsampledcw.w, clamp(motion_viewport_len *0.05f, 0.0, 1.0))); |
|
|
|
float basealpha = baseupdate; |
|
|
|
half baseupdate = 1.0f - 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, clamp(motion_viewport_len *0.05f, 0.0, 1.0))); |
|
|
|
half basealpha = baseupdate; |
|
|
|
|
|
|
|
const float EPSILON = 1.192e-07f; |
|
|
|
float boxscale = max(depthfactor, clamp(motion_viewport_len * 0.05f, 0.0, 1.0)); |
|
|
|
float boxsize = mix(scalefactor, 1.0f, boxscale); |
|
|
|
vec3 sboxvar = rectboxvar * boxsize; |
|
|
|
vec3 boxmin = rectboxcenter - sboxvar; |
|
|
|
vec3 boxmax = rectboxcenter + sboxvar; |
|
|
|
half boxscale = max(depthfactor, clamp(motion_viewport_len * 0.05f, 0.0, 1.0)); |
|
|
|
half boxsize = lerp(scalefactor, 1.0f, boxscale); |
|
|
|
half3 sboxvar = rectboxvar * boxsize; |
|
|
|
half3 boxmin = rectboxcenter - sboxvar; |
|
|
|
half3 boxmax = rectboxcenter + sboxvar; |
|
|
|
rectboxmax = min(rectboxmax, boxmax); |
|
|
|
rectboxmin = max(rectboxmin, boxmin); |
|
|
|
|
|
|
|
vec3 clampedcolor = clamp(HistoryColor, rectboxmin, rectboxmax); |
|
|
|
float startLerpValue = params.minLerpContribution; |
|
|
|
half3 clampedcolor = clamp(HistoryColor, rectboxmin, rectboxmax); |
|
|
|
half startLerpValue = minLerpContribution; |
|
|
|
if ((abs(mda.x) + abs(mda.y)) > 0.000001) startLerpValue = 0.0; |
|
|
|
float lerpcontribution = (any(greaterThan(rectboxmin, HistoryColor)) || any(greaterThan(HistoryColor, rectboxmax))) ? startLerpValue : 1.0f; |
|
|
|
half lerpcontribution = (any(rectboxmin > HistoryColor) || any(HistoryColor > rectboxmax)) ? startLerpValue : 1.0f; |
|
|
|
|
|
|
|
HistoryColor = mix(clampedcolor, HistoryColor, clamp(lerpcontribution, 0.0, 1.0)); |
|
|
|
float basemin = min(basealpha, 0.1f); |
|
|
|
basealpha = mix(basemin, basealpha, clamp(lerpcontribution, 0.0, 1.0)); |
|
|
|
HistoryColor = lerp(clampedcolor, HistoryColor, clamp(lerpcontribution, 0.0, 1.0)); |
|
|
|
half basemin = min(basealpha, 0.1f); |
|
|
|
basealpha = lerp(basemin, basealpha, clamp(lerpcontribution, 0.0, 1.0)); |
|
|
|
|
|
|
|
////blend color |
|
|
|
float alphasum = max(EPSILON, basealpha + Upsampledcw.w); |
|
|
|
float alpha = clamp(Upsampledcw.w / alphasum + params.reset, 0.0, 1.0); |
|
|
|
half alphasum = max(EPSILON, basealpha + Upsampledcw.w); |
|
|
|
half alpha = clamp(Upsampledcw.w / alphasum + reset, 0.0, 1.0); |
|
|
|
|
|
|
|
Upsampledcw.xyz = mix(HistoryColor, Upsampledcw.xyz, alpha); |
|
|
|
Upsampledcw.xyz = lerp(HistoryColor, Upsampledcw.xyz, alpha); |
|
|
|
|
|
|
|
Output = vec4(Upsampledcw.xyz, 0.0); |
|
|
|
Output = half4(Upsampledcw.xyz, 0.0); |
|
|
|
} |