diff --git a/SDFMapCreator.sln.DotSettings.user b/SDFMapCreator.sln.DotSettings.user index 4dfff6d..0c42637 100644 --- a/SDFMapCreator.sln.DotSettings.user +++ b/SDFMapCreator.sln.DotSettings.user @@ -1,8 +1,11 @@  ForceIncluded + ForceIncluded ForceIncluded ForceIncluded + ForceIncluded ForceIncluded + ForceIncluded ForceIncluded ForceIncluded <AssemblyExplorer> diff --git a/SDFMapCreator/Program.cs b/SDFMapCreator/Program.cs index 872033d..1bf0be0 100644 --- a/SDFMapCreator/Program.cs +++ b/SDFMapCreator/Program.cs @@ -211,23 +211,11 @@ public class Program { $"Progress: {iterCount / (float)(width * height):P}% | {iterCount / (sw.Elapsed.TotalSeconds):N0} pixels/s"); } });*/ - kernels.Sdf(mask.Edges.ToArray(), out var temp); + kernels.Sdf(mask.Edges.ToArray(), (int)width, (int)height, out var temp); Console.WriteLine( $"\nSDF Generation Time: {sw.Elapsed.TotalSeconds:N4}s ({iterCount / sw.Elapsed.TotalSeconds:N0} pixels/s)"); - sw.Restart(); - Parallel.For(0, width * height, parallelOptions, (i) => - { - //convert 1D index to 2D index - var x = (int)(i % width); - var y = (int)(i / width); - temp[x, y] = new(Remap(temp[x, y].X, 0, AbsMax, MIN, MAX)); - }); - sw.Stop(); - Console.WriteLine( - $"SDF Normalization Time: {sw.Elapsed.TotalSeconds:N4}s ({iterCount / sw.Elapsed.TotalSeconds:N0} pixels/s)"); - Console.WriteLine("AbsMax: " + AbsMax); return new(temp); } diff --git a/SDFMapCreator/SdfKernels.cs b/SDFMapCreator/SdfKernels.cs index 3a96c35..958fa18 100644 --- a/SDFMapCreator/SdfKernels.cs +++ b/SDFMapCreator/SdfKernels.cs @@ -107,11 +107,8 @@ public partial class SdfKernels { edge = buffer.GetAsArray2D(); } - public void Sdf(Vector2[] edges, out Vector3[,] sdf) { + public void Sdf(Vector2[] edges, int width, int height, out Vector3[,] sdf) { var dev = gpuContext.GetPreferredDevice(preferCPU:false); - int width = edges.Length; - int height = edges.Length; - sdf = new Vector3[width, height]; using Accelerator accelerator = dev.CreateAccelerator(gpuContext); using var buffer = accelerator.Allocate2DDenseX(new (width, height));