9 changed files with 512 additions and 0 deletions
-
8Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/2_pass_fs.meta
-
51Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/2_pass_fs/sgsr2.shader
-
9Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/2_pass_fs/sgsr2.shader.meta
-
116Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/2_pass_fs/sgsr2_convert.hlsl
-
7Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/2_pass_fs/sgsr2_convert.hlsl.meta
-
286Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/2_pass_fs/sgsr2_upscale.hlsl
-
7Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/2_pass_fs/sgsr2_upscale.hlsl.meta
-
21Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/2_pass_fs/sgsr2_vertex.vs
-
7Packages/com.unity.postprocessing@3.2.2/PostProcessing/Runtime/Effects/Upscaling/SGSR2/Shaders/2_pass_fs/sgsr2_vertex.vs.meta
@ -0,0 +1,8 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 097742e23f344d0408435f99f89e1edb |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,51 @@ |
|||
Shader "TND/sgsr2_2pass_fs" |
|||
{ |
|||
Properties |
|||
{ |
|||
_MainTex ("Texture", 2D) = "white" {} |
|||
} |
|||
SubShader |
|||
{ |
|||
Cull Off ZWrite Off ZTest Always |
|||
|
|||
Pass // Convert |
|||
{ |
|||
CGPROGRAM |
|||
#pragma vertex vert_img |
|||
#pragma fragment frag |
|||
|
|||
#include "UnityCG.cginc" |
|||
|
|||
sampler2D _MainTex; |
|||
|
|||
fixed4 frag (v2f_img i) : SV_Target |
|||
{ |
|||
fixed4 col = tex2D(_MainTex, i.uv); |
|||
// just invert the colors |
|||
col.rgb = 1 - col.rgb; |
|||
return col; |
|||
} |
|||
ENDCG |
|||
} |
|||
|
|||
Pass // Upscale |
|||
{ |
|||
CGPROGRAM |
|||
#pragma vertex vert_img |
|||
#pragma fragment frag |
|||
|
|||
#include "UnityCG.cginc" |
|||
|
|||
sampler2D _MainTex; |
|||
|
|||
fixed4 frag (v2f_img i) : SV_Target |
|||
{ |
|||
fixed4 col = tex2D(_MainTex, i.uv); |
|||
// just invert the colors |
|||
col.rgb = 1 - col.rgb; |
|||
return col; |
|||
} |
|||
ENDCG |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,9 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 9e367486dadedbc4da8313a481aa8a27 |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
nonModifiableTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,116 @@ |
|||
#include "../sgsr2_birp.hlsl" |
|||
#include "../sgsr2_common.hlsl" |
|||
|
|||
//============================================================================================================ |
|||
// |
|||
// |
|||
// Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserved. |
|||
// SPDX-License-Identifier: BSD-3-Clause |
|||
// |
|||
//============================================================================================================ |
|||
|
|||
precision highp float; |
|||
precision highp int; |
|||
|
|||
layout(location = 0) out vec4 MotionDepthClipAlphaBuffer; |
|||
layout(location = 0) in highp vec2 texCoord; |
|||
|
|||
layout(set = 0, binding = 1) uniform mediump sampler2D InputDepth; |
|||
layout(set = 0, binding = 2) uniform mediump sampler2D InputVelocity; |
|||
|
|||
layout(std140, set = 0, binding = 0) uniform Params |
|||
{ |
|||
vec4 clipToPrevClip[4]; |
|||
vec2 renderSize; |
|||
vec2 outputSize; |
|||
vec2 renderSizeRcp; |
|||
vec2 outputSizeRcp; |
|||
vec2 jitterOffset; |
|||
vec2 scaleRatio; |
|||
float cameraFovAngleHor; |
|||
float minLerpContribution; |
|||
float reset; |
|||
uint bSameCamera; |
|||
} params; |
|||
|
|||
vec2 decodeVelocityFromTexture(vec2 ev) { |
|||
const float inv_div = 1.0f / (0.499f * 0.5f); |
|||
vec2 dv; |
|||
dv.xy = ev.xy * inv_div - 32767.0f / 65535.0f * inv_div; |
|||
//dv.z = uintBitsToFloat((uint(round(ev.z * 65535.0f)) << 16) | uint(round(ev.w * 65535.0f))); |
|||
return dv; |
|||
} |
|||
|
|||
void main() |
|||
{ |
|||
uvec2 InputPos = uvec2(texCoord * params.renderSize); |
|||
vec2 gatherCoord = texCoord - vec2(0.5) * params.renderSizeRcp; |
|||
|
|||
|
|||
// texture gather to find nearest depth |
|||
// a b c d |
|||
// e f g h |
|||
// i j k l |
|||
// m n o p |
|||
//btmLeft mnji |
|||
//btmRight oplk |
|||
//topLeft efba |
|||
//topRight ghdc |
|||
|
|||
vec4 btmLeft = textureGather(InputDepth, gatherCoord, 0); |
|||
vec2 v10 = vec2(params.renderSizeRcp.x * 2.0f, 0.0); |
|||
vec4 btmRight = textureGather(InputDepth,(gatherCoord+v10), 0); |
|||
vec2 v12 = vec2(0.0, params.renderSizeRcp.y * 2.0f); |
|||
vec4 topLeft = textureGather(InputDepth,(gatherCoord+v12), 0); |
|||
vec2 v14 = vec2(params.renderSizeRcp.x * 2.0f, params.renderSizeRcp.y * 2.0f); |
|||
vec4 topRight = textureGather(InputDepth,(gatherCoord+v14), 0); |
|||
float maxC = min(min(min(btmLeft.z,btmRight.w),topLeft.y),topRight.x); |
|||
float btmLeft4 = min(min(min(btmLeft.y,btmLeft.x),btmLeft.z),btmLeft.w); |
|||
float btmLeftMax9 = min(topLeft.x,min(min(maxC,btmLeft4),btmRight.x)); |
|||
|
|||
float depthclip = 0.0; |
|||
if (maxC < 1.0 - 1.0e-05f) |
|||
{ |
|||
float btmRight4 = min(min(min(btmRight.y,btmRight.x),btmRight.z),btmRight.w); |
|||
float topLeft4 = min(min(min(topLeft.y,topLeft.x),topLeft.z),topLeft.w); |
|||
float topRight4 = min(min(min(topRight.y,topRight.x),topRight.z),topRight.w); |
|||
|
|||
float Wdepth = 0.0; |
|||
float Ksep = 1.37e-05f; |
|||
float Kfov = params.cameraFovAngleHor; |
|||
float diagonal_length = length(params.renderSize); |
|||
float Ksep_Kfov_diagonal = Ksep * Kfov * diagonal_length; |
|||
|
|||
float Depthsep = Ksep_Kfov_diagonal * (1.0 - maxC); |
|||
float EPSILON = 1.19e-07f; |
|||
Wdepth += clamp((Depthsep / (abs(maxC - btmLeft4) + EPSILON)), 0.0, 1.0); |
|||
Wdepth += clamp((Depthsep / (abs(maxC - btmRight4) + EPSILON)), 0.0, 1.0); |
|||
Wdepth += clamp((Depthsep / (abs(maxC - topLeft4) + EPSILON)), 0.0, 1.0); |
|||
Wdepth += clamp((Depthsep / (abs(maxC - topRight4) + EPSILON)), 0.0, 1.0); |
|||
depthclip = clamp(1.0f - Wdepth * 0.25, 0.0, 1.0); |
|||
} |
|||
|
|||
//refer to ue/fsr2 PostProcessFFX_FSR2ConvertVelocity.usf, and using nearest depth for dilated motion |
|||
|
|||
vec4 EncodedVelocity = texelFetch(InputVelocity, ivec2(InputPos), 0); |
|||
|
|||
vec2 motion; |
|||
if (EncodedVelocity.x > 0.0) |
|||
{ |
|||
motion = decodeVelocityFromTexture(EncodedVelocity.xy); |
|||
} |
|||
else |
|||
{ |
|||
#ifdef REQUEST_NDC_Y_UP |
|||
vec2 ScreenPos = vec2(2.0f * texCoord.x - 1.0f, 1.0f - 2.0f * texCoord.y); |
|||
#else |
|||
vec2 ScreenPos = vec2(2.0f * texCoord - 1.0f); |
|||
#endif |
|||
vec3 Position = vec3(ScreenPos, btmLeftMax9); //this_clip |
|||
vec4 PreClip = params.clipToPrevClip[3] + ((params.clipToPrevClip[2] * Position.z) + ((params.clipToPrevClip[1] * ScreenPos.y) + (params.clipToPrevClip[0] * ScreenPos.x))); |
|||
vec2 PreScreen = PreClip.xy / PreClip.w; |
|||
motion = Position.xy - PreScreen; |
|||
} |
|||
MotionDepthClipAlphaBuffer = vec4(motion, depthclip, 0.0); |
|||
|
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 3e8c4c408c337364291ae0e57dc25f28 |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,286 @@ |
|||
#include "../sgsr2_birp.hlsl" |
|||
#include "../sgsr2_common.hlsl" |
|||
|
|||
//============================================================================================================ |
|||
// |
|||
// |
|||
// Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserved. |
|||
// SPDX-License-Identifier: BSD-3-Clause |
|||
// |
|||
//============================================================================================================ |
|||
|
|||
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; |
|||
|
|||
layout(std140, set = 0, binding = 0) uniform readonly Params |
|||
{ |
|||
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; |
|||
|
|||
void main() |
|||
{ |
|||
float Biasmax_viewportXScale = params.scaleRatio.x; |
|||
float scalefactor = params.scaleRatio.y; |
|||
|
|||
highp vec2 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); |
|||
|
|||
highp ivec2 InputPos = ivec2(Jitteruv * params.renderSize); |
|||
|
|||
highp vec3 mda = textureLod(MotionDepthClipAlphaBuffer, Jitteruv, 0.0).xyz; |
|||
highp vec2 Motion = mda.xy; |
|||
|
|||
highp vec2 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); |
|||
#else |
|||
PrevUV.y = clamp(-0.5 * Motion.y + Hruv.y, 0.0, 1.0); |
|||
#endif |
|||
|
|||
float depthfactor = mda.z; |
|||
|
|||
vec3 HistoryColor = textureLod(PrevOutput, 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; |
|||
|
|||
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; |
|||
{ |
|||
|
|||
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); |
|||
rectboxmin = samplecolor; |
|||
rectboxmax = samplecolor; |
|||
vec3 wsample = samplecolor * boxweight; |
|||
rectboxcenter += wsample; |
|||
rectboxvar += (samplecolor * wsample); |
|||
rectboxweight += boxweight; |
|||
} |
|||
vec3 rightMid = texelFetch(InputColor, InputPos + ivec2(1, 0), 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); |
|||
rectboxmin = min(rectboxmin, samplecolor); |
|||
rectboxmax = max(rectboxmax, samplecolor); |
|||
vec3 wsample = samplecolor * boxweight; |
|||
rectboxcenter += wsample; |
|||
rectboxvar += (samplecolor * wsample); |
|||
rectboxweight += boxweight; |
|||
} |
|||
vec3 leftMid = texelFetch(InputColor, InputPos + ivec2(-1, 0) , 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); |
|||
rectboxmin = min(rectboxmin, samplecolor); |
|||
rectboxmax = max(rectboxmax, samplecolor); |
|||
vec3 wsample = samplecolor * boxweight; |
|||
rectboxcenter += wsample; |
|||
rectboxvar += (samplecolor * wsample); |
|||
rectboxweight += boxweight; |
|||
} |
|||
vec3 centerMid = texelFetch(InputColor, InputPos + ivec2(0, 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); |
|||
rectboxmin = min(rectboxmin, samplecolor); |
|||
rectboxmax = max(rectboxmax, samplecolor); |
|||
vec3 wsample = samplecolor * boxweight; |
|||
rectboxcenter += wsample; |
|||
rectboxvar += (samplecolor * wsample); |
|||
rectboxweight += boxweight; |
|||
} |
|||
vec3 btmMid = texelFetch(InputColor, InputPos + ivec2(0, -1) , 0).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); |
|||
rectboxmin = min(rectboxmin, samplecolor); |
|||
rectboxmax = max(rectboxmax, samplecolor); |
|||
vec3 wsample = samplecolor * boxweight; |
|||
rectboxcenter += wsample; |
|||
rectboxvar += (samplecolor * wsample); |
|||
rectboxweight += boxweight; |
|||
} |
|||
|
|||
//if (params.sameCameraFrmNum!=0u) //maybe disable this for ultra performance |
|||
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); |
|||
rectboxmin = min(rectboxmin, samplecolor); |
|||
rectboxmax = max(rectboxmax, samplecolor); |
|||
vec3 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); |
|||
rectboxmin = min(rectboxmin, samplecolor); |
|||
rectboxmax = max(rectboxmax, samplecolor); |
|||
vec3 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); |
|||
rectboxmin = min(rectboxmin, samplecolor); |
|||
rectboxmax = max(rectboxmax, samplecolor); |
|||
vec3 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); |
|||
rectboxmin = min(rectboxmin, samplecolor); |
|||
rectboxmax = max(rectboxmax, samplecolor); |
|||
vec3 wsample = samplecolor * boxweight; |
|||
rectboxcenter += wsample; |
|||
rectboxvar += (samplecolor * wsample); |
|||
rectboxweight += boxweight; |
|||
} |
|||
} |
|||
|
|||
rectboxweight = 1.0 / rectboxweight; |
|||
rectboxcenter *= rectboxweight; |
|||
rectboxvar *= rectboxweight; |
|||
rectboxvar = sqrt(abs(rectboxvar - rectboxcenter * rectboxcenter)); |
|||
|
|||
Upsampledcw.xyz = clamp(Upsampledcw.xyz / Upsampledcw.w, rectboxmin-vec3(0.075), rectboxmax+vec3(0.075)); |
|||
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; |
|||
|
|||
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; |
|||
rectboxmax = min(rectboxmax, boxmax); |
|||
rectboxmin = max(rectboxmin, boxmin); |
|||
|
|||
vec3 clampedcolor = clamp(HistoryColor, rectboxmin, rectboxmax); |
|||
float startLerpValue = params.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; |
|||
|
|||
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)); |
|||
|
|||
////blend color |
|||
float alphasum = max(EPSILON, basealpha + Upsampledcw.w); |
|||
float alpha = clamp(Upsampledcw.w / alphasum + params.reset, 0.0, 1.0); |
|||
|
|||
Upsampledcw.xyz = mix(HistoryColor, Upsampledcw.xyz, alpha); |
|||
|
|||
Output = vec4(Upsampledcw.xyz, 0.0); |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
fileFormatVersion: 2 |
|||
guid: b3f52eb20bad6124e8835caaa5938444 |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
@ -0,0 +1,21 @@ |
|||
#version 320 es |
|||
|
|||
//============================================================================================================ |
|||
// |
|||
// |
|||
// Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserved. |
|||
// SPDX-License-Identifier: BSD-3-Clause |
|||
// |
|||
//============================================================================================================ |
|||
|
|||
precision highp float; |
|||
precision highp int; |
|||
layout (location = 0) in vec3 vPosition; |
|||
layout (location = 1) in vec2 vTexCord; |
|||
|
|||
out vec2 texCoord; |
|||
void main() |
|||
{ |
|||
gl_Position = vec4(vPosition,1.0); |
|||
texCoord = vTexCord; |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 47316c9383c34b44c95bc0da4fad688e |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue