Generate clean 2D game sprites & animation atlases — component-row pipeline: state rows, alpha cleanup, frame extraction, runtime atlases. Codex/Claude skill.
fix: remove near-black noise before brightness alpha extraction
Soohong Kim688e96d89245
diff --git a/sprite_gen/video/effect.py b/sprite_gen/video/effect.pyindex ebcb787..469ad57 100644--- a/sprite_gen/video/effect.py+++ b/sprite_gen/video/effect.py@@ -2,8 +2,8 @@"""Emissive effects on black: straight-alpha conversion and generation framing.RGB on black is already multiplied by its coverage. The maximum channel is the-smallest alpha that can reconstruct every channel without clipping. No threshold-is applied: a dim wisp and a detached spark both carry intentional light.+smallest alpha that can reconstruct every channel without clipping. The shared+black noise floor removes near-zero values; surviving light is not rescaled."""from pathlib import Pathfrom typing import Any@@ -14,11 +14,13 @@ from sprite_gen._deps import npSTATE = "effect"ALPHA_MODES = ("chroma", "brightness")+BRIGHTNESS_NOISE_FLOOR = 2def brightness_alpha(image: Image.Image) -> Image.Image:rgb = np.asarray(image.convert("RGB"), dtype=np.float32)alpha = rgb.max(axis=2)+ alpha[alpha <= BRIGHTNESS_NOISE_FLOOR] = 0color = np.zeros_like(rgb)np.divide(rgb * 255, alpha[:, :, None], out=color, where=alpha[:, :, None] > 0)return Image.fromarray(np.dstack((np.rint(color), alpha)).astype(np.uint8), "RGBA")@@ -36,7 +38,8 @@ def key_frames(files: list[Path], directory: Path) -> dict[str, Any]:zero = image.getchannel("A").histogram()[0]rows.append({"frame": src.name, "alpha_zero_pct": round(100 * zero / (image.width * image.height), 2),"route": "brightness", "specks": 0})- return {"alpha_mode": "brightness", "blend": "add", "frames": len(rows), "rows": rows,+ return {"alpha_mode": "brightness", "brightness_noise_floor": BRIGHTNESS_NOISE_FLOOR,+ "blend": "add", "frames": len(rows), "rows": rows,"alpha_zero_pct_min": min(r["alpha_zero_pct"] for r in rows),"alpha_zero_pct_max": max(r["alpha_zero_pct"] for r in rows),"specks": {"dropped": 0, "frames": 0, "policy": "off"},