misc fixes

This commit is contained in:
Samuele Lorefice
2025-04-03 17:06:05 +02:00
parent 664c5e02fe
commit 6fd430a670
3 changed files with 11 additions and 10 deletions

View File

@@ -17,20 +17,22 @@ public class Program {
static List<SDFData> SDFs = new();
static List<Vector3[,]> 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<Vector3>($"./{imagesPath}{Path.DirectorySeparatorChar}{i + 1:00}.png");
Images.Add(new(pixels, pixels.GetLength(0), pixels.GetLength(1)));
}
*/
/*
var pixels = ImageUtil.LoadImage<Vector3>($"./sphereempty.png");
Images.Add(new(pixels, pixels.GetLength(0), pixels.GetLength(1)));
pixels = ImageUtil.LoadImage<Vector3>($"./spherehalf.png");
@@ -39,8 +41,6 @@ public class Program {
Images.Add(new(pixels, pixels.GetLength(0), pixels.GetLength(1)));
pixels = ImageUtil.LoadImage<Vector3>($"./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) {
@@ -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) {

View File

@@ -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);
}
}

View File

@@ -17,6 +17,7 @@ public partial class SdfKernels {
.OpenCL()
.Cuda()
.CPU()
.Math(MathMode.Fast32BitOnly)
);
Console.WriteLine("Reading available accelerators (CUDA only)...");