Preserve texture alpha in local renderer

This commit is contained in:
2026-08-11 00:34:56 +01:00
parent 7ccca2715a
commit bc10c0a0a1
+4 -2
View File
@@ -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)