Extend AI image tooling with variants; drop dev asset folders from git

asset_pipeline generate gains --variants N (saved as <stem>-1..N.png). .gitignore now excludes assets/models/concepts, assets/models/npc, assets/textures/npc/ai, and raw assets/textures/ai outputs; only game_ready and the game-facing NPC maps/models stay tracked.
This commit is contained in:
zwitschi committed 2026-11-01 12:08:34 +01:00
1 parent b24d0aeb61
commit 4943dbff16
32 files changed
+46 -16

No files matched your search

+28 -15
View File
@@ -258,6 +258,13 @@ def image_paths(values):
return sorted(set(found))
def _variant_output(output: Path, index: int, count: int) -> Path:
"""Suffix the output path for alternative images (N > 1 only)."""
if count <= 1:
return output
return output.with_name(f"{output.stem}-{index}{output.suffix}")
def _generate(args):
profile = PROFILES[args.role]
if (args.width is None) != (args.height is None):
@@ -267,21 +274,24 @@ def _generate(args):
transparent = args.transparent if args.transparent is not None else profile.get(
"alpha") is True
prompt = f"{args.prompt.strip()}. {ROLE_GUIDANCE[args.role]}."
image = generate_textures.generate_image(
prompt, args.model, args.request_size, transparent,
aspect_ratio=API_ASPECTS[args.role])
foreground = getattr(args, "foreground", None)
if foreground:
image = colorize_alpha(image, foreground)
if args.role == "icon" and has_alpha(image):
image = resize_image_from_image(
image, width, height, "contain", (0, 0, 0, 0))
else:
image = ImageOps.fit(image, (width, height),
method=Image.Resampling.LANCZOS)
if args.role == "tile":
image = make_seamless(image)
save_image(image, resolve_path(args.output))
count = max(1, int(getattr(args, "variants", 1) or 1))
output = resolve_path(args.output)
for index in range(1, count + 1):
image = generate_textures.generate_image(
prompt, args.model, args.request_size, transparent,
aspect_ratio=API_ASPECTS[args.role])
foreground = getattr(args, "foreground", None)
if foreground:
image = colorize_alpha(image, foreground)
if args.role == "icon" and has_alpha(image):
image = resize_image_from_image(
image, width, height, "contain", (0, 0, 0, 0))
else:
image = ImageOps.fit(image, (width, height),
method=Image.Resampling.LANCZOS)
if args.role == "tile":
image = make_seamless(image)
save_image(image, _variant_output(output, index, count))
def resize_image_from_image(image, width, height, fit, background):
@@ -365,6 +375,9 @@ def build_parser():
default=generate_textures.GEN_SIZE)
generate.add_argument("--width", type=int)
generate.add_argument("--height", type=int)
generate.add_argument("--variants", type=int, default=1,
help="generate N alternative images; saved as "
"<stem>-1.png ... <stem>-N.png when N > 1")
generate.add_argument(
"--foreground", type=parse_color,
help="replace visible RGB with this color while preserving alpha")