diff --git a/SDFMapCreator/Program.cs b/SDFMapCreator/Program.cs index 31c6890..67f484b 100644 --- a/SDFMapCreator/Program.cs +++ b/SDFMapCreator/Program.cs @@ -48,6 +48,21 @@ public class Program { Environment.Exit(1); } + for (int i = 1; i < Images.Count; i++) + { + for (int x = 0; x < Images[i].Width; x++) + { + for (int y = 0; y < Images[i].Height; y++) + { + Images[i].Pixels[x, y].X = MathF.Min(Images[i - 1].Pixels[x, y].X + Images[i].Pixels[x, y].X, MAX); + Images[i].Pixels[x, y].Y = MathF.Min(Images[i - 1].Pixels[x, y].Y + Images[i].Pixels[x, y].X, MAX); + 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; @@ -89,14 +104,20 @@ public class Program { var finalImage = new Vector3[width, height]; var currStep = 0f; var stepIncrement = MAX / (Gradients.Count); + + for(int x=0; x {currStep + stepIncrement}"); for (var x = 0; x < mask.Mask.GetLength(0); x++) { for (var y = 0; y < mask.Mask.GetLength(1); y++) { - if (mask.Mask[x, y].X == 0) continue; - finalImage[x, y] = new(Remap(gradient[x, y].X, MAX, MIN, currStep, currStep + stepIncrement)); + if(gradient[x, y].X == 0) continue; + var pixel = new Vector3(Remap(gradient[x, y].X, MIN, MAX, 1.0f-currStep, 1.0f-(currStep + stepIncrement))); + if(pixel.X > finalImage[x, y].X) finalImage[x, y] = pixel; } } currStep += stepIncrement; @@ -251,7 +272,7 @@ public class Program { uint y = (uint)(i / resX); var pixelA = A[x, y]; float lumaA = (pixelA.X + pixelA.Y + pixelA.Z) / 3; - float resultPixel = lumaA > 0 ? MAX : MIN; + float resultPixel = lumaA > 0.99 ? MAX : MIN; temp[x, y] = new(resultPixel, 0, 0); }); return temp;