From 89132abafe36bd4bc1322fe95af3a452b7b18baa Mon Sep 17 00:00:00 2001 From: brimson Date: Wed, 25 May 2022 14:45:42 -0700 Subject: [PATCH] MInor optimization --- shaders/cMotionBlur.fx | 5 +++-- shaders/cOpticalFlow.fx | 5 +++-- shaders/kDatamosh.fx | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/shaders/cMotionBlur.fx b/shaders/cMotionBlur.fx index 09773b6..631a5c8 100644 --- a/shaders/cMotionBlur.fx +++ b/shaders/cMotionBlur.fx @@ -598,8 +598,9 @@ namespace Motion_Blur // [Ix^2+A IxIy] [U] = -[IxIt] // [IxIy Iy^2+A] [V] = -[IyIt] UVAverage.xy = (AreaGrad.xx * AreaAvg[0]) + (AreaGrad.yy * AreaAvg[1]) + (AreaGrad.zz * AreaAvg[2]) + (AreaGrad.ww * AreaAvg[3]); - OpticalFlow.x = Aii.x * ((Alpha * UVAverage.x) - (Aij * CenterAverage.y) - Bi.x); - OpticalFlow.y = Aii.y * ((Alpha * UVAverage.y) - (Aij * OpticalFlow.x) - Bi.y); + UVAverage.xy = UVAverage.xy * Alpha; + OpticalFlow.x = Aii.x * (UVAverage.x - (Aij * CenterAverage.y) - Bi.x); + OpticalFlow.y = Aii.y * (UVAverage.y - (Aij * OpticalFlow.x) - Bi.y); } #define LEVEL_PS(NAME, SAMPLER, LEVEL) \ diff --git a/shaders/cOpticalFlow.fx b/shaders/cOpticalFlow.fx index 14f8535..4b84c87 100644 --- a/shaders/cOpticalFlow.fx +++ b/shaders/cOpticalFlow.fx @@ -642,8 +642,9 @@ namespace OpticalFlow // [Ix^2+A IxIy] [U] = -[IxIt] // [IxIy Iy^2+A] [V] = -[IyIt] UVAverage.xy = (AreaGrad.xx * AreaAvg[0]) + (AreaGrad.yy * AreaAvg[1]) + (AreaGrad.zz * AreaAvg[2]) + (AreaGrad.ww * AreaAvg[3]); - OpticalFlow.x = Aii.x * ((Alpha * UVAverage.x) - (Aij * CenterAverage.y) - Bi.x); - OpticalFlow.y = Aii.y * ((Alpha * UVAverage.y) - (Aij * OpticalFlow.x) - Bi.y); + UVAverage.xy = UVAverage.xy * Alpha; + OpticalFlow.x = Aii.x * (UVAverage.x - (Aij * CenterAverage.y) - Bi.x); + OpticalFlow.y = Aii.y * (UVAverage.y - (Aij * OpticalFlow.x) - Bi.y); } #define LEVEL_PS(NAME, SAMPLER, LEVEL) \ diff --git a/shaders/kDatamosh.fx b/shaders/kDatamosh.fx index e4c003f..2621d32 100644 --- a/shaders/kDatamosh.fx +++ b/shaders/kDatamosh.fx @@ -605,8 +605,9 @@ namespace Datamosh // [Ix^2+A IxIy] [U] = -[IxIt] // [IxIy Iy^2+A] [V] = -[IyIt] UVAverage.xy = (AreaGrad.xx * AreaAvg[0]) + (AreaGrad.yy * AreaAvg[1]) + (AreaGrad.zz * AreaAvg[2]) + (AreaGrad.ww * AreaAvg[3]); - OpticalFlow.x = Aii.x * ((Alpha * UVAverage.x) - (Aij * CenterAverage.y) - Bi.x); - OpticalFlow.y = Aii.y * ((Alpha * UVAverage.y) - (Aij * OpticalFlow.x) - Bi.y); + UVAverage.xy = UVAverage.xy * Alpha; + OpticalFlow.x = Aii.x * (UVAverage.x - (Aij * CenterAverage.y) - Bi.x); + OpticalFlow.y = Aii.y * (UVAverage.y - (Aij * OpticalFlow.x) - Bi.y); } #define LEVEL_PS(NAME, SAMPLER, LEVEL) \