@ajsmonty/adobe-mcp 1.1.2 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +361 -119
  3. package/SECURITY.md +24 -1
  4. package/adapters/ae_more.mjs +208 -0
  5. package/adapters/an.mjs +96 -0
  6. package/adapters/assets.mjs +194 -0
  7. package/adapters/blender.mjs +230 -0
  8. package/adapters/id.mjs +250 -0
  9. package/adapters/ppro.mjs +4 -3
  10. package/adapters/ppro_more.mjs +393 -0
  11. package/adapters/ps_ai_more.mjs +277 -0
  12. package/adapters/substance.mjs +193 -0
  13. package/adapters/texlib.mjs +193 -0
  14. package/bridges/blender/adobe_mcp_bridge.py +132 -0
  15. package/cep/mcp-bridge/CSXS/manifest.xml +36 -2
  16. package/cep/mcp-bridge/main.js +48 -20
  17. package/cli/doctor.mjs +234 -0
  18. package/cli/index.mjs +67 -0
  19. package/cli/install.mjs +149 -0
  20. package/core/barrows.mjs +16 -0
  21. package/core/blender_pbr.py +148 -0
  22. package/core/bridge.mjs +166 -77
  23. package/core/harness.jsx +11 -6
  24. package/core/harness.py +34 -0
  25. package/core/helpers.mjs +196 -0
  26. package/core/platform.mjs +209 -0
  27. package/core/pybridge.mjs +256 -0
  28. package/core/telemetry.mjs +80 -0
  29. package/core/texlib.mjs +279 -0
  30. package/core/win/run_com.js +33 -0
  31. package/core/workspace.mjs +1 -1
  32. package/knowledge/knowledge.mjs +8 -5
  33. package/knowledge/lessons.jsonl +19 -0
  34. package/package.json +56 -3
  35. package/scripts/ae/Cinematic_3D_Composite.jsx +173 -0
  36. package/scripts/blender/Creature_Walk_Cinematic.py +569 -0
  37. package/scripts/substance/Creature_Skin_LookDev.py +148 -0
  38. package/server.mjs +92 -27
  39. package/workflow/setup.mjs +106 -0
  40. package/workflow/vfx.mjs +136 -0
  41. package/workflow/workflow.mjs +66 -21
@@ -0,0 +1,148 @@
1
+ """
2
+ Creature_Skin_LookDev — Substance 3D Painter look-dev pass for a large reptile/creature.
3
+ Per texture set: optional mesh-map bake (curvature/AO feed the generators), an optional smart
4
+ material, a matte "aged scales" base (high roughness, zero metal), and a cavity-masked wetness
5
+ layer (low roughness where moisture collects). Texture sets whose name matches eye/mouth/teeth/
6
+ tongue get a glossy wet treatment. Everything lands in one undo step. Optional PBR export.
7
+ Override keys in DEFAULTS via PARAMS (run_script params). Sets `result` to a per-set report.
8
+ """
9
+ import substance_painter.colormanagement as sp_cm
10
+ import substance_painter.layerstack as sp_ls
11
+ import substance_painter.project as sp_proj
12
+ import substance_painter.resource as sp_res
13
+ import substance_painter.textureset as sp_ts
14
+
15
+ DEFAULTS = {
16
+ "texture_sets": None, # None = all
17
+ "bake": False, # True kicks off an async bake first (edits queue behind it)
18
+ "smart_material": None, # e.g. "Creature Skin" (searched in the shelf); None = skip
19
+ "base_color": [0.23, 0.2, 0.16], # sRGB 0-1, desaturated olive-brown
20
+ "scale_roughness": 0.78, # matte, sun-dried scales
21
+ "wet_roughness": 0.32, # moisture in folds / cavities
22
+ "wet_generator": "Dirt", # generator used as the cavity mask for wetness
23
+ "gloss_sets": ["eye", "mouth", "teeth", "tongue", "gum"],
24
+ "gloss_roughness": 0.12, # eyes / mouth: wet, specular
25
+ "export_dir": None, # absolute folder -> export PBR Metallic Roughness
26
+ }
27
+ P = dict(DEFAULTS)
28
+ P.update(globals().get("PARAMS") or {})
29
+ CT = sp_ts.ChannelType
30
+
31
+
32
+ def gray(v):
33
+ return sp_cm.Color(v, v, v)
34
+
35
+
36
+ def set_uniform(fill, channel, value):
37
+ """Uniform channel value; some Painter versions want a Color even for scalar channels."""
38
+ try:
39
+ fill.set_source(channel, value)
40
+ except Exception:
41
+ fill.set_source(channel, gray(value) if isinstance(value, float) else value)
42
+
43
+
44
+ def find_resource(query):
45
+ try:
46
+ hits = sp_res.search(query)
47
+ return hits[0] if hits else None
48
+ except Exception:
49
+ return None
50
+
51
+
52
+ def look_dev_set(ts, notes):
53
+ name = ts.name()
54
+ stack = ts.get_stack()
55
+ glossy = any(k in name.lower() for k in P["gloss_sets"])
56
+ pos = sp_ls.InsertPosition.from_textureset_stack(stack)
57
+
58
+ if P["smart_material"] and not glossy:
59
+ res = find_resource("u:smartmaterial " + P["smart_material"])
60
+ if res is None:
61
+ notes.append("smart material %r not found" % P["smart_material"])
62
+ else:
63
+ try:
64
+ sp_ls.insert_smart_material(pos, res.identifier())
65
+ notes.append("smart material: " + P["smart_material"])
66
+ except Exception as e:
67
+ notes.append("smart material failed: %s" % e)
68
+
69
+ base = sp_ls.insert_fill(sp_ls.InsertPosition.from_textureset_stack(stack))
70
+ base.set_name("MCP Base Skin" if not glossy else "MCP Wet Gloss")
71
+ base.active_channels = {CT.BaseColor, CT.Roughness, CT.Metallic}
72
+ if not glossy:
73
+ base.set_source(CT.BaseColor, sp_cm.Color(*P["base_color"]))
74
+ set_uniform(base, CT.Roughness, float(P["gloss_roughness"] if glossy else P["scale_roughness"]))
75
+ set_uniform(base, CT.Metallic, 0.0) # organic dielectric: never metallic
76
+ if glossy:
77
+ # base colour stays whatever the artist painted; only the gloss changes
78
+ base.active_channels = {CT.Roughness, CT.Metallic}
79
+ return {"texture_set": name, "treatment": "wet gloss", "roughness": P["gloss_roughness"]}
80
+
81
+ wet = sp_ls.insert_fill(sp_ls.InsertPosition.from_textureset_stack(stack))
82
+ wet.set_name("MCP Cavity Wetness")
83
+ wet.active_channels = {CT.Roughness}
84
+ set_uniform(wet, CT.Roughness, float(P["wet_roughness"]))
85
+ masked = False
86
+ try:
87
+ wet.add_mask(sp_ls.MaskBackground.Black)
88
+ gen = find_resource("u:generator " + P["wet_generator"])
89
+ if gen is not None:
90
+ sp_ls.insert_generator_effect(
91
+ sp_ls.InsertPosition.inside_node(wet, sp_ls.NodeStack.Mask), gen.identifier())
92
+ masked = True
93
+ else:
94
+ notes.append("generator %r not found; wetness left unmasked at low opacity" % P["wet_generator"])
95
+ except Exception as e:
96
+ notes.append("wetness mask failed: %s" % e)
97
+ if not masked:
98
+ try:
99
+ wet.set_opacity(0.25, CT.Roughness)
100
+ except Exception:
101
+ pass
102
+ return {"texture_set": name, "treatment": "aged scales + cavity wetness",
103
+ "roughness": [P["scale_roughness"], P["wet_roughness"]], "wet_masked": masked}
104
+
105
+
106
+ def run():
107
+ if not sp_proj.is_open():
108
+ raise RuntimeError("No Substance Painter project is open")
109
+ wanted = P["texture_sets"]
110
+ sets = [t for t in sp_ts.all_texture_sets() if wanted is None or t.name() in wanted]
111
+ if not sets:
112
+ raise RuntimeError("No matching texture sets: %s" % wanted)
113
+ notes, report = [], []
114
+ if P["bake"]:
115
+ import substance_painter.baking as sp_bake
116
+ if hasattr(sp_bake, "bake_async"):
117
+ for t in sets:
118
+ sp_bake.bake_async(t)
119
+ notes.append("bake started (async) for %d set(s)" % len(sets))
120
+ else:
121
+ # older builds bake the Baking-window selection, not an arbitrary list
122
+ if wanted is not None and len(sets) < len(sp_ts.all_texture_sets()):
123
+ raise RuntimeError("This Painter version can only bake the texture sets selected in the Baking "
124
+ "window; select them there, or omit texture_sets")
125
+ sp_bake.bake_selected_textures_async()
126
+ notes.append("bake started (async) for the Baking-window selection")
127
+ with sp_ls.ScopedModification("adobe-mcp creature look-dev"):
128
+ for t in sets:
129
+ report.append(look_dev_set(t, notes))
130
+ out = {"texture_sets": report, "notes": notes}
131
+ if P["export_dir"]:
132
+ import os
133
+ import substance_painter.export as sp_exp
134
+ os.makedirs(P["export_dir"], exist_ok=True) # Painter's export fails on a missing folder
135
+ cfg = {
136
+ "exportShaderParams": False,
137
+ "exportPath": P["export_dir"],
138
+ "defaultExportPreset": sp_res.ResourceID(context="starter_assets", name="PBR Metallic Roughness").url(),
139
+ "exportList": [{"rootPath": t.name()} for t in sets],
140
+ "exportParameters": [{"parameters": {"fileFormat": "png", "bitDepth": "16", "paddingAlgorithm": "infinite"}}],
141
+ }
142
+ res = sp_exp.export_project_textures(cfg)
143
+ out["export"] = {"status": str(res.status), "message": res.message,
144
+ "files": [p for paths in (res.textures or {}).values() for p in paths]}
145
+ return out
146
+
147
+
148
+ result = run()
package/server.mjs CHANGED
@@ -1,31 +1,92 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * adobe-mcp — Model Context Protocol server for the Adobe Creative Cloud suite (macOS).
3
+ * adobe-mcp — Model Context Protocol server for Adobe Creative Cloud, Blender and Substance 3D Painter
4
+ * (macOS and Windows).
4
5
  *
5
6
  * Bridges MCP tool calls into each app's scripting engine:
6
- * AE / Photoshop / Illustrator → osascript (DoScript / do javascript) → ExtendScript
7
- * Premiere Pro → mcp-bridge CEP panel (command-file handoff)
8
- * Character Animator → integrated around (PSD puppet authoring via Photoshop)
7
+ * AE → macOS: osascript DoScript · Windows: AfterFX.exe -r → ExtendScript
8
+ * Photoshop / Illus. → macOS: osascript do javascript · Windows: COM DoJavaScriptFile → ExtendScript
9
+ * InDesign → macOS: osascript do script · Windows: COM DoScript → ExtendScript
10
+ * Animate → .jsfl handed to Animate on the command line (result via file)
11
+ * Media Encoder → through Premiere's app.encoder (ame_* tools)
12
+ * Premiere Pro → mcp-bridge CEP panel (command-file handoff, both OSes)
13
+ * Character Animator → integrated around (PSD puppet authoring via Photoshop)
14
+ * Blender → Python (bpy) via live add-on socket or headless background process
15
+ * Substance 3D Painter → Python via remote scripting (HTTP, port 60041)
16
+ * Poly Haven / ambientCG → free CC0 texture + HDRI libraries (HTTPS APIs, local cache)
9
17
  *
10
- * Adapters register namespaced tools (ae_*, ps_*, ai_*, ppro_*, ch_*), plus cross-app
11
- * workflow tools (asset registry, layered handoffs, per-app script libraries).
18
+ * `npx @ajsmonty/adobe-mcp doctor|install|--help` runs the CLI instead of the server.
19
+ * ADOBE_MCP_APPS=ae,ps,... limits which app tool sets are registered (default: all).
12
20
  */
21
+ import fs from "node:fs";
22
+ import path from "node:path";
23
+ import { fileURLToPath } from "node:url";
13
24
 
14
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
15
- import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
25
+ const ROOT = path.dirname(fileURLToPath(import.meta.url));
26
+ const PKG = JSON.parse(fs.readFileSync(path.join(ROOT, "package.json"), "utf8"));
16
27
 
17
- import { register as registerAE } from "./adapters/ae.mjs";
18
- import { register as registerPS } from "./adapters/ps.mjs";
19
- import { register as registerAI } from "./adapters/ai.mjs";
20
- import { register as registerPPRO } from "./adapters/ppro.mjs";
21
- import { register as registerCH } from "./adapters/ch.mjs";
22
- import { register as registerWorkflow, makeRegisterAsset } from "./workflow/workflow.mjs";
23
- import { register as registerKnowledge, instructionsDigest } from "./knowledge/knowledge.mjs";
28
+ // ---- CLI mode --------------------------------------------------------------------------
29
+ const { CLI_COMMANDS, main } = await import("./cli/index.mjs");
30
+ const cmd = process.argv[2];
31
+ if (cmd && CLI_COMMANDS.has(cmd)) process.exit(await main(process.argv.slice(2)));
24
32
 
25
- const server = new McpServer(
26
- { name: "adobe-mcp", version: "1.1.0" },
27
- { instructions: instructionsDigest() }
28
- );
33
+ // ---- server mode -----------------------------------------------------------------------
34
+ const { McpServer } = await import("@modelcontextprotocol/sdk/server/mcp.js");
35
+ const { StdioServerTransport } = await import("@modelcontextprotocol/sdk/server/stdio.js");
36
+ const { register: registerWorkflow, makeRegisterAsset } = await import("./workflow/workflow.mjs");
37
+ const { register: registerKnowledge, instructionsDigest } = await import("./knowledge/knowledge.mjs");
38
+ const { register: registerSetup } = await import("./workflow/setup.mjs");
39
+ const { instrument } = await import("./core/telemetry.mjs");
40
+
41
+ /** Tool sets that can be switched with ADOBE_MCP_APPS: each is a list of [module, export]. Workflow + knowledge are always on. */
42
+ export const MODULES = {
43
+ ae: [["./adapters/ae.mjs", "register"], ["./adapters/ae_more.mjs", "register"]],
44
+ ps: [["./adapters/ps.mjs", "register"], ["./adapters/ps_ai_more.mjs", "registerPS"]],
45
+ ai: [["./adapters/ai.mjs", "register"], ["./adapters/ps_ai_more.mjs", "registerAI"]],
46
+ id: [["./adapters/id.mjs", "register"]],
47
+ ppro: [["./adapters/ppro.mjs", "register"], ["./adapters/ppro_more.mjs", "register"]],
48
+ an: [["./adapters/an.mjs", "register"]],
49
+ ch: [["./adapters/ch.mjs", "register"]],
50
+ blender: [["./adapters/blender.mjs", "register"]],
51
+ substance: [["./adapters/substance.mjs", "register"]],
52
+ textures: [["./adapters/texlib.mjs", "register"]],
53
+ vfx: [["./workflow/vfx.mjs", "register"]],
54
+ files: [["./adapters/assets.mjs", "register"]],
55
+ };
56
+ const ALIASES = {
57
+ aftereffects: "ae", photoshop: "ps", illustrator: "ai", indesign: "id", premiere: "ppro", premierepro: "ppro",
58
+ mediaencoder: "ppro", ame: "ppro", animate: "an", characteranimator: "ch", texlib: "textures", assets: "files",
59
+ };
60
+
61
+ function enabledModules(spec = process.env.ADOBE_MCP_APPS) {
62
+ if (!spec || !spec.trim() || spec.trim() === "all") return Object.keys(MODULES);
63
+ const wanted = new Set();
64
+ for (const raw of spec.split(/[\s,]+/).filter(Boolean)) {
65
+ const k = ALIASES[raw.toLowerCase().replace(/[-_ ]/g, "")] || raw.toLowerCase();
66
+ if (MODULES[k]) wanted.add(k);
67
+ else console.error(`adobe-mcp: ignoring unknown app "${raw}" in ADOBE_MCP_APPS (valid: ${Object.keys(MODULES).join(", ")})`);
68
+ }
69
+ // Character Animator puppets are authored in Photoshop; Blender texturing uses the texture libraries.
70
+ if (wanted.has("ch")) wanted.add("ps");
71
+ if (wanted.has("blender")) wanted.add("textures");
72
+ return Object.keys(MODULES).filter((k) => wanted.has(k));
73
+ }
74
+
75
+ const enabled = enabledModules();
76
+ const server = new McpServer({ name: "adobe-mcp", version: PKG.version }, { instructions: instructionsDigest() });
77
+ const flush = instrument(server, { version: PKG.version, apps: enabled });
78
+
79
+ // When the Barrows AE Bridge extension is installed, hide our basic After Effects tools that it
80
+ // covers, so Claude doesn't get two overlapping sets. Our other AE tools stay.
81
+ const { barrowsInstalled, SUPERSEDED_BY_BARROWS } = await import("./core/barrows.mjs");
82
+ if (barrowsInstalled()) {
83
+ const reg = server.registerTool.bind(server);
84
+ server.registerTool = (name, def, handler) => {
85
+ const tool = reg(name, def, handler);
86
+ if (SUPERSEDED_BY_BARROWS.has(name)) tool.disable();
87
+ return tool;
88
+ };
89
+ }
29
90
 
30
91
  const ctx = {
31
92
  text: (obj) => ({
@@ -38,14 +99,18 @@ const ctx = {
38
99
  registerAsset: makeRegisterAsset(),
39
100
  };
40
101
 
41
- registerAE(server, ctx);
42
- registerPS(server, ctx);
43
- registerAI(server, ctx);
44
- registerPPRO(server, ctx);
45
- registerCH(server, ctx);
102
+ for (const k of enabled) for (const [file, fn] of MODULES[k]) (await import(file))[fn](server, ctx);
46
103
  registerWorkflow(server, ctx);
47
104
  registerKnowledge(server, ctx);
105
+ registerSetup(server, ctx);
106
+
107
+ const shutdown = async () => {
108
+ await flush();
109
+ process.exit(0);
110
+ };
111
+ process.once("SIGINT", shutdown);
112
+ process.once("SIGTERM", shutdown);
113
+ process.stdin.once("end", shutdown);
48
114
 
49
- const transport = new StdioServerTransport();
50
- await server.connect(transport);
51
- console.error("adobe-mcp ready (ae, ps, ai, ppro, ch + workflow + knowledge)");
115
+ await server.connect(new StdioServerTransport());
116
+ console.error(`adobe-mcp ${PKG.version} ready on ${process.platform} (${enabled.join(", ")} + workflow + knowledge + setup)`);
@@ -0,0 +1,106 @@
1
+ // Setup from inside the chat, for people who never open a terminal: the same checks and installer
2
+ // as `npx @ajsmonty/adobe-mcp doctor` / `install`, as tools, plus a guided prompt and release notes.
3
+ import fs from "node:fs";
4
+ import path from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+ import { z } from "zod";
7
+
8
+ const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
9
+
10
+ /** The newest `count` sections of CHANGELOG.md (each starts with "## "). */
11
+ export function latestNotes(markdown, count = 1) {
12
+ const parts = markdown.split(/\n(?=## )/).filter((p) => p.startsWith("## "));
13
+ return parts.slice(0, Math.max(1, count)).join("\n").trim();
14
+ }
15
+
16
+ export function register(server, { text, errText }) {
17
+ server.registerTool(
18
+ "adobe_setup_check",
19
+ {
20
+ title: "Check Adobe setup",
21
+ description:
22
+ "Check this computer for everything the Adobe tools need: which Adobe apps (and Blender, Substance) are installed " +
23
+ "and running, the MCP Bridge panel for Premiere Pro and After Effects, PlayerDebugMode, After Effects' scripting " +
24
+ "preference, Windows COM, and the Barrows AE Bridge. Each problem comes with its fix. live: true also runs a " +
25
+ "one-line script in each open app. Start here when an Adobe tool fails or when someone asks to set things up.",
26
+ inputSchema: { live: z.boolean().optional().describe("Also run a real one-line script in each open app (default false).") },
27
+ },
28
+ async ({ live }) => {
29
+ try {
30
+ const { collectChecks } = await import("../cli/doctor.mjs");
31
+ const checks = await collectChecks({ live: !!live });
32
+ const problems = checks.filter((c) => c.status === "fail");
33
+ return text({ ready: problems.length === 0, problems: problems.length, checks });
34
+ } catch (e) {
35
+ return errText(e);
36
+ }
37
+ }
38
+ );
39
+
40
+ server.registerTool(
41
+ "adobe_install_panel",
42
+ {
43
+ title: "Install the MCP Bridge panel",
44
+ description:
45
+ "Install the MCP Bridge panel for Premiere Pro and After Effects and turn on PlayerDebugMode (needed for unsigned " +
46
+ "panels). Writes only to the user's own Adobe extensions folder and preferences. Premiere needs the panel; After " +
47
+ "Effects uses it when present (faster, and no scripting preference or Automation prompt). Ask the user before " +
48
+ "running it, and tell them to restart Premiere / After Effects afterwards.",
49
+ inputSchema: {
50
+ dry_run: z.boolean().optional().describe("Only report what would change (default false)."),
51
+ force: z.boolean().optional().describe("Install even if neither Premiere Pro nor After Effects is found."),
52
+ },
53
+ },
54
+ async ({ dry_run, force }) => {
55
+ try {
56
+ const { install } = await import("../cli/install.mjs");
57
+ const lines = [];
58
+ const sink = { log: (m) => lines.push(String(m).trim()), error: (m) => lines.push("ERROR: " + String(m).trim()) };
59
+ const code = await install({ "dry-run": !!dry_run, panel: !!force }, sink);
60
+ return text({ ok: code === 0, steps: lines.filter(Boolean) });
61
+ } catch (e) {
62
+ return errText(e);
63
+ }
64
+ }
65
+ );
66
+
67
+ server.registerTool(
68
+ "adobe_whats_new",
69
+ {
70
+ title: "What's new in adobe-mcp",
71
+ description: "Release notes for this version of the Adobe tools; versions > 1 also shows earlier releases.",
72
+ inputSchema: { versions: z.number().int().min(1).max(20).optional().describe("How many releases to show (default 1).") },
73
+ },
74
+ async ({ versions }) => {
75
+ try {
76
+ return text(latestNotes(fs.readFileSync(path.join(ROOT, "CHANGELOG.md"), "utf8"), versions ?? 1));
77
+ } catch (e) {
78
+ return errText(e);
79
+ }
80
+ }
81
+ );
82
+
83
+ server.registerPrompt(
84
+ "setup_adobe",
85
+ {
86
+ title: "Set up Adobe for Claude",
87
+ description: "Guided walkthrough: check this computer, then help finish the one-time setup.",
88
+ },
89
+ () => ({
90
+ messages: [
91
+ {
92
+ role: "user",
93
+ content: {
94
+ type: "text",
95
+ text:
96
+ "Help me set up the Adobe tools. Call adobe_setup_check, then explain what's ready and what isn't in plain " +
97
+ "words, one line per app I have installed. For each problem, give the fix. If the MCP Bridge panel is " +
98
+ "missing or out of date, offer to run adobe_install_panel, and only run it if I say yes. Things I must do " +
99
+ "inside an Adobe app (a preference, restarting it), give me the exact menu path. Finish by suggesting one " +
100
+ "small thing to try in an app that's ready.",
101
+ },
102
+ },
103
+ ],
104
+ })
105
+ );
106
+ }
@@ -0,0 +1,136 @@
1
+ // VFX pipeline planner: turns a creature-shot brief into physically derived timing and the
2
+ // ordered Blender → Substance → Blender → After Effects tool calls that execute it.
3
+ import { z } from "zod";
4
+ import path from "node:path";
5
+ import { WORKSPACE } from "../core/workspace.mjs";
6
+
7
+ const G = 9.81;
8
+
9
+ /** Same gait model as scripts/blender/Creature_Walk_Cinematic.py (keep in sync). */
10
+ export function deriveGait({ hip_height_m = 3.1, froude = 0.055, mass_kg = 8000, fps = 24 }) {
11
+ const v = Math.sqrt(froude * G * hip_height_m);
12
+ const stride = 2.3 * froude ** 0.3 * hip_height_m; // Alexander (1976)
13
+ const cycle_s = stride / v;
14
+ return {
15
+ speed_mps: +v.toFixed(3),
16
+ speed_kmh: +(v * 3.6).toFixed(2),
17
+ stride_m: +stride.toFixed(3),
18
+ cycle_s: +cycle_s.toFixed(3),
19
+ cycle_frames: +(cycle_s * fps).toFixed(1),
20
+ step_frames: +((cycle_s * fps) / 2).toFixed(1),
21
+ breath_s: +(4.0 * (mass_kg / 70) ** 0.26 * 0.5).toFixed(2),
22
+ gait: froude < 0.5 ? "walk" : froude < 1 ? "fast walk / trot transition" : "run",
23
+ };
24
+ }
25
+
26
+ export function register(server, { text, errText }) {
27
+ server.registerTool(
28
+ "vfx_plan_creature_shot",
29
+ {
30
+ title: "Plan a photo-real creature shot (Blender → Substance → AE)",
31
+ description:
32
+ "For briefs like 'a photo-real dinosaur walking past the camera while turning its neck'. Derives " +
33
+ "physical timing from size and mass (Froude-scaled speed, Alexander stride, steps per frame, " +
34
+ "breathing period) and returns the four-stage pipeline as concrete tool calls: 1) block + animate " +
35
+ "in Blender (run_script Creature_Walk_Cinematic.py), 2) look-dev in Substance Painter " +
36
+ "(Creature_Skin_LookDev.py + export), 3) bind textures and render passes in Blender, " +
37
+ "4) composite in After Effects (Cinematic_3D_Composite.jsx). Call this first, then run each step, " +
38
+ "verifying visually (blender_render_frame / ae_save_frame) between steps.",
39
+ inputSchema: {
40
+ brief: z.string().optional().describe("The shot description, echoed into the plan."),
41
+ hip_height_m: z.number().optional().describe("Hip height in meters (default 3.1, adult T. rex)."),
42
+ mass_kg: z.number().optional().describe("Body mass (default 8000)."),
43
+ froude: z.number().optional().describe("Gait intensity v²/(g·h): 0.05 plodding, 0.25 brisk, 0.5 walk→run (default 0.055)."),
44
+ fps: z.number().optional().describe("Frame rate (default 24)."),
45
+ duration_s: z.number().optional().describe("Shot length in seconds (default 10)."),
46
+ lens_mm: z.number().optional().describe("Focal length on a 36 mm sensor (default 35)."),
47
+ cam_distance_m: z.number().optional().describe("Camera distance from the walk line (default 14)."),
48
+ hero_mesh: z.string().optional().describe("Existing Blender object to drive (default: proxy blocking rig only)."),
49
+ shot_dir: z.string().optional().describe("Absolute folder for renders/textures (default <workspace>/shots/creature)."),
50
+ },
51
+ },
52
+ async (a) => {
53
+ try {
54
+ const fps = a.fps ?? 24;
55
+ const g = deriveGait({ hip_height_m: a.hip_height_m, froude: a.froude, mass_kg: a.mass_kg, fps });
56
+ const shot = a.shot_dir ?? path.join(WORKSPACE, "shots", "creature");
57
+ const blend = path.join(shot, "creature_shot.blend");
58
+ const params = {
59
+ fps,
60
+ duration_s: a.duration_s ?? 10,
61
+ hip_height_m: a.hip_height_m ?? 3.1,
62
+ mass_kg: a.mass_kg ?? 8000,
63
+ froude: a.froude ?? 0.055,
64
+ lens_mm: a.lens_mm ?? 35,
65
+ cam_distance_m: a.cam_distance_m ?? 14,
66
+ output_dir: path.join(shot, "render"),
67
+ ...(a.hero_mesh ? { bind: { [a.hero_mesh]: "Hips" } } : {}),
68
+ };
69
+ const plan = {
70
+ brief: a.brief ?? null,
71
+ physics: {
72
+ ...g,
73
+ notes: [
74
+ `A ${params.mass_kg} kg animal with ${params.hip_height_m} m hips walks at ${g.speed_kmh} km/h: one step every ${g.step_frames} frames at ${fps} fps.`,
75
+ "Feet are planted for 62% of each cycle (duty factor) — heavy walkers never have an airborne phase.",
76
+ "Hips drop just after each contact (weight acceptance), sway over the stance foot and roll toward the swing side.",
77
+ "Neck and tail lag the hips by 3 frames per joint (overlapping action); the head is gaze-stabilised and leads the look-turn.",
78
+ "Every footfall puts a mass- and distance-scaled impact shake into the handheld camera; timeline markers mark contacts.",
79
+ ],
80
+ },
81
+ stages: [
82
+ {
83
+ stage: "1. Analyze & block + 2. Animate (Blender)",
84
+ tool: "run_script",
85
+ args: { app: "blender", name: "Creature_Walk_Cinematic.py", mode: "background", params, save_as: blend },
86
+ verify: { tool: "blender_render_frame", args: { blend_file: blend, frame: Math.round(params.duration_s * fps * 0.55) } },
87
+ },
88
+ {
89
+ stage: "2b. Light & dress to match the plate (free CC0 libraries)",
90
+ tool: "texture_search",
91
+ args: { type: "hdri", query: "<sky that matches the plate: e.g. 'partly cloudy afternoon'>" },
92
+ then: [
93
+ { tool: "blender_set_hdri", args: { source: "<from search>", id: "<from search>", blend_file: blend, save_as: blend, mode: "background", rotation_deg: 0 } },
94
+ { tool: "blender_apply_texture", args: { objects: ["<set-dressing objects>"], source: "<from texture_search query='forest ground'>", id: "<id>", blend_file: blend, save_as: blend, mode: "background", tile_m: 2 } },
95
+ ],
96
+ note: "Rotate the HDRI until CG shadow direction matches the plate. The ground is a shadow catcher, so only texture set-dressing and props.",
97
+ },
98
+ {
99
+ stage: "3. Texture & materialize (Substance 3D Painter, project with the hero mesh open)",
100
+ tool: "run_script",
101
+ args: {
102
+ app: "substance",
103
+ name: "Creature_Skin_LookDev.py",
104
+ params: { bake: true, export_dir: path.join(shot, "textures") },
105
+ },
106
+ note: "Bake is async: if the export runs before the bake finishes, re-run substance_export_textures afterwards.",
107
+ },
108
+ {
109
+ stage: "3b. Bind textures + render passes (Blender)",
110
+ tool: "run_script",
111
+ args: {
112
+ app: "blender",
113
+ name: "Creature_Walk_Cinematic.py",
114
+ mode: "background",
115
+ blend_file: blend,
116
+ save_as: blend,
117
+ params: { ...params, texture_dir: path.join(shot, "textures") },
118
+ },
119
+ then: { tool: "blender_render_animation", args: { blend_file: blend, mode: "background" } },
120
+ note: a.hero_mesh ? undefined : "No hero_mesh given: proxies render as the creature (blocking pass).",
121
+ },
122
+ {
123
+ stage: "4. Composite & polish (After Effects, plate layer named BG_Plate in the active comp)",
124
+ tool: "run_script",
125
+ args: { app: "ae", name: "Cinematic_3D_Composite.jsx", params: { render_dir: params.output_dir, fps } },
126
+ verify: { tool: "ae_save_frame", args: { comp_name: "<your comp>" } },
127
+ },
128
+ ],
129
+ };
130
+ return text(plan);
131
+ } catch (e) {
132
+ return errText(e);
133
+ }
134
+ }
135
+ );
136
+ }