diff --git a/SDFMapCreator/Program.cs b/SDFMapCreator/Program.cs index 0d6d2f1..872033d 100644 --- a/SDFMapCreator/Program.cs +++ b/SDFMapCreator/Program.cs @@ -17,20 +17,22 @@ public class Program { static List SDFs = new(); static List Gradients = new(); static readonly SdfKernels kernels = new(); + static uint width; + static uint height; + static void ConsoleUpdateLine(string s) => Console.Write("\r" + s); public static void Main(string[] args) { Console.WriteLine("Reading images..."); +/* var imagesPath = "images"; - - for (int i = 0; i < 8; i++) { var pixels = ImageUtil.LoadImage($"./{imagesPath}{Path.DirectorySeparatorChar}{i + 1:00}.png"); Images.Add(new(pixels, pixels.GetLength(0), pixels.GetLength(1))); } +*/ - /* var pixels = ImageUtil.LoadImage($"./sphereempty.png"); Images.Add(new(pixels, pixels.GetLength(0), pixels.GetLength(1))); pixels = ImageUtil.LoadImage($"./spherehalf.png"); @@ -39,9 +41,7 @@ public class Program { Images.Add(new(pixels, pixels.GetLength(0), pixels.GetLength(1))); pixels = ImageUtil.LoadImage($"./spherefull.png"); Images.Add(new(pixels, pixels.GetLength(0), pixels.GetLength(1))); - */ - - + //check if all the images in Images are the same resolution if (Images.Select(img => (img.Width, img.Height)).Distinct().Count() > 1) { Console.WriteLine("Error: Not all images have the same resolution."); @@ -56,14 +56,13 @@ public class Program { Images[i].Pixels[x, y].Z = MathF.Min(Images[i - 1].Pixels[x, y].Z + Images[i].Pixels[x, y].X, MAX); } } - Images[i].Pixels.SaveImage($"./Sum{i}.png"); } Console.WriteLine("Creating masks..."); //for each image pair, create a mask - var width = (uint)Images[0].Width; - var height = (uint)Images[0].Height; + width = (uint)Images[0].Width; + height = (uint)Images[0].Height; for (int i = 0; i < Images.Count; i++) { ImageMasks.Add(new(SelfMask(Images[i].Pixels, width, height), Images[i], new())); if (i < Images.Count - 1) { diff --git a/SDFMapCreator/SdfKernels.Kernels.cs b/SDFMapCreator/SdfKernels.Kernels.cs index 05ccfba..35ea606 100644 --- a/SDFMapCreator/SdfKernels.Kernels.cs +++ b/SDFMapCreator/SdfKernels.Kernels.cs @@ -57,7 +57,7 @@ public partial class SdfKernels { ) { Vector2 pos = new((float)index.X / width, (float)index.Y / height); float minDist = 2f; - int count = edges.IntExtent.X; + int count = edges.IntExtent.Size; for (int i = 0; i < count; i++) { Vector2 edgeNrm = new (edges[i].X/width, edges[i].Y/height); @@ -69,4 +69,5 @@ public partial class SdfKernels { sdf[index] = new(minDist); } + } \ No newline at end of file diff --git a/SDFMapCreator/SdfKernels.cs b/SDFMapCreator/SdfKernels.cs index 4a9c995..3a96c35 100644 --- a/SDFMapCreator/SdfKernels.cs +++ b/SDFMapCreator/SdfKernels.cs @@ -17,6 +17,7 @@ public partial class SdfKernels { .OpenCL() .Cuda() .CPU() + .Math(MathMode.Fast32BitOnly) ); Console.WriteLine("Reading available accelerators (CUDA only)...");