summaryrefslogtreecommitdiffstats
path: root/Third_Party/gen_sdf
diff options
context:
space:
mode:
authoryum <yum.food.vr@gmail.com>2025-02-05 23:14:13 -0800
committeryum <yum.food.vr@gmail.com>2025-02-05 23:14:13 -0800
commit9b52e08a7f2400c7ee78e9b284ed0c4c876a7dd4 (patch)
tree601470be4190a95677e88c77c4c9846b0384a433 /Third_Party/gen_sdf
parentd45815e49ba24b881bf54b73fd1b8a82579fa1c2 (diff)
Add 4x4 textures to ssfd
Diffstat (limited to 'Third_Party/gen_sdf')
-rw-r--r--Third_Party/gen_sdf37
1 files changed, 19 insertions, 18 deletions
diff --git a/Third_Party/gen_sdf b/Third_Party/gen_sdf
index 2f0e3a6..52ef487 100644
--- a/Third_Party/gen_sdf
+++ b/Third_Party/gen_sdf
@@ -25,28 +25,29 @@ def compute_sdf(img, scale_factor):
def main():
parser = argparse.ArgumentParser(description='Generate SDF from black and white image')
- parser.add_argument('input_image', help='Path to input image')
+ parser.add_argument('input_images', nargs='+', help='Path to input image(s)')
parser.add_argument('--scale', type=float, default=1.0,
help='Scale factor for distance (in texels)')
args = parser.parse_args()
- # Get input and output paths
- input_path = args.input_image
- filename, ext = os.path.splitext(input_path)
- output_path = f"{filename}-sdf{ext}"
-
- # Read input image
- img = cv2.imread(input_path, cv2.IMREAD_GRAYSCALE)
- if img is None:
- print(f"Error: Could not read image {input_path}")
- return
-
- # Compute SDF with scale factor
- sdf = compute_sdf(img, args.scale)
-
- # Save result
- cv2.imwrite(output_path, sdf)
- print(f"SDF generated and saved to {output_path}")
+ # Process each input image
+ for input_path in args.input_images:
+ # Get input and output paths
+ filename, ext = os.path.splitext(input_path)
+ output_path = f"{filename}-sdf{ext}"
+
+ # Read input image
+ img = cv2.imread(input_path, cv2.IMREAD_GRAYSCALE)
+ if img is None:
+ print(f"Error: Could not read image {input_path}")
+ continue
+
+ # Compute SDF with scale factor
+ sdf = compute_sdf(img, args.scale)
+
+ # Save result
+ cv2.imwrite(output_path, sdf)
+ print(f"SDF generated and saved to {output_path}")
if __name__ == "__main__":
main()