From 77c45018ac597f556edce19e4895889cc35c34e6 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Mon, 19 Aug 2019 00:58:42 +0200 Subject: [PATCH] Switched to updated bokeh code --- samples/ComputeSharp.BokehBlur/Program.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/samples/ComputeSharp.BokehBlur/Program.cs b/samples/ComputeSharp.BokehBlur/Program.cs index b79c1105..7b13da22 100644 --- a/samples/ComputeSharp.BokehBlur/Program.cs +++ b/samples/ComputeSharp.BokehBlur/Program.cs @@ -74,8 +74,8 @@ namespace ComputeSharp.BokehBlur int j = ij % width; ref Vector4 rin = ref vectorArray[0]; ref Vector4 rout = ref resultArray[0]; + ref float rk = ref kernel[0]; Vector4 total = Vector4.Zero; - int pixels = 0; for (int y = -Radius; y <= Radius; y++) { @@ -86,17 +86,15 @@ namespace ComputeSharp.BokehBlur if (iy < 0 || iy > height) continue; if (jx < 0 || jx > width) continue; - int dx2x1 = jx - j; - int dy2y1 = iy - i; - if (MathF.Sqrt(dx2x1 * dx2x1 + dy2y1 * dy2y1) > Radius) continue; - ref Vector4 v4 = ref Unsafe.Add(ref rin, iy * width + jx); - total += v4; - pixels++; + int ki = Radius - y; + int kj = Radius - x; + + total += Unsafe.Add(ref rin, iy * width + jx) * Unsafe.Add(ref rk, ki * diameter + kj); } } - Unsafe.Add(ref rout, i * width + j) = total / pixels; + Unsafe.Add(ref rout, i * width + j) = total; }); // Copy the modified image back