diff --git a/code/renderer/shaders/crp/mblur_blur.hlsl b/code/renderer/shaders/crp/mblur_blur.hlsl index 1a7c84a..33262f3 100644 --- a/code/renderer/shaders/crp/mblur_blur.hlsl +++ b/code/renderer/shaders/crp/mblur_blur.hlsl @@ -55,23 +55,34 @@ References: void ProcessSample( 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 - if(Zs - DepthThreshold < Zc && Vsl >= distTC) + if(Z0s - DepthThreshold < Zc) { - fgAccum += float4(C0s, 1) * W0d; - bgAccum += float4(C1s, 1); - alpha += 1.0; + if(Vsl >= distTC) + { + fgAccum += float4(C0s, 1) * W0d; + if(Z1s >= Zc) + { + bgAccum += float4(C1s, 1); + } + alpha += 1.0; + } } - else if(Zs >= Zc && Vcl >= distTC) + else if(Z0s + DepthThreshold >= Zc) { - bgAccum += float4(C0s, 1); + if(Vcl >= distTC) + { + bgAccum += float4(C0s, 1); + } } 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 TC1 = input.texCoords + i1 * tcStep; - [branch] - if(!Is01(TC0) || !Is01(TC1)) - { - continue; - } - uint2 packedSample0 = packedTexture.Load(uint3(TC0 * fullResSize, 0)); float2 V0s = UnpackHalf2(packedSample0.x); float V0sl = length(V0s); @@ -194,10 +199,17 @@ float4 ps(VOut input) : SV_Target float distTC1 = distance(TC1, input.texCoords); float W1d = max(dot(V1sn, dirn), 0.0); - ProcessSample(fgAccum, bgAccum, alpha, center, Z0s, Zc, V0sl, Vcl, distTC0, C0s, C1s, W0d); - ProcessSample(fgAccum, bgAccum, alpha, center, Z1s, Zc, V1sl, Vcl, distTC1, C1s, C0s, W1d); + if(Is01(TC0)) + { + 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)