From bc10c0a0a124bfd40cae0ea3edd7aed43e060085 Mon Sep 17 00:00:00 2001 From: Mark Rapson Date: Tue, 11 Aug 2026 00:34:56 +0100 Subject: [PATCH] Preserve texture alpha in local renderer --- build/scripts/render_models.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/build/scripts/render_models.py b/build/scripts/render_models.py index 8e306cf..8699394 100644 --- a/build/scripts/render_models.py +++ b/build/scripts/render_models.py @@ -328,8 +328,10 @@ def transform_face(texture: Image.Image, vertices: list[tuple[float, float, floa warped = texture.transform((width, height), Image.Transform.AFFINE, (a, b, c, d, e, f), resample=Image.Resampling.BICUBIC) mask = Image.new("L", (width, height), 0) ImageDraw.Draw(mask).polygon(local, fill=255) + texture_alpha = warped.getchannel("A") + warped.putalpha(ImageChops.multiply(texture_alpha, mask)) - return warped.putalpha(mask), (min_x, min_y) + return warped, (min_x, min_y) def render_model(pack_root: Path, model_ref: str, output_path: Path, cache: dict[str, dict[str, Any]]) -> None: @@ -437,7 +439,7 @@ def render_model(pack_root: Path, model_ref: str, output_path: Path, cache: dict warped = texture.transform((width, height), Image.Transform.AFFINE, (a, b, c, d, e, f), resample=Image.Resampling.NEAREST) mask = Image.new("L", (width, height), 0) ImageDraw.Draw(mask).polygon(local, fill=255) - warped.putalpha(mask) + warped.putalpha(ImageChops.multiply(warped.getchannel("A"), mask)) canvas.alpha_composite(warped, (min_x, min_y)) canvas.save(output_path)