Agent skills that make real-time game VFX: procedural Effekseer effects, video-model flipbooks, or both, played in Godot and Unity (Claude Code, Codex and other Agent Skills hosts).
Python
Keep CLI help and output ASCII so a Windows console can print them
Kanad17b3e747df4
diff --git a/skills/effekseer-vfx/scripts/vfxkit/cli.py b/skills/effekseer-vfx/scripts/vfxkit/cli.pyindex 25093f4..7f04a87 100644--- a/skills/effekseer-vfx/scripts/vfxkit/cli.py+++ b/skills/effekseer-vfx/scripts/vfxkit/cli.py@@ -52,7 +52,7 @@ def parser():a.add_argument('--anchor', choices=['center', 'bottom'], default='center')a = sub.add_parser('video-timeline', help='labelled frames (24 fps numbering) of a generated clip, to pick the span for a flipbook')a.add_argument('video'); a.add_argument('--step', type=int, default=2)- a = sub.add_parser('video-flipbook', help='generated clip on black → straight-alpha flipbook sheet with masked cells and transparent gutters')+ a = sub.add_parser('video-flipbook', help='generated clip on black -> straight-alpha flipbook sheet with masked cells and transparent gutters')a.add_argument('video'); a.add_argument('output'); a.add_argument('--grid', type=int, nargs=2, metavar=('COLS', 'ROWS'), default=(8, 8))a.add_argument('--cell', type=int, default=256); a.add_argument('--cell-h', type=int, default=0, help='cell height (tall columns); default = --cell')a.add_argument('--start', type=int, default=-1); a.add_argument('--end', type=int, default=-1)diff --git a/skills/effekseer-vfx/scripts/vfxkit/unity.py b/skills/effekseer-vfx/scripts/vfxkit/unity.pyindex c9c3ada..8459ee0 100644--- a/skills/effekseer-vfx/scripts/vfxkit/unity.py+++ b/skills/effekseer-vfx/scripts/vfxkit/unity.py@@ -6,7 +6,7 @@export copy a processed sheet into Assets/VfxSkill/Flipbooks/ with a .flipbook.json sidecar (grid, cell size,source) so the import rules and the "Create element skill" window read its grid without guessing.-In Unity: VFX Skill → 1. Setup shared materials → 2. Create element skill from flipbooks → 3. Build demo scene.+In Unity: VFX Skill -> 1. Setup shared materials -> 2. Create element skill from flipbooks -> 3. Build demo scene."""import jsonimport shutil@@ -46,7 +46,7 @@ def _mask(path, m, root):def _inner_gradient(binary, radius, power=0.7):- """Binary shape → interior gradient (an approximate distance field). A higher power keeps less area near 1, so+ """Binary shape -> interior gradient (an approximate distance field). A higher power keeps less area near 1, sothe shell's white core is smaller and erosion thins the shape gradually instead of dropping it all at once."""b = np.asarray(Image.fromarray((binary * 255).astype(np.uint8)).filter(ImageFilter.GaussianBlur(float(radius)))) / 255.0g = np.clip((b - 0.5) * 2, 0, 1) * binary@@ -60,7 +60,7 @@ def _periodic(w, k, rng):def _tile_noise(n, octaves, rng, base=4):- """Tileable value noise in 0–1: random lattices sampled with wrap-around, smoothly interpolated."""+ """Tileable value noise in 0-1: random lattices sampled with wrap-around, smoothly interpolated."""out, amp, total = np.zeros((n, n)), 1.0, 0.0for o in range(octaves):cells = base * 2 ** o@@ -107,14 +107,14 @@ def textures(project, seed=7):rays = 0.25 * np.abs(np.cos(th * 3)) ** 8 * np.clip(1 - r, 0, 1)written.append(_save(out / 'T_Flash.png', np.ones(3), np.clip(1 - r, 0, 1) ** 2.4 + rays, root))- cells = [] # smoke 2×2: neutral puffs, coloured by particle colour+ cells = [] # smoke 2x2: neutral puffs, coloured by particle colourfor _ in range(4):a = _blob(256, rng, rough=0.22, base=0.6)shade = 0.72 + 0.28 * np.clip(1 - _polar(256)[0] * 0.9, 0, 1) * _tile_noise(256, 3, rng, 3)cells.append(np.dstack([shade, shade, shade, a * (0.55 + 0.45 * _tile_noise(256, 4, rng, 4))]))s = _sheet(cells, 2); written.append(_save(out / 'T_Smoke_2x2.png', s[..., :3], s[..., 3], root))- cells = [] # drops 2×2: round beads, dark-edged, one highlight+ cells = [] # drops 2x2: round beads, dark-edged, one highlightfor i in range(4):n = 128; r2, _ = _polar(n)a = _blob(n, rng, lobes=4, rough=0.05, base=0.5 + 0.08 * (i % 2))@@ -161,7 +161,7 @@ def textures(project, seed=7):band[(np.abs(v - c - 0.03 * np.sin(u * 13 + c * 9)) < w0 * (0.4 + u)) & (u > 0.25)] = 0written.append(_mask(out / 'T_MaskRibbon.png', _inner_gradient(band, 10, 1.5), root))- v = np.linspace(0, 1, 32)[:, None] * np.ones((1, 256)) # bolt strip: cross-section, ridge 1 → edges 0+ v = np.linspace(0, 1, 32)[:, None] * np.ones((1, 256)) # bolt strip: cross-section, ridge 1 -> edges 0written.append(_mask(out / 'T_MaskBoltStrip.png', np.clip(1 - np.abs(v - 0.5) * 2, 0, 1) ** 1.3, root))r, th = _polar(256); spikes = 9 # contact star: uneven many-pointed burst@@ -200,9 +200,9 @@ def install(project, force=False):tex = textures(root)version = json.loads((PACKAGE / 'package.json').read_text())['version']return {'ok': True, 'package': str(dest), 'version': version, 'package_state': state, **tex,- 'next': ['Open the project in Unity (6000.0+, URP).', 'VFX Skill → 1. Setup shared materials',- f'vfx unity-export <sheet.png> {root} for each flipbook', 'VFX Skill → 2. Create element skill from flipbooks',- 'VFX Skill → 3. Build demo scene, then Play']}+ 'next': ['Open the project in Unity (6000.0+, URP).', 'VFX Skill -> 1. Setup shared materials',+ f'vfx unity-export <sheet.png> {root} for each flipbook', 'VFX Skill -> 2. Create element skill from flipbooks',+ 'VFX Skill -> 3. Build demo scene, then Play']}def export(sheet, project, grid=None, name=None):@@ -221,7 +221,7 @@ def export(sheet, project, grid=None, name=None):cols, rows = int(grid[0]), int(grid[1])w, h = Image.open(src).sizeif w % cols or h % rows:- raise ValueError(f'{src.name} is {w}×{h}: not divisible into a {cols}×{rows} grid')+ raise ValueError(f'{src.name} is {w}x{h}: not divisible into a {cols}x{rows} grid')if name and (Path(name).name != name or name in ('.', '..')):raise ValueError(f'--name must be a plain file name, not {name!r}')dest = root / FLIPBOOKS / f'{name or src.stem}.png'diff --git a/skills/effekseer-vfx/scripts/vfxkit/video.py b/skills/effekseer-vfx/scripts/vfxkit/video.pyindex 826a45e..4181c79 100644--- a/skills/effekseer-vfx/scripts/vfxkit/video.py+++ b/skills/effekseer-vfx/scripts/vfxkit/video.py@@ -8,7 +8,7 @@ layered primitives cannot draw. This module turns such a clip into a sheet and gflipbook decode at a fixed rate, luminance key on black, one shared crop for every frame (no jitter), a noisyround or rounded-box mask per cell (never a square edge), a fully transparent gutter round every cell,and a hard failure if any cell border still has alpha- grade re-colour by density with one value ramp per element (dark rim → body → light → hot core), erode the+ grade re-colour by density with one value ramp per element (dark rim -> body -> light -> hot core), erode thehaze that keying leaves behind, fade the last cells to zero, optionally cool the tail to smokefirst_frame put a generated element image on pure black at the size and place the clip should start from@@ -112,7 +112,7 @@ def _smoothstep(a, b, x):def _key(path, floor, gain, dehaze):- """Black → alpha. The median of a thin border ring is the frame's haze; it is subtracted before keying, and+ """Black -> alpha. The median of a thin border ring is the frame's haze; it is subtracted before keying, andcolour is un-premultiplied so thin glows keep their hue instead of turning grey."""img = np.asarray(Image.open(path).convert('RGB'), np.float32) / 255h, w = img.shape[:2]@@ -166,7 +166,7 @@ def timeline(video, step=2, columns=10):# ------------------------------------------------------------------ flipbookdef flipbook(video, output, cols=8, rows=8, cell=256, cell_h=0, start=-1, end=-1, frames=None, crop='auto', box=None,pad=1.04, radius=.38, feather=.12, mask_power=2.0, floor=.06, gain=1.3, gutter=6, dehaze=1.0, prompt=None, prompt_file=None):- """Decode → key → shared crop → masked cells with transparent gutters → one sheet (cols × rows cells of cell × cell_h).+ """Decode -> key -> shared crop -> masked cells with transparent gutters -> one sheet (cols x rows cells of cell x cell_h).`frames` 'a:b:s' picks exact 24 fps frames (len must equal cols*rows); otherwise `start`..`end` (auto: the span withvisible content) is sampled evenly. `crop` 'auto' takes the union bounding box of every picked frame (padded by `pad`)@@ -176,9 +176,9 @@ def flipbook(video, output, cols=8, rows=8, cell=256, cell_h=0, start=-1, end=-1cell_h = cell_h or celln = cols * rowsif min(cols, rows) < 1 or cell < 32 or cell_h < 32 or gutter < 2:- raise ValueError('need cols, rows ≥ 1, cells ≥ 32 px and a gutter of at least 2 px')+ raise ValueError('need cols, rows >= 1, cells >= 32 px and a gutter of at least 2 px')if cols * cell > 4096 or rows * cell_h > 4096:- raise ValueError(f'sheet {cols * cell}×{rows * cell_h} exceeds 4096 px; use smaller cells or fewer frames')+ raise ValueError(f'sheet {cols * cell}x{rows * cell_h} exceeds 4096 px; use smaller cells or fewer frames')tmp = Path(tempfile.mkdtemp())try:files = _decode(video, tmp)@@ -288,7 +288,7 @@ def grade(source, output, cols=8, rows=8, ramp=None, erode=.22, erode_pow=1.5, t- `erode`/`erode_pow`: the alpha threshold rises over time, so thin haze goes first and the structure last;`tail_fade` brings the last cells linearly to zero (no pop when the particle dies).- - `ramp` 'pos:r,g,b;...' maps density (alpha × luminance) to the element's value ramp; close stops give hard+ - `ramp` 'pos:r,g,b;...' maps density (alpha x luminance) to the element's value ramp; close stops give hardcel steps. `highlight` keeps white only on fine detail (spray, glints). `ramp_fade` 't0,t1' blends back to theclip's own colours later in the sheet (a clip's grey smoke and embers usually read better than a re-colour).- `smoke`/`smoke_start` cool the tail towards one smoke colour; `keep_embers` leaves saturated orange-red pixels of@@ -304,7 +304,7 @@ def grade(source, output, cols=8, rows=8, ramp=None, erode=.22, erode_pow=1.5, tim = np.asarray(Image.open(src).convert('RGBA')).astype(np.float64) / 255H, W = im.shape[0] // rows, im.shape[1] // colsif H * rows != im.shape[0] or W * cols != im.shape[1]:- raise ValueError(f'{im.shape[1]}×{im.shape[0]} does not divide into {cols}×{rows} cells')+ raise ValueError(f'{im.shape[1]}x{im.shape[0]} does not divide into {cols}x{rows} cells')stops = _ramp(ramp) if ramp else Nonesmoke_rgb = np.array([float(v) for v in smoke.split(',')]) if smoke else Nonefade = [float(v) for v in ramp_fade.split(',')] if ramp_fade else Nonediff --git a/tests/test_video.py b/tests/test_video.pyindex ce71cb8..b499bff 100644--- a/tests/test_video.py+++ b/tests/test_video.py@@ -128,9 +128,10 @@ def test_unity_export_writes_the_grid_sidecar_and_stays_inside_the_project(tmp_pdef test_unity_commands_need_no_workspace(tmp_path):+ """Runs without a vfx/ workspace and prints only what a cp1252 Windows console can encode."""root = fake_unity(tmp_path)run = subprocess.run([__import__('sys').executable, '-m', 'vfxkit', 'unity-install', str(root)], capture_output=True, text=True,- cwd=tmp_path, env=cli_env(VFX_PROJECT=''), timeout=120)+ cwd=tmp_path, env=cli_env(VFX_PROJECT='', PYTHONIOENCODING='cp1252'), timeout=120) # a Windows console's encodingassert run.returncode == 0, run.stdout + run.stderrassert json.loads(run.stdout)['ok'] and not (tmp_path / 'vfx').exists()@@ -158,3 +159,9 @@ def test_unity_force_keeps_meta_guids(tmp_path):meta.write_text('fileFormatVersion: 2\nguid: 0123456789abcdef0123456789abcdef\n')assert 'GUIDs kept' in unity.install(root, force=True)['package_state']assert '0123456789abcdef' in meta.read_text()+++def test_help_prints_on_a_windows_console():+ run = subprocess.run([__import__('sys').executable, '-m', 'vfxkit', '--help'], capture_output=True, text=True,+ env=cli_env(PYTHONIOENCODING='cp1252'), timeout=60)+ assert run.returncode == 0, run.stderr