dsh-game-material-master 0.2.1 → 0.4.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.
- package/README.en.md +383 -0
- package/README.md +83 -6
- package/lib/client.js +4436 -877
- package/lib/config.js +45 -5
- package/lib/directions.js +120 -5
- package/lib/index.js +375 -12
- package/lib/jsonio.js +49 -3
- package/lib/links.js +10 -2
- package/lib/tilegen.js +1702 -0
- package/lib/tilegeom.js +1392 -0
- package/lib/tilemap.js +560 -0
- package/lib/tilemedia.js +243 -0
- package/lib/tools.js +397 -19
- package/lib/wire.js +100 -4
- package/package.json +3 -2
package/README.en.md
ADDED
|
@@ -0,0 +1,383 @@
|
|
|
1
|
+
English | [中文](https://github.com/universe-st/dsh-game-material-master/blob/main/README.md)
|
|
2
|
+
|
|
3
|
+
# Game Material Master
|
|
4
|
+
|
|
5
|
+
**Start from a single character sheet and batch-produce the assets your game actually needs.**
|
|
6
|
+
|
|
7
|
+
Volcengine Ark **Seedream** handles image generation, **MiniMax** handles image-to-video, and keying,
|
|
8
|
+
frame extraction, pixel quantization and spritesheet composition all happen locally through `ffmpeg` —
|
|
9
|
+
no system image libraries required, and your assets are never uploaded to a third-party service.
|
|
10
|
+
|
|
11
|
+
[](https://www.npmjs.com/package/dsh-game-material-master)
|
|
12
|
+
[](LICENSE)
|
|
13
|
+
|
|
14
|
+

|
|
15
|
+
|
|
16
|
+
> **Up and running in 30 seconds**: `dsh plugin --profile web add dsh-game-material-master` → restart DSH →
|
|
17
|
+
> click "Game Material Master" in the sidebar → enter the two API keys in settings → create a project,
|
|
18
|
+
> upload your character sheet → click "Generate turn video" (the default path: the character rotates steadily
|
|
19
|
+
> in place for one full turn, then the eight directions are cut out automatically; switch the method in
|
|
20
|
+
> stage ① if you'd rather generate each direction separately).
|
|
21
|
+
>
|
|
22
|
+
> The sidebar entry also carries a **small chevron menu button**: click it to pop up the five features and
|
|
23
|
+
> jump straight into the one you want. Features you do not use can be turned off in settings (see
|
|
24
|
+
> "Feature management").
|
|
25
|
+
|
|
26
|
+
All four modules share the same "generate → review → re-run" workbench. Every stage can be **redone on its
|
|
27
|
+
own**, and every asset can be **approved item by item**. The "review mode" lets an agent approve each step
|
|
28
|
+
and move on automatically, or stop at every step and wait for your go-ahead.
|
|
29
|
+
|
|
30
|
+
| Module | What it does | What you get |
|
|
31
|
+
|---|---|---|
|
|
32
|
+
| **① Eight-direction sprite sheet** | One character sheet → 8 directions × 8 frames (default "turn capture": eight directions cut from one rotation video) | A walk spritesheet you can drive with WASD |
|
|
33
|
+
| **② Image generation** | Prompt (optionally with reference images) → images → green-screen keying | Clean transparent PNG character art / props |
|
|
34
|
+
| **③ Sequence frames** | First/last frame or a reference video → generate video → extract frames → key | A horizontally laid out, loopable sequence |
|
|
35
|
+
| **⑤ Map tile generation** | Isometric tiles → assemble a whole map | A tile pack (PNGs) + map PNG + layout JSON |
|
|
36
|
+
| ~~④ Rigged animation~~ | Part extraction → assembly → skeletal animation → Spine / DragonBones atlas | **Experimental, not covered in this document** |
|
|
37
|
+
|
|
38
|
+
> 💡 **Module ⑤ "Map tile generation" is built on one idea: geometry by code, content by AI.**
|
|
39
|
+
> The diamond template is rendered locally (strict 2:1 isometric) and the AI only fills its interior with the
|
|
40
|
+
> requested terrain. Each result is then measured and affine-aligned back to the standard diamond, and the map
|
|
41
|
+
> is assembled locally on the isometric grid. Geometry is therefore always exact — tiles never show seams, and
|
|
42
|
+
> re-assembling with the same seed is pixel-identical. Measured: letting the model draw the diamond freely
|
|
43
|
+
> gives ratios of 1.03–1.55 (nowhere near 2:1), while template filling hits 100%.
|
|
44
|
+
|
|
45
|
+
> ⚠️ **Module ④ "Rigged animation" is still experimental and not yet finished**: the quality of part extraction
|
|
46
|
+
> depends on the image model, automatic assembly and bone inference frequently need manual correction on real
|
|
47
|
+
> character art (agent visual priors or manual dragging), and the exported Spine / DragonBones output has not
|
|
48
|
+
> seen enough engine-side validation. The module carries an "experimental" badge in the UI and shows a dialog
|
|
49
|
+
> every time you enter it. This document only covers the first three modules.
|
|
50
|
+
> If you need it — or want to help make it solid — you're welcome to join in at the
|
|
51
|
+
> [GitHub repository](https://github.com/universe-st/dsh-game-material-master).
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## ① Eight-direction sprite sheet
|
|
56
|
+
|
|
57
|
+
Feed in one front-facing character sheet and get all eight directions in one pass:
|
|
58
|
+
**green-screen images → walk videos → sequence frames → final spritesheet → interactive preview**.
|
|
59
|
+
|
|
60
|
+
```mermaid
|
|
61
|
+
flowchart LR
|
|
62
|
+
S(["Character sheet"]) --> I["① Eight green-screen directions"] --> V["② Walk videos"] --> F["③ Extract sequence frames"] --> P["④ Compose spritesheet"] --> W(["⑤ WASD preview"])
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### The two generation methods: turn capture (default) / per-direction generation
|
|
66
|
+
|
|
67
|
+
There are two ways to produce the eight direction images, and the output is identical either way
|
|
68
|
+
(`images/<direction>.png`), so the next four steps don't change:
|
|
69
|
+
|
|
70
|
+
| | **Turn capture (default)** | Per-direction generation (alternative) |
|
|
71
|
+
|---|---|---|
|
|
72
|
+
| How | Generate **one** green-screen video of the character turning steadily in place for a full rotation, then cut frames for the eight directions along the timeline | Generate each of the eight directions separately, in dependency order |
|
|
73
|
+
| Cost | One video call | Eight image calls |
|
|
74
|
+
| Consistency | **All eight directions share one source**: same character, same lighting, same art style | The model has to re-interpret the character every time, so face shape, hair color and clothing tend to drift |
|
|
75
|
+
| Adjusting position | The timeline has **eight draggable circles** — drag to a frame and that frame is cut (re-cut locally, free and instant) | Regenerate each image |
|
|
76
|
+
|
|
77
|
+
The row of circles in the UI is the capture position for each of the eight directions, and the thumbnail
|
|
78
|
+
strip below it is the candidate frames for the whole rotation — drag against the picture and release to
|
|
79
|
+
re-cut that one image (this also invalidates that direction's walk video and sequence frames automatically,
|
|
80
|
+
so old and new orientations never get mixed together). The default positions assume an even split
|
|
81
|
+
"starting from the front, one full rotation at constant speed"; when the model actually turns in a different
|
|
82
|
+
direction or at a different pace, just drag the circles, or click "turn direction" to re-order them. Changing
|
|
83
|
+
the candidate frame count (8–64) re-extracts automatically and rescales any positions you have dragged.
|
|
84
|
+
|
|
85
|
+
### How to use it
|
|
86
|
+
|
|
87
|
+
1. **Create a project → upload a character sheet**, then write your prompts (turn capture uses **one turn-video
|
|
88
|
+
prompt**; per-direction generation uses one prompt per direction, plus a shared "common suffix prompt" for
|
|
89
|
+
all eight).
|
|
90
|
+
2. **Generate turn video** (the default path): the character rotates steadily in place for one full turn
|
|
91
|
+
against a green screen. Once the video arrives, the plugin extracts candidate frames and cuts out the eight
|
|
92
|
+
directions automatically — you usually don't need to touch anything. **Per-direction generation** (the
|
|
93
|
+
alternative) is **generate all in one click**: the eight directions produce green-screen full-body images in
|
|
94
|
+
dependency order. Per image you can see the elapsed time and which model was used; if you don't like one,
|
|
95
|
+
**regenerate** that image, or expand **edit prompt** to change just that one.
|
|
96
|
+
3. **Generate all videos**: make the character walk three steps in place in each direction. This is the most
|
|
97
|
+
expensive and slowest step (1–6 minutes per clip).
|
|
98
|
+
4. **Extract all sequence frames**: each video is sampled evenly across its duration; uniform cropping, scaling
|
|
99
|
+
and **pixel-art quantization** all happen here too.
|
|
100
|
+
5. **Compose spritesheet**: remove the green screen and stitch the rows into one spritesheet; drag rows with
|
|
101
|
+
↑↓ to reorder, and you can save parameters before composing.
|
|
102
|
+
6. **Walk preview**: drive the character with WASD or the arrow keys — whether the eight directions blend
|
|
103
|
+
smoothly is obvious at a glance.
|
|
104
|
+
|
|
105
|
+
### ① Eight green-screen directions
|
|
106
|
+
|
|
107
|
+
**Turn capture (default)**: one green-screen video of "a steady full rotation in place", cut into eight
|
|
108
|
+
directions along the timeline; the eight circles on the axis are their capture positions — drag to change
|
|
109
|
+
them and release to re-cut instantly (locally, free).
|
|
110
|
+
|
|
111
|
+

|
|
112
|
+
|
|
113
|
+
**Per-direction generation (alternative)**: each of the eight directions is generated separately; single
|
|
114
|
+
images are sharper, which suits cases where you only need a few directions or want maximum per-image quality.
|
|
115
|
+
|
|
116
|
+

|
|
117
|
+
|
|
118
|
+
### ② Walk videos
|
|
119
|
+
|
|
120
|
+

|
|
121
|
+
|
|
122
|
+
### ③ Extract sequence frames
|
|
123
|
+
|
|
124
|
+

|
|
125
|
+
|
|
126
|
+
### ④ Key green screen and compose spritesheet
|
|
127
|
+
|
|
128
|
+

|
|
129
|
+
|
|
130
|
+
### ⑤ Walk preview
|
|
131
|
+
|
|
132
|
+

|
|
133
|
+
|
|
134
|
+
> **Re-running a single step**: if any step isn't right, redo just that step — a single direction or a single
|
|
135
|
+
> stage — instead of starting the whole batch over.
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## ② Image generation
|
|
140
|
+
|
|
141
|
+
Generate images from a prompt, with optional reference images. After generation the green screen is
|
|
142
|
+
**keyed automatically** into a transparent PNG — or you can upload an existing image and run only the keying,
|
|
143
|
+
without spending anything on generation.
|
|
144
|
+
|
|
145
|
+
### How to use it
|
|
146
|
+
|
|
147
|
+
1. Write the main prompt; put requirements you reuse across batches (for example "no text watermarks") into the
|
|
148
|
+
**common suffix prompt**.
|
|
149
|
+
2. Optional: drop in **reference images** (up to 10); with references present, it runs image-to-image. To cite
|
|
150
|
+
several of them, refer to "image one", "image two" in the prompt.
|
|
151
|
+
3. Pick the model / size / count and click **Generate**.
|
|
152
|
+
4. In the results area, review **image by image**: approve, download the PNG, regenerate, delete. The background
|
|
153
|
+
percentage is shown right there so you can judge how clean the keying is.
|
|
154
|
+
|
|
155
|
+

|
|
156
|
+
|
|
157
|
+

|
|
158
|
+
|
|
159
|
+
---
|
|
160
|
+
|
|
161
|
+
## ③ Sequence frames
|
|
162
|
+
|
|
163
|
+
A more "one shot" path than the eight-direction sheet: give it a first-frame image (or a reference image plus a
|
|
164
|
+
reference video) and it generates a looping motion directly, then extracts frames, keys them, composes them
|
|
165
|
+
horizontally and **plays the loop in place for preview**.
|
|
166
|
+
|
|
167
|
+
```mermaid
|
|
168
|
+
flowchart LR
|
|
169
|
+
A(["First/last frame or reference image + reference video"]) --> V["Generate video"] --> F["Extract sequence frames"] --> K["Key green screen + compose horizontally"] --> L(["Loop playback review"])
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### How to use it
|
|
173
|
+
|
|
174
|
+
1. Pick a mode — the platform makes the two mutually exclusive:
|
|
175
|
+
- **First/last frame mode**: one image as the starting frame (the last frame is optional);
|
|
176
|
+
- **Multimodal reference mode**: reference image + reference video, used to constrain style and motion.
|
|
177
|
+
2. Write a prompt, pick the model / duration (4–15 seconds) / resolution, and click **Generate video**.
|
|
178
|
+
3. **Extract sequence frames**: frame extraction, uniform cropping, pixel quantization.
|
|
179
|
+
4. **Green-screen keying and composition**: tune the keying parameters and compose the horizontal strip; the
|
|
180
|
+
preview area on the right plays it back in a loop at the frame rate — **whether the motion flows and whether
|
|
181
|
+
the keyed edges stay stable is immediately visible in playback**.
|
|
182
|
+
5. **Review**: approve each of the three steps.
|
|
183
|
+
|
|
184
|
+

|
|
185
|
+
|
|
186
|
+

|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## Driving it from chat
|
|
191
|
+
|
|
192
|
+
**Every feature of all four modules** (including the experimental rigged animation) **is available through
|
|
193
|
+
chat**. The plugin registers the whole pipeline as `game_material_*` tools, so an agent can drive it forward,
|
|
194
|
+
wait, review, and also stop at each step for you to approve.
|
|
195
|
+
|
|
196
|
+
| Tool | What it does |
|
|
197
|
+
|---|---|
|
|
198
|
+
| `game_material_intake` | **Step 0 of the fixed workflow**: nail down the key parameters and review mode before doing anything |
|
|
199
|
+
| `game_material_call` | Universal channel: every remote method of the plugin is individually callable, covering all features |
|
|
200
|
+
| `game_material_upload` | Upload assets by local file path (character sheet / reference image / first and last frames / parts…) |
|
|
201
|
+
| `game_material_reviewMode` | Record the review mode: `auto` approves automatically / `manual` requires human approval at each step |
|
|
202
|
+
| `game_material_status` | See the current progress and which step to do now |
|
|
203
|
+
| `game_material_wait` | Block until "no task is running"; what comes back is a reviewable state |
|
|
204
|
+
| `game_material_review` | Produce a **review package**: absolute URL, status, approval flag and deep link for every asset |
|
|
205
|
+
| `game_material_approve` | Approve / un-approve |
|
|
206
|
+
|
|
207
|
+
Review links are **deep links**: an `openUrl` posted by the agent in its reply takes you straight to the
|
|
208
|
+
matching plugin page when clicked, landing on the right module / project / stage without any navigating
|
|
209
|
+
on your part.
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## Installation
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
# install from npm
|
|
217
|
+
dsh plugin --profile web add dsh-game-material-master
|
|
218
|
+
|
|
219
|
+
# install from a local directory (during development)
|
|
220
|
+
dsh plugin --profile web add /path/to/dsh-game-material-master
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
The package is published to npm: [dsh-game-material-master](https://www.npmjs.com/package/dsh-game-material-master)
|
|
224
|
+
(currently `0.1.1`, `latest`). It has no runtime dependencies, so `dsh plugin add` is all you need.
|
|
225
|
+
|
|
226
|
+
After installing, **restart DSH** (the host half is loaded at startup). The browser half is read from
|
|
227
|
+
`lib/client.js` on disk on each request, so refreshing the browser is enough for it to take effect.
|
|
228
|
+
|
|
229
|
+
**Dependencies**: `ffmpeg` / `ffprobe` must be on your `PATH` (macOS: `brew install ffmpeg`), or you can
|
|
230
|
+
point `FFMPEG_PATH` / `FFPROBE_PATH` at absolute paths. The package has **no runtime npm dependencies** —
|
|
231
|
+
`zod`, `cordis` and friends all resolve from DSH's own installation tree.
|
|
232
|
+
|
|
233
|
+
> When upgrading from the older `dsh-8dir-sprites`, the first startup migrates the data directory
|
|
234
|
+
> automatically and your existing projects carry over seamlessly.
|
|
235
|
+
|
|
236
|
+
## Configuration
|
|
237
|
+
|
|
238
|
+
**Settings → Game Material Master**:
|
|
239
|
+
|
|
240
|
+

|
|
241
|
+
|
|
242
|
+
| Item | Description |
|
|
243
|
+
|---|---|
|
|
244
|
+
| Volcengine Ark API Key | "Test connection" really generates a 1K thumbnail (a small charge) and validates both the key and the model |
|
|
245
|
+
| Image model | Defaults to `doubao-seedream-5-0-flash-260915`; switchable to 5.0 Pro / Lite / 4.5 |
|
|
246
|
+
| MiniMax API Key | "Test connection" is free and can tell an invalid key apart from other errors |
|
|
247
|
+
| Video model | Defaults to `MiniMax-H3` (v2 protocol); Hailuo / I2V use v1; the UCloud version of H3 is selected explicitly |
|
|
248
|
+
| Base URL | Host root, without `/v1` or `/v2`. `api.minimax.cn` in mainland China, `api.minimaxi.com` internationally |
|
|
249
|
+
| Default parameters | Cell width and height, frame count, pixel block size, keying threshold, and so on |
|
|
250
|
+
| Feature management | Per-module switches: a disabled module disappears from the UI **and the agent cannot call it either** (see below) |
|
|
251
|
+
|
|
252
|
+
Keys are written only to `<DSH_HOME>/game-material-master/config.json` on your machine, and the UI always
|
|
253
|
+
masks them when displaying them back. **The model is a plugin-level setting shared by all three modules**;
|
|
254
|
+
after you switch models, tasks align to the new tier automatically.
|
|
255
|
+
|
|
256
|
+
### Feature management (hiding modules you do not use)
|
|
257
|
+
|
|
258
|
+
Turn a module off under **Settings → Game Material Master → Feature management**; turn it back on any time.
|
|
259
|
+
Existing project data is never deleted.
|
|
260
|
+
|
|
261
|
+
- **UI**: the module disappears from the workbench tabs and from the sidebar shortcut menu. If you were
|
|
262
|
+
sitting on that module, the workbench falls back to the first visible one.
|
|
263
|
+
- **Chat**: `game_material_call` / `status` / `intake` / `upload` / `wait` / `review` / `approve` all refuse,
|
|
264
|
+
and the error says where to turn the feature back on. Hiding only the UI would not be hiding at all: the
|
|
265
|
+
agent cannot see the tab but could still call generation methods and spend real money, so the host half
|
|
266
|
+
re-checks the current setting on every call.
|
|
267
|
+
- Visibility is **user-only**: the tool surface rejects `saveConfig({hiddenModules})`, otherwise the model
|
|
268
|
+
could simply unhide a feature by itself.
|
|
269
|
+
- Hiding everything is allowed; the workbench then says every feature is hidden.
|
|
270
|
+
|
|
271
|
+
## UI language
|
|
272
|
+
|
|
273
|
+
**The plugin UI follows DSH's own language setting** (Settings → General → Language). Chinese and English are
|
|
274
|
+
both first-class, and switching takes effect **immediately** with no page refresh: the workbench title, the four
|
|
275
|
+
module tabs, every card's buttons, notice bars, dialogs and the settings page all follow along.
|
|
276
|
+
|
|
277
|
+
Implementation-wise it neither guesses nor copies DSH's language state; instead it hooks into DSH's `locale`
|
|
278
|
+
service (`@deepseek-ai/dsh-client-locale`): the plugin registers its Chinese/English string table there and
|
|
279
|
+
afterwards pulls every piece of UI text from it. If the service isn't there, nothing errors and the UI falls
|
|
280
|
+
back to the original Chinese.
|
|
281
|
+
|
|
282
|
+
**The built-in default prompts switch too.** The eight-direction image prompts, walk-video prompts and
|
|
283
|
+
turn-video prompts have English versions when the UI is in English — they really do get sent to
|
|
284
|
+
Seedream / MiniMax, so the language has to match the UI, otherwise you can't tell what you're tuning. The rule
|
|
285
|
+
is "only swap the ones you haven't edited": prompts you have edited by hand don't change a single character when
|
|
286
|
+
you switch languages, and "Reset to default" gives you the default for the **current** language. Prompts live on
|
|
287
|
+
the host side (the host has no access to the locale service), so the browser half passes the current language
|
|
288
|
+
along every time it reads a project or resets prompts.
|
|
289
|
+
|
|
290
|
+
Scope note: **localization covers the browser half's UI text and the built-in default prompts** — the workbench
|
|
291
|
+
title, the four module tabs, every card's buttons and notice bars, dialogs, the settings page, the review
|
|
292
|
+
controls, and the default prompts. Two categories remain in Chinese, because DSH currently only exposes the
|
|
293
|
+
locale service to the browser half:
|
|
294
|
+
|
|
295
|
+
- **Lines the host writes into the run log** (the host emits Chinese, so they actually look like
|
|
296
|
+
`开始生成「南 · 正对镜头」`, `「南 · 正对镜头」生成完成,用时 12.3 秒`) plus the dynamic conclusions from
|
|
297
|
+
part-extraction QA;
|
|
298
|
+
- Text that chat tools return for the model to read (the rendering of `game_material_status` / `review`, the
|
|
299
|
+
follow-up questions from `intake`).
|
|
300
|
+
|
|
301
|
+
Everything in the UI that you can click, change or approve is bilingual.
|
|
302
|
+
|
|
303
|
+
## Common pitfalls
|
|
304
|
+
|
|
305
|
+
- Don't use "silhouette" in a prompt — the image model takes it literally and paints the character as a solid
|
|
306
|
+
black outline.
|
|
307
|
+
- Distinguish "turning" from "gaze": when writing a direction, add "rotate around the vertical axis only, gaze
|
|
308
|
+
stays level", or the character ends up looking up at the sky.
|
|
309
|
+
- Image-to-video doesn't guarantee it will preserve a flat background (lighting can turn it into a gradient), so
|
|
310
|
+
the keying doesn't rely on a single green value.
|
|
311
|
+
- Duplicate submissions are blocked (both in the UI and in chat) so you don't burn money for nothing.
|
|
312
|
+
|
|
313
|
+
## Where the output goes
|
|
314
|
+
|
|
315
|
+
```
|
|
316
|
+
<DSH_HOME>/game-material-master/
|
|
317
|
+
├── projects/<id>/ eight-direction sheet (source / images / videos / frames / keyed / preview / out)
|
|
318
|
+
├── image-jobs/<id>/ image generation
|
|
319
|
+
├── sequence-jobs/<id>/ sequence frames
|
|
320
|
+
└── rig-jobs/<id>/ rigged animation (experimental: sheet / parts / layout / rig / atlas)
|
|
321
|
+
└── tile-jobs/<id>/ map tiles (template / raw / cell / decor / map / export)
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
> Map tiles keep the **raw generation output** in `raw/`: after changing regularisation parameters such as
|
|
325
|
+
> the cell size you can re-run regularisation for free, without paying to generate again.
|
|
326
|
+
|
|
327
|
+
## Development
|
|
328
|
+
|
|
329
|
+
```bash
|
|
330
|
+
npm run build # tsc → lib/, and strip the trailing export from the browser bundle
|
|
331
|
+
npm run typecheck # type checking only
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
Local self-checks (no network, no cost): `scripts/verify-host.mjs` (host pipeline), `verify-tools.mjs`
|
|
335
|
+
(chat-facing tool surface), `verify-pipeline.mjs` (frame extraction / keying / composition), `verify-client.mjs`
|
|
336
|
+
+ `verify-feedback.mjs` (browser-half contracts and real rendering), `verify-i18n.mjs` (Chinese/English string
|
|
337
|
+
table completeness), `verify-rig.mjs` (the rigging algorithm layer), and more. End-to-end scripts that hit the
|
|
338
|
+
real API cost money — run them only when you mean to.
|
|
339
|
+
|
|
340
|
+
### Adding a piece of UI text
|
|
341
|
+
|
|
342
|
+
The **Chinese source text you write is itself the key** in the string table, so you just write code
|
|
343
|
+
normally (yes, the key stays Chinese even in the English build — that is the point: the call site reads
|
|
344
|
+
as the copy, and a missing translation falls back to the key instead of showing a code name):
|
|
345
|
+
|
|
346
|
+
```ts
|
|
347
|
+
h("span", null, T("正在装配定位…")) // plain copy
|
|
348
|
+
T("第 {n0} 帧", { n0: index + 1 }) // with interpolation; English may reorder freely
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
Then add an English entry to the string table in `src/client.ts` (between `i18n-ignore-start` /
|
|
352
|
+
`i18n-ignore-end`); if you miss one nothing crashes, but `verify-i18n.mjs` will catch it. To wrap legacy code
|
|
353
|
+
in bulk, use `node scripts/i18n-wrap.mjs src/client.ts --write` (lexical, idempotent, safe to run repeatedly).
|
|
354
|
+
|
|
355
|
+
How changes take effect after you edit code:
|
|
356
|
+
|
|
357
|
+
| What you changed | How it takes effect |
|
|
358
|
+
|---|---|
|
|
359
|
+
| `src/client.ts` (browser half) | Just refresh the browser |
|
|
360
|
+
| `src/*.ts` host half | Restart DSH (or hot-reload with `--patch`) |
|
|
361
|
+
|
|
362
|
+
The screenshots in this document were taken by Playwright against the real UI; the originals live in
|
|
363
|
+
[`docs/images/`](https://github.com/universe-st/dsh-game-material-master/tree/main/docs/images).
|
|
364
|
+
|
|
365
|
+
## Known trade-offs
|
|
366
|
+
|
|
367
|
+
- **The pixel-art look comes from post-processing** (pixel quantization during frame extraction), not from the
|
|
368
|
+
prompt — Seedream ignores "pixel art"-style instructions.
|
|
369
|
+
- **Part-extraction quality is determined by the image model** and is the biggest bottleneck right now. The
|
|
370
|
+
model occasionally "swaps the character" or splits them into clothing pieces; the most reliable path is
|
|
371
|
+
"upload your own part PNGs" (the filename is the part name), which skips generation entirely.
|
|
372
|
+
- **Automatic assembly is only reliable when each part really is a whole limb from the reference image**; when
|
|
373
|
+
real character art goes through generated part extraction, prefer correcting it with agent visual priors or
|
|
374
|
+
manual dragging (neither of those steps costs anything).
|
|
375
|
+
- MiniMax occasionally rejects content on moderation (about 10% in practice); just reword to a more neutral
|
|
376
|
+
prompt and retry.
|
|
377
|
+
|
|
378
|
+
## License
|
|
379
|
+
|
|
380
|
+
[MIT](LICENSE)
|
|
381
|
+
|
|
382
|
+
> Full engineering documentation (algorithm details, self-check contracts, history of pitfalls) is in
|
|
383
|
+
> [docs/ENGINEERING.md](docs/ENGINEERING.md).
|
package/README.md
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
[English](https://github.com/universe-st/dsh-game-material-master/blob/main/README.en.md) | 中文
|
|
2
|
+
|
|
1
3
|
# 游戏素材大师
|
|
2
4
|
|
|
3
5
|
**从一张角色设定图出发,批量做出游戏里真正要用的素材。**
|
|
@@ -13,8 +15,11 @@
|
|
|
13
15
|
> **30 秒上手**:`dsh plugin --profile web add dsh-game-material-master` → 重启 DSH →
|
|
14
16
|
> 侧栏点「游戏素材大师」→ 设置里填两个 API Key → 新建项目、上传设定图 → 点「生成转圈视频」
|
|
15
17
|
>(默认路径:角色原地匀速转一圈,再自动截出八个方向;要逐方向生图就在阶段①切一下方式)。
|
|
18
|
+
>
|
|
19
|
+
> 侧栏那个入口上还有一个**小折角菜单按钮**:点它直接弹出五个功能,一步跳进要用的那个;
|
|
20
|
+
> 不用的功能可以在设置里关掉(见「功能管理」)。
|
|
16
21
|
|
|
17
|
-
|
|
22
|
+
四个模块共用同一套「生成 → 验收 → 重跑」工作台。每个阶段都能**单独重做**,每份产物都能
|
|
18
23
|
**逐项打「通过」**;「审核模式」可以选 agent 自动审完就往下走,也可以选每一步停下来等你点头。
|
|
19
24
|
|
|
20
25
|
| 模块 | 做什么 | 走完能拿到 |
|
|
@@ -22,13 +27,21 @@
|
|
|
22
27
|
| **① 八方向图生成** | 一张设定图 → 8 方位 × 8 帧(默认「转圈截帧」:一段转圈视频截出八个方向) | 可用 WASD 操控预览的行走精灵图 |
|
|
23
28
|
| **② 图片生成** | 提示词(可带参考图)→ 出图 → 抠绿幕 | 干净透明的 PNG 立绘 / 道具 |
|
|
24
29
|
| **③ 序列帧生成** | 首尾帧或参考视频 → 生成视频 → 抽帧 → 抠像 | 横向排布、可循环播放的序列帧 |
|
|
30
|
+
| **⑤ 45°地图地块生成**(实验性) | 45° 等距地块 → 铺成整张地图 | 地块包(PNG)+ 地图 PNG + 布局 JSON |
|
|
25
31
|
| ~~④ 骨骼动画生成~~ | 拆件 → 装配 → 骨骼动画 → Spine / DragonBones 图集 | **实验性功能,本文不展示** |
|
|
26
32
|
|
|
33
|
+
> 💡 **模块⑤「45°地图地块生成」的核心思路是「几何交给代码,内容交给 AI」。**
|
|
34
|
+
> 菱形模板由本机代码渲染(严格 2:1 等距),AI 只负责把菱形内部填成指定地貌;
|
|
35
|
+
> 生成完再本地量一次、仿射对齐到标准菱形,最后本地按等距网格铺图。
|
|
36
|
+
> 好处是**几何永远精确**——地块拼起来不会有缝,换种子重铺逐像素可复现。
|
|
37
|
+
> 实测「让模型自由画菱形」的比例只有 1.03~1.55(对不上 2:1),而模板填充的达标率是 100%。
|
|
38
|
+
|
|
27
39
|
> ⚠️ **模块④「骨骼动画生成」仍是实验性功能,尚未完善**:拆件质量取决于生图模型,自动装配与骨骼推导
|
|
28
40
|
> 对真实立绘经常需要人工校正(agent 视觉先验或手工拖放),导出的 Spine / DragonBones 产物也还没经过
|
|
29
41
|
> 足够的引擎侧验证。界面上该模块带「实验性」角标,并在每次进入时弹窗说明。本文只展示前三个模块。
|
|
30
42
|
> 如果你需要它、或者想一起把它做扎实,欢迎到
|
|
31
|
-
> [GitHub 仓库](https://github.com/universe-st/dsh-game-material-master)
|
|
43
|
+
> [GitHub 仓库](https://github.com/universe-st/dsh-game-material-master) 参与开发,
|
|
44
|
+
> 或加入 **QQ 群 `1126382236`**(见文末「交流与反馈」)。
|
|
32
45
|
|
|
33
46
|
---
|
|
34
47
|
|
|
@@ -197,15 +210,54 @@ dsh plugin --profile web add /path/to/dsh-game-material-master
|
|
|
197
210
|
| 项 | 说明 |
|
|
198
211
|
|---|---|
|
|
199
212
|
| 火山方舟 API Key | 「测试连接」会真实生成一张 1K 小图(少量费用),同时验证 Key 与模型 |
|
|
200
|
-
| 生图模型 | 默认 `doubao-seedream-
|
|
213
|
+
| 生图模型 | 默认 `doubao-seedream-5-0-flash-260915`,可切 5.0 Pro / Lite / 4.5 |
|
|
201
214
|
| MiniMax API Key | 「测试连接」免费,能区分 Key 无效与其它错误 |
|
|
202
215
|
| 视频模型 | 默认 `MiniMax-H3`(v2 协议);Hailuo / I2V 走 v1;优云智算版 H3 显式选择 |
|
|
203
216
|
| Base URL | 主机根,不含 `/v1` `/v2`。国内 `api.minimax.cn`,国际 `api.minimaxi.com` |
|
|
204
217
|
| 默认参数 | 单格宽高、抽帧张数、像素块边长、抠像阈值等 |
|
|
218
|
+
| 功能管理 | 逐个开关五个模块:关掉的模块界面上不再出现,**对话里的 AI 也调不到**(见下) |
|
|
205
219
|
|
|
206
220
|
Key 只写入本机 `<DSH_HOME>/game-material-master/config.json`,界面回显始终脱敏。
|
|
207
221
|
**模型是插件级设置,三个模块共用**,切换模型后任务自动对齐新档位。
|
|
208
222
|
|
|
223
|
+
### 功能管理(隐藏不用的模块)
|
|
224
|
+
|
|
225
|
+
不用的模块可以在**设置 → 游戏素材大师 → 功能管理**里关掉,随时再打开,已有项目数据不会删:
|
|
226
|
+
|
|
227
|
+
- **界面**:工作台页签、侧栏快捷菜单里都不再出现它;如果当时正停在这个模块,会自动落到第一个可见模块。
|
|
228
|
+
- **对话**:`game_material_call` / `status` / `intake` / `upload` / `wait` / `review` / `approve`
|
|
229
|
+
一律拒绝,报错里说明去哪里打开。只藏界面不拦工具等于没藏——模型看不见页签,
|
|
230
|
+
照样能调生成类方法真实计费,所以宿主半区每次都按最新配置再拦一次。
|
|
231
|
+
- 可见性**只能由用户在设置页里改**:工具面拒绝 `saveConfig({hiddenModules})`,
|
|
232
|
+
否则模型能自己把隐藏的功能放出来。
|
|
233
|
+
- 全部关掉也是允许的,工作台会提示「所有功能都已被隐藏」。
|
|
234
|
+
|
|
235
|
+
## 界面语言
|
|
236
|
+
|
|
237
|
+
**插件界面跟随 DSH 自身的语言设置**(设置 → 通用 → 语言),中文 / 英文都是一等公民,
|
|
238
|
+
切换**即时生效**、不用刷新页面:工作台标题、四个模块页签、每一张卡片的按钮、提示条、
|
|
239
|
+
弹窗与设置页全部跟着走。
|
|
240
|
+
|
|
241
|
+
实现上不猜也不复制 DSH 的语言状态,而是接 DSH 的 `locale` 服务
|
|
242
|
+
(`@deepseek-ai/dsh-client-locale`):插件把中英词条表注册进去,之后所有界面文案都从它取。
|
|
243
|
+
服务不在时不报错,界面退回中文原文。
|
|
244
|
+
|
|
245
|
+
**内置默认提示词也跟着切。** 八方向生图提示词、行走视频提示词、转圈视频提示词在英文界面下
|
|
246
|
+
就是英文版——它们会真的发给 Seedream / MiniMax,所以语言得跟界面一致,不然用户读不懂
|
|
247
|
+
自己在调什么。规则是「只换没改过的那些」:手改过的提示词切语言时一个字都不动,
|
|
248
|
+
点「重置为默认」得到的是**当前语言**的默认值。提示词存在宿主侧(宿主拿不到 locale 服务),
|
|
249
|
+
所以浏览器半区每次读项目、重置提示词时把当前语言一起带过去。
|
|
250
|
+
|
|
251
|
+
范围说明:**多语言覆盖的是浏览器半区的界面文案与内置默认提示词**——工作台标题、
|
|
252
|
+
四个模块页签、每一张卡片的按钮与提示条、弹窗、设置页、验收控件、默认提示词。
|
|
253
|
+
以下两类仍是中文,因为 DSH 目前只把 locale 服务提供给浏览器半区:
|
|
254
|
+
|
|
255
|
+
- **运行日志里由宿主写入的行**(「开始生成「南 · 正对镜头」」「…生成完成,用时 12.3 秒」等)
|
|
256
|
+
以及拆件质检给出的动态结论;
|
|
257
|
+
- 对话工具返回给模型看的文本(`game_material_status` / `review` 的渲染、`intake` 的追问)。
|
|
258
|
+
|
|
259
|
+
界面上能点、能改、能验收的部分都是双语。
|
|
260
|
+
|
|
209
261
|
## 常见坑
|
|
210
262
|
|
|
211
263
|
- 提示词别用「剪影」——生图模型会照字面把角色画成纯黑轮廓。
|
|
@@ -220,9 +272,13 @@ Key 只写入本机 `<DSH_HOME>/game-material-master/config.json`,界面回显
|
|
|
220
272
|
├── projects/<id>/ 八方向图(source / images / videos / frames / keyed / preview / out)
|
|
221
273
|
├── image-jobs/<id>/ 图片生成
|
|
222
274
|
├── sequence-jobs/<id>/ 序列帧生成
|
|
223
|
-
|
|
275
|
+
├── rig-jobs/<id>/ 骨骼动画(实验性:sheet / parts / layout / rig / atlas)
|
|
276
|
+
└── tile-jobs/<id>/ 地图地块(template / raw / cell / decor / map / export)
|
|
224
277
|
```
|
|
225
278
|
|
|
279
|
+
> 地图地块的 `raw/` 会**保留原始生成结果**:改了单元格尺寸之类的规整参数后,
|
|
280
|
+
> 可以零成本重跑规整,不必重新花钱生成。
|
|
281
|
+
|
|
226
282
|
## 开发
|
|
227
283
|
|
|
228
284
|
```bash
|
|
@@ -231,8 +287,22 @@ npm run typecheck # 只做类型检查
|
|
|
231
287
|
```
|
|
232
288
|
|
|
233
289
|
本地自检(不联网、不花钱):`scripts/verify-host.mjs`(宿主链路)、`verify-tools.mjs`
|
|
234
|
-
(对话调用面)、`verify-pipeline.mjs`(抽帧 / 抠像 / 合成)、`verify-
|
|
235
|
-
|
|
290
|
+
(对话调用面)、`verify-pipeline.mjs`(抽帧 / 抠像 / 合成)、`verify-client.mjs` +
|
|
291
|
+
`verify-feedback.mjs`(浏览器半区契约与真渲染)、`verify-i18n.mjs`(中英词条表完整性)、
|
|
292
|
+
`verify-rig.mjs`(骨骼算法层)等。真实 API 端到端脚本会花钱,按需运行。
|
|
293
|
+
|
|
294
|
+
### 加一条界面文案
|
|
295
|
+
|
|
296
|
+
中文原文**就是**词条表的 key,所以正常写代码即可:
|
|
297
|
+
|
|
298
|
+
```ts
|
|
299
|
+
h("span", null, T("正在装配定位…")) // 纯文案
|
|
300
|
+
T("第 {n0} 帧", { n0: index + 1 }) // 带插值,英文可自由换语序
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+
然后在 `src/client.ts` 的词条表(`i18n-ignore-start` / `i18n-ignore-end` 之间)补一条英文;
|
|
304
|
+
漏了也不会崩,`verify-i18n.mjs` 会拦下来。批量包老代码用
|
|
305
|
+
`node scripts/i18n-wrap.mjs src/client.ts --write`(词法级、幂等,可反复跑)。
|
|
236
306
|
|
|
237
307
|
改代码后如何生效:
|
|
238
308
|
|
|
@@ -253,6 +323,13 @@ npm run typecheck # 只做类型检查
|
|
|
253
323
|
建议用 agent 视觉先验或手工拖放校正(这些步骤都不花钱)。
|
|
254
324
|
- MiniMax 偶发内容审核拒绝(实测约 10%),换一版更中性的提示词重试即可。
|
|
255
325
|
|
|
326
|
+
## 交流与反馈
|
|
327
|
+
|
|
328
|
+
- **QQ 群:`1126382236`**(群名「DSH游戏素材大师插件」)——新版本发布、路线图和踩坑经验都在群里同步,
|
|
329
|
+
欢迎进群获取最新动态,也欢迎直接参与开发:提需求、报 bug、认领模块都可以在群里聊。
|
|
330
|
+
- 也可以在 [GitHub Issues](https://github.com/universe-st/dsh-game-material-master/issues)
|
|
331
|
+
提 issue 或直接发 PR。
|
|
332
|
+
|
|
256
333
|
## 许可
|
|
257
334
|
|
|
258
335
|
[MIT](LICENSE)
|