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)