mirror of
https://bitbucket.org/CPMADevs/cnq3
synced 2024-11-10 06:31:48 +00:00
fixed some motion blur artifacts
fixed: - sharp moving pixels at screen edges - static foreground meshes leaving a trail - static foreground meshes surrounded by sharp moving background pixels the last 2 items were very noticeable with view weapons the trade-off is that blurred silhouettes of foreground objects now look worse
This commit is contained in:
parent
ea3b071c58
commit
5c4cf3d720
1 changed files with 29 additions and 17 deletions
|
@ -55,23 +55,34 @@ References:
|
||||||
|
|
||||||
void ProcessSample(
|
void ProcessSample(
|
||||||
inout float4 fgAccum, inout float4 bgAccum, inout float alpha, inout float center,
|
inout float4 fgAccum, inout float4 bgAccum, inout float alpha, inout float center,
|
||||||
float Zs, float Zc, float Vsl, float Vcl, float distTC, float3 C0s, float3 C1s, float W0d)
|
float Z0s, float Z1s, float Zc, float Vsl, float Vcl, float distTC, float3 C0s, float3 C1s, float W0d)
|
||||||
{
|
{
|
||||||
const float DepthThreshold = 0.28; // 10mm assuming 56u == 2m
|
const float DepthThreshold = 0.28; // 10mm assuming 56u == 2m
|
||||||
|
|
||||||
if(Zs - DepthThreshold < Zc && Vsl >= distTC)
|
if(Z0s - DepthThreshold < Zc)
|
||||||
|
{
|
||||||
|
if(Vsl >= distTC)
|
||||||
{
|
{
|
||||||
fgAccum += float4(C0s, 1) * W0d;
|
fgAccum += float4(C0s, 1) * W0d;
|
||||||
|
if(Z1s >= Zc)
|
||||||
|
{
|
||||||
bgAccum += float4(C1s, 1);
|
bgAccum += float4(C1s, 1);
|
||||||
|
}
|
||||||
alpha += 1.0;
|
alpha += 1.0;
|
||||||
}
|
}
|
||||||
else if(Zs >= Zc && Vcl >= distTC)
|
}
|
||||||
|
else if(Z0s + DepthThreshold >= Zc)
|
||||||
|
{
|
||||||
|
if(Vcl >= distTC)
|
||||||
{
|
{
|
||||||
bgAccum += float4(C0s, 1);
|
bgAccum += float4(C0s, 1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
center += 1.0;
|
float bgness = saturate(0.5 * (Zc + DepthThreshold - Z0s) / DepthThreshold);
|
||||||
|
bgAccum += float4(C0s, 1) * bgness;
|
||||||
|
center += 1.0 - bgness;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,12 +181,6 @@ float4 ps(VOut input) : SV_Target
|
||||||
float2 TC0 = input.texCoords + i0 * tcStep;
|
float2 TC0 = input.texCoords + i0 * tcStep;
|
||||||
float2 TC1 = input.texCoords + i1 * tcStep;
|
float2 TC1 = input.texCoords + i1 * tcStep;
|
||||||
|
|
||||||
[branch]
|
|
||||||
if(!Is01(TC0) || !Is01(TC1))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint2 packedSample0 = packedTexture.Load(uint3(TC0 * fullResSize, 0));
|
uint2 packedSample0 = packedTexture.Load(uint3(TC0 * fullResSize, 0));
|
||||||
float2 V0s = UnpackHalf2(packedSample0.x);
|
float2 V0s = UnpackHalf2(packedSample0.x);
|
||||||
float V0sl = length(V0s);
|
float V0sl = length(V0s);
|
||||||
|
@ -194,10 +199,17 @@ float4 ps(VOut input) : SV_Target
|
||||||
float distTC1 = distance(TC1, input.texCoords);
|
float distTC1 = distance(TC1, input.texCoords);
|
||||||
float W1d = max(dot(V1sn, dirn), 0.0);
|
float W1d = max(dot(V1sn, dirn), 0.0);
|
||||||
|
|
||||||
ProcessSample(fgAccum, bgAccum, alpha, center, Z0s, Zc, V0sl, Vcl, distTC0, C0s, C1s, W0d);
|
if(Is01(TC0))
|
||||||
ProcessSample(fgAccum, bgAccum, alpha, center, Z1s, Zc, V1sl, Vcl, distTC1, C1s, C0s, W1d);
|
{
|
||||||
|
ProcessSample(fgAccum, bgAccum, alpha, center, Z0s, Z1s, Zc, V0sl, Vcl, distTC0, C0s, C1s, W0d);
|
||||||
|
realSampleCount++;
|
||||||
|
}
|
||||||
|
|
||||||
realSampleCount += 2;
|
if(Is01(TC1))
|
||||||
|
{
|
||||||
|
ProcessSample(fgAccum, bgAccum, alpha, center, Z1s, Z0s, Zc, V1sl, Vcl, distTC1, C1s, C0s, W1d);
|
||||||
|
realSampleCount++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fgAccum.w <= 0.0 || bgAccum.w <= 0.0)
|
if(fgAccum.w <= 0.0 || bgAccum.w <= 0.0)
|
||||||
|
|
Loading…
Reference in a new issue