diff --git a/art/WORKFLOW.md b/art/WORKFLOW.md index 4c47eba..66eef74 100644 --- a/art/WORKFLOW.md +++ b/art/WORKFLOW.md @@ -159,7 +159,10 @@ Optionen, die zählen: `--size`, `--colors` (16/32), `--dither none|bayer4|bayer `--cutout 12` (Hintergrund freistellen → RGBA), `--outline auto` (1-px-Kontur um die Figur), `--recenter` (Figur in die Canvas-Mitte), `--canvas 96x96` (Zeichnung bei kleinerem `--size` auf einen größeren transparenten Sprite-Grund -setzen → Größenklassen, `--inset 4` +setzen → Größenklassen), `--cutout-global` (auch eingeschlossene +Hintergrundflächen entfernen, nur Chromakey), `--shrink 1` (Chromakey-Saum +abtragen), `--palette-figure` (Palette nur aus der Figur), `--deshadow` +(neutrale Bodenschatten auf grauem Grund), `--inset 4` (Rand abschneiden), `--flatten 6` (Untergrund flachziehen), `--seal-edge` (Kacheln nahtlos), `--stats`. diff --git a/art/final/Creatures/README.md b/art/final/Creatures/README.md index 8287433..496ff18 100644 --- a/art/final/Creatures/README.md +++ b/art/final/Creatures/README.md @@ -25,33 +25,53 @@ python3 ../../tools/pixelize.py ../../raw/Creatures/.png \ ## Inhalt -| Datei | Rohbild | Seed | Klasse | Aufruf | +| Datei | Rohbild | Seed | Zeichnung | Aufruf | |---|---|---|---|---| -| `monster_wolf_96px.png` | `raw/Creatures/monster_wolf_s271828.png` | 271828 | mittel | `--size 96x96 --colors 32 --cutout 12 --outline auto --recenter --upscale 4` | -| `monster_ratte_96px.png` | `raw/Creatures/monster_ratte_v2_fal_s271828.png` (fal) | 271828 | klein | `--size 56x56 --canvas 96x96 --colors 32 --cutout 12 --outline auto --recenter --upscale 4` | +| `monster_wolf_96px.png` | `raw/Creatures/monster_wolf_s271828.png` | 271828 | 96 | `--size 96x96 --colors 32 --cutout 12 --outline auto --recenter --upscale 4` | +| `monster_ratte_96px.png` | `raw/Creatures/monster_ratte_v2_fal_s271828.png` (fal) | 271828 | 56 | `--size 56x56 --canvas 96x96 --colors 32 --cutout 12 --outline auto --recenter --upscale 4` | +| `monster_goblin_96px.png` | `raw/Creatures/monster_goblin_fal_s271828_magenta.png` (fal) | 271828 | 72 | `--size 72x72 --canvas 96x96 --colors 32 --cutout 12 --cutout-global --shrink 1 --palette-figure --outline auto --recenter --upscale 4` | ## Größenklassen (entschieden 14.11.2026) -**Die Canvas ist für alle Kreaturen gleich (96×96), die Figur darin nicht.** -Der Wolf ist die Referenz „mittel" (gezeichnet bei 96); die Ratte ist „klein" -und wird bei **56** gezeichnet, dann mit `--canvas 96x96` mittig auf den -transparenten 96er-Grund gesetzt. So bleibt der Anker in der Engine für alle -Kreaturen derselbe, ohne dass die Ratte so groß wie der Wolf wirkt. +**Die Canvas ist für alle Kreaturen gleich (96×96), die Zeichnung darin nicht.** +Der Wolf ist die Referenz (bei 96 gezeichnet); die Ratte ist kleiner und wird +bei **56** gezeichnet, dann mit `--canvas 96x96` mittig auf den transparenten +96er-Grund gesetzt. So bleibt der Anker in der Engine für alle Kreaturen +derselbe, ohne dass die Ratte so groß wie der Wolf wirkt. Gemessen (1×, Bounding-Box der sichtbaren Figur): -| Klasse | Zeichnung | Bbox 1× | Datei | +| Figur | Zeichnung | Bbox 1× | Datei | |---|---|---|---| -| klein (Ratte) | 56 | 47×34 | 384×384 | -| mittel (Wolf) | 96 | 74×46 | 384×384 | -| groß (Boss, noch offen) | 128 | — | 512×512 (eigene Canvas) | +| Ratte | 56 | 47×34 | 384×384 | +| Goblin | 72 | 30×63 | 384×384 | +| Wolf | 96 | 74×46 | 384×384 | +| Boss (noch offen) | 128 | — | 512×512 (eigene Canvas) | + +Die Stufe ist eine **Leiter, keine Norm**: 56 / 72 / 96 / 128. Ein Goblin ist +schmal und hoch, ein Wolf breit und tief — dieselbe Zahl sieht deshalb +verschieden groß aus. Entschieden wird an der Bbox, nicht am Etikett. Regel: **eine Variable pro Figur** — die Klasse steckt im `--size`, nicht im Prompt („small rat" ist bei FLUX ohne Wirkung; das Rechteck entscheidet). Vergleich der Stufen 64/56/48 unter [`../../prep/rat-test/_groessen.png`](../../prep/rat-test/_groessen.png), Wolf vs. Ratte unter -[`../../prep/rat-test/_vergleich.png`](../../prep/rat-test/_vergleich.png). +[`../../prep/rat-test/_vergleich.png`](../../prep/rat-test/_vergleich.png), +Goblin-Stufen unter +[`../../prep/goblin-test/_groessen.png`](../../prep/goblin-test/_groessen.png). + +## Hintergrund: grau oder magenta + +- **Grau** (Standard): Figuren ohne Bodenschatten — Wolf, Ratte, Objekte. + Freistellen mit `--cutout 12` (randverbunden), Kontur, fertig. +- **Magenta** (Chromakey): stehende Humanoiden. FLUX malt ihnen fast immer + einen weichen Schatten unter die Füße, und der schließt die Lücken zwischen + Beinen und Armen ab — der Freisteller lässt sie als graue Flächen stehen. + Magenta liegt weit von jeder Figurfarbe, wird mit Schatten mitgezeichnet und + ist sauber keybar: `--cutout 12 --cutout-global --shrink 1 + --palette-figure`. Messwerte und die Sackgassen: + [`../../prep/goblin-test/README.md`](../../prep/goblin-test/README.md). ## Regeln @@ -62,6 +82,8 @@ Wolf vs. Ratte unter zentriert davor nur innerhalb der Zeichnung. - **`--cutout` nicht über 12–14 % treiben.** Getestet an der Ratte: bei 20 % flutet die Füllung die Körpermitte, bei 26 % bricht die Silhouette auf. -- Neue Datei → Zeile in der Tabelle oben (Name, Seed, Rohdatei, Klasse). +- **`--cutout-global` nie auf grauem Grund.** Es entfernt auch eingeschlossene + Flächen — bei grauem Fell (Wolf) sind das Löcher. Nur bei Chromakey. +- Neue Datei → Zeile in der Tabelle oben (Name, Seed, Rohdatei, Zeichnung). - Dunkle Sprites brauchen `--levels`: ohne Tonwertspreizung verschwinden sie auf dunklem Grund. Hell-mittel bleibt ohne. diff --git a/art/final/Creatures/monster_goblin_96px.png b/art/final/Creatures/monster_goblin_96px.png new file mode 100644 index 0000000..1283f18 Binary files /dev/null and b/art/final/Creatures/monster_goblin_96px.png differ diff --git a/art/license-log.csv b/art/license-log.csv index 98b980e..be56be7 100644 --- a/art/license-log.csv +++ b/art/license-log.csv @@ -31,3 +31,8 @@ datum,endpoint_id,request_id,prompt,seed,lizenz 2026-11-14,fal-ai/flux-2/klein/9b,01a1dba3-558d-7423-a803-dd0f8a1df75c,"grey wolf sprite, test pattern, flat neutral background",1,"FLUX.2 [klein] 9B über fal.ai (BFL Non-Commercial License: Gewichte/Selbsthosting; Outputs nach §2d frei nutzbar, keine IP-Indemnity) - 256x256, 0.0655 MP, x-fal-billable-units 0.25 = 0.00 USD" 2026-11-14,fal-ai/flux-2/klein/9b,01a1dbc0-5ae0-7c90-81cd-dfa53122de48,"illustrated fantasy RPG art, late-1980s role-playing game cover-illustration sensibility, flat color shapes with hard edges, limited palette of six to eight hues - muted ochre, dusty slate blue, olive green, warm cream highlights, deep umber shadow, no gradients except two-step blends, strong silhouettes, readable at small size, painterly but economical detail, full body of a large grey rat in a low crouching stance, side-on three-quarter view, centered, isolated on a flat neutral mid-grey background, complete silhouette with all four legs, both ears and the long tail visible, no cast shadow, no ground plane",271828,"FLUX.2 [klein] 9B über fal.ai (BFL Non-Commercial License: Gewichte/Selbsthosting; Outputs nach §2d frei nutzbar, keine IP-Indemnity) - 1024x1024, 1.0486 MP, x-fal-billable-units 1.0 = 0.01 USD" 2026-11-14,fal-ai/flux-2/klein/9b,01a1dbc9-702b-74e1-99f5-e6e90249341e,"illustrated fantasy RPG art, late-1980s role-playing game cover-illustration sensibility, flat color shapes with hard edges, limited palette of six to eight hues - muted ochre, dusty slate blue, olive green, warm cream highlights, deep umber shadow, no gradients except two-step blends, strong silhouettes, readable at small size, painterly but economical detail, full body of a grey rat in a low crouching stance, side-on three-quarter view, centered, isolated on a flat neutral mid-grey background, complete silhouette with all four legs, both ears and the long thin tail visible, the tail tapering to a point, no cast shadow, no ground plane",271828,"FLUX.2 [klein] 9B über fal.ai (BFL Non-Commercial License: Gewichte/Selbsthosting; Outputs nach §2d frei nutzbar, keine IP-Indemnity) - 1024x1024, 1.0486 MP, x-fal-billable-units 1.0 = 0.01 USD" +2026-11-14,fal-ai/flux-2/klein/9b,01a1dbce-c325-79d1-a839-0ce91191b56b,"illustrated fantasy RPG art, late-1980s role-playing game cover-illustration sensibility, flat color shapes with hard edges, limited palette of six to eight hues - muted ochre, dusty slate blue, olive green, warm cream highlights, deep umber shadow, no gradients except two-step blends, strong silhouettes, readable at small size, painterly but economical detail, full body of a hunched goblin with olive-green skin, long pointed ears and a large nose, wearing a ragged brown tunic, bare feet, empty-handed, side-on three-quarter view, centered, isolated on a flat neutral mid-grey background, complete silhouette with both arms and both legs visible, no cast shadow, no ground plane",271828,"FLUX.2 [klein] 9B über fal.ai (BFL Non-Commercial License: Gewichte/Selbsthosting; Outputs nach §2d frei nutzbar, keine IP-Indemnity) - 1024x1024, 1.0486 MP, x-fal-billable-units 1.0 = 0.01 USD" +2026-11-14,fal-ai/flux-2/klein/9b,01a1dbcf-05ff-7420-9f26-a2f207a19a42,"illustrated fantasy RPG art, late-1980s role-playing game cover-illustration sensibility, flat color shapes with hard edges, limited palette of six to eight hues - muted ochre, dusty slate blue, olive green, warm cream highlights, deep umber shadow, no gradients except two-step blends, strong silhouettes, readable at small size, painterly but economical detail, full body of a hunched goblin with olive-green skin, long pointed ears and a large nose, wearing a ragged brown tunic, bare feet, empty-handed, side-on three-quarter view, centered, isolated on a flat neutral mid-grey background, complete silhouette with both arms and both legs visible, no cast shadow, no ground plane",314159,"FLUX.2 [klein] 9B über fal.ai (BFL Non-Commercial License: Gewichte/Selbsthosting; Outputs nach §2d frei nutzbar, keine IP-Indemnity) - 1024x1024, 1.0486 MP, x-fal-billable-units 1.0 = 0.01 USD" +2026-11-14,fal-ai/flux-2/klein/9b,01a1dbcf-108a-7993-963e-775c12b18036,"illustrated fantasy RPG art, late-1980s role-playing game cover-illustration sensibility, flat color shapes with hard edges, limited palette of six to eight hues - muted ochre, dusty slate blue, olive green, warm cream highlights, deep umber shadow, no gradients except two-step blends, strong silhouettes, readable at small size, painterly but economical detail, full body of a hunched goblin with olive-green skin, long pointed ears and a large nose, wearing a ragged brown tunic, bare feet, empty-handed, side-on three-quarter view, centered, isolated on a flat neutral mid-grey background, complete silhouette with both arms and both legs visible, no cast shadow, no ground plane",880417,"FLUX.2 [klein] 9B über fal.ai (BFL Non-Commercial License: Gewichte/Selbsthosting; Outputs nach §2d frei nutzbar, keine IP-Indemnity) - 1024x1024, 1.0486 MP, x-fal-billable-units 1.0 = 0.01 USD" +2026-11-14,fal-ai/flux-2/klein/9b,01a1dbcf-79c5-7a60-8681-a6ebfb74b20a,"illustrated fantasy RPG art, late-1980s role-playing game cover-illustration sensibility, flat color shapes with hard edges, limited palette of six to eight hues - muted ochre, dusty slate blue, olive green, warm cream highlights, deep umber shadow, no gradients except two-step blends, strong silhouettes, readable at small size, painterly but economical detail, full body of a hunched goblin with olive-green skin, long pointed ears and a large nose, wearing a ragged brown tunic, bare feet, empty-handed, side-on three-quarter view, centered, isolated on a flat neutral mid-grey background, complete silhouette with both arms and both legs visible, no cast shadow, no drop shadow under the feet, no ground plane",271828,"FLUX.2 [klein] 9B über fal.ai (BFL Non-Commercial License: Gewichte/Selbsthosting; Outputs nach §2d frei nutzbar, keine IP-Indemnity) - 1024x1024, 1.0486 MP, x-fal-billable-units 1.0 = 0.01 USD" +2026-11-14,fal-ai/flux-2/klein/9b,01a1dbd1-f11f-7b23-a5c9-d818e5ec98b1,"illustrated fantasy RPG art, late-1980s role-playing game cover-illustration sensibility, flat color shapes with hard edges, limited palette of six to eight hues - muted ochre, dusty slate blue, olive green, warm cream highlights, deep umber shadow, no gradients except two-step blends, strong silhouettes, readable at small size, painterly but economical detail, full body of a hunched goblin with olive-green skin, long pointed ears and a large nose, wearing a ragged brown tunic, bare feet, empty-handed, side-on three-quarter view, centered, isolated on a flat solid magenta background, complete silhouette with both arms and both legs visible, no cast shadow, no drop shadow under the feet, no ground plane",271828,"FLUX.2 [klein] 9B über fal.ai (BFL Non-Commercial License: Gewichte/Selbsthosting; Outputs nach §2d frei nutzbar, keine IP-Indemnity) - 1024x1024, 1.0486 MP, x-fal-billable-units 1.0 = 0.01 USD" diff --git a/art/prep/goblin-test/README.md b/art/prep/goblin-test/README.md new file mode 100644 index 0000000..bc1a72d --- /dev/null +++ b/art/prep/goblin-test/README.md @@ -0,0 +1,99 @@ +# Goblin-Test — Bodenschatten und Chromakey + +Stand: 14.11.2026 · MacBook Air, fal `klein/9b`, Seed **271828**. +Fünf Läufe à 0,0063 $ = **0,0315 $**. + +**Frage:** Ein Goblin-Sprite in derselben Handschrift wie Wolf und Ratte — und +was macht man mit dem weichen Bodenschatten, den FLUX unter stehende Figuren +malt? + +## Läufe + +| # | Grund | Seed | Ergebnis | +|---|---|---|---| +| 1 | grau | 271828 | Schatten unter den Füßen; graue Lücke zwischen den Beinen und zwischen Arm und Körper | +| 2 | grau | 314159 | Schatten kleiner, aber die Arm-Lücke bleibt | +| 3 | grau | 880417 | Schatten, Figur muddiger, Arm-Lücke | +| 4 | grau | 271828 | Prompt um `no drop shadow under the feet` erweitert — **keine Wirkung** | +| 5 | **magenta** | 271828 | Schatten wird magenta mitgezeichnet, Figur unverändert — keybar | + +Nach drei Seeds stand fest: Das Modell malt den Schatten unabhängig vom Seed. +Nach Lauf 4: Negative Formulierungen ändern daran nichts (dieselbe Erfahrung +wie beim Wolf, `WORKFLOW.md` §4.4). Bleibt die Farbe des Grundes. + +## Warum der graue Grund scheitert + +Der Freisteller flutet von den Rändern. Zwei Dinge bleiben dadurch stehen: + +1. Der **Schatten** ist ein neutrales Grau knapp unter der Hintergrundhelligkeit + (Abstand ~50/255, Toleranz 12 % liegt bei 53). Er überlebt an seiner dunklen + Kernfläche und **schließt die Lücke zwischen den Beinen ab**. +2. Dadurch ist der Hintergrund *innerhalb* der Silhouette nicht mehr + randverbunden — er bleibt als grauer Fleck stehen. Dasselbe gilt für die + Lücke zwischen Arm und Torso. + +`--cutout 15/18/20` als Ausweg getestet: die Flut bricht durch die +Antialias-Kante in die Figur ein und frisst Kopf, Tunicfalten und Arme +(`_detail_schatten.png` ist der unveränderte 12er-Lauf, die 15/18er-Versionen +sind in der Sitzung verworfen worden). + +## Der Chromakey-Weg (gewählt) + +Prompt-Änderung: `isolated on a flat solid magenta background` statt +`… neutral mid-grey …`. Magenta liegt weit von jeder Figurfarbe des +A/B-Stils. Beide Prompts liegen als [`prompt_grau.txt`](prompt_grau.txt) und +[`prompt_magenta.txt`](prompt_magenta.txt) daneben. + +Gemessen am Rohbild (Abstand zur Randfarbe): + +| Bereich | Abstand | +|---|---| +| Hintergrund | 0–10 | +| Schatten (mitgezeichnet, magenta) | 20–30 | +| **Lücke** | **40–60 (keine Pixel)** | +| Figur (dunkelste Olive-/Brauntöne) | ab ~100 | + +Diese Lücke macht den Key stabil: Toleranz 12 (53) trifft genau zwischen +Schatten und Figur. Drei Zusätze waren nötig, alle neu in `pixelize.py`: + +| Flag | Warum | +|---|---| +| `--cutout-global` | entfernt auch **eingeschlossene** Grundflächen (Lücke Arm/Torso); bei Magenta ungefährlich, weil keine Figurfarbe in Reichweite liegt | +| `--shrink 1` | trägt den magenta Saum der Antialias-Kante ab (1 px), die Kontur setzt die Silhouette danach wieder zu | +| `--palette-figure` | zieht die Palette nur aus der Figur. Ohne das frisst der Grund 20 der 32 Plätze: 12 statt 32 Farben, flache Figur | + +`--deshadow` (neutrale Grautöne in Hintergrundhelligkeit) ist der Weg für +**graue** Gründe. Bei diesem Motiv war er nicht genug, weil die Lücken auch +ohne Schatten bleiben — und `--cutout-global` wäre auf Grau gefährlich (der +Wolf hat graues Fell in Hintergrundnähe). + +## Ergebnis + +```bash +~/.venvs/art/bin/python art/tools/pixelize.py \ + ~/Dokumente/workbench_taloria/assets/raw/Creatures/monster_goblin_fal_s271828_magenta.png \ + -o art/final/Creatures/monster_goblin_96px.png \ + --size 72x72 --canvas 96x96 --colors 32 --cutout 12 --cutout-global \ + --shrink 1 --palette-figure --outline auto --recenter --upscale 4 +``` + +| | | +|---|---| +| Datei | `art/final/Creatures/monster_goblin_96px.png` — 384×384 (96er-Canvas, 4×) | +| Zeichnung | 72, Bbox 30×63 bei 1× | +| Palette | 32, davon 62 sichtbare RGB-Werte (die Kontur erzeugt eigene Abdunkelungen) | +| Freisteller | Ecken-Alpha 0, deckend 12,7 % der Canvas, keine Lücken, kein Schatten | + +[`_detail_schatten.png`](_detail_schatten.png) — der graue Lauf mit Schatten und +grauer Lücke. [`_groessen.png`](_groessen.png) — 72/64/56 gegen Wolf und Ratte; +72 ist gewählt, weil bei 64 die Beine zu Strichen zerfallen. +[`_vergleich.png`](_vergleich.png) — Wolf, Ratte, Goblin bei 1:1. + +## Was ab jetzt gilt + +- **Grau bleibt der Standard** für Figuren ohne Bodenschatten (Wolf, Ratte, + Objekte). +- **Stehende Humanoiden bekommen Magenta** + `--cutout-global --shrink 1 + --palette-figure`. Das gilt für alle Zweibeiner, die auf dem Boden stehen. +- Toleranz bei Magenta: 12. Die Histogrammlücke prüfen, nicht raten. +- Kein `--cutout` über 14 auf Grau, kein `--cutout-global` auf Grau. diff --git a/art/prep/goblin-test/_detail_schatten.png b/art/prep/goblin-test/_detail_schatten.png new file mode 100644 index 0000000..f375e13 Binary files /dev/null and b/art/prep/goblin-test/_detail_schatten.png differ diff --git a/art/prep/goblin-test/_groessen.png b/art/prep/goblin-test/_groessen.png new file mode 100644 index 0000000..7f1206b Binary files /dev/null and b/art/prep/goblin-test/_groessen.png differ diff --git a/art/prep/goblin-test/_vergleich.png b/art/prep/goblin-test/_vergleich.png new file mode 100644 index 0000000..8360d48 Binary files /dev/null and b/art/prep/goblin-test/_vergleich.png differ diff --git a/art/prep/goblin-test/prompt_grau.txt b/art/prep/goblin-test/prompt_grau.txt new file mode 100644 index 0000000..ff93bd7 --- /dev/null +++ b/art/prep/goblin-test/prompt_grau.txt @@ -0,0 +1 @@ +illustrated fantasy RPG art, late-1980s role-playing game cover-illustration sensibility, flat color shapes with hard edges, limited palette of six to eight hues - muted ochre, dusty slate blue, olive green, warm cream highlights, deep umber shadow, no gradients except two-step blends, strong silhouettes, readable at small size, painterly but economical detail, full body of a hunched goblin with olive-green skin, long pointed ears and a large nose, wearing a ragged brown tunic, bare feet, empty-handed, side-on three-quarter view, centered, isolated on a flat neutral mid-grey background, complete silhouette with both arms and both legs visible, no cast shadow, no drop shadow under the feet, no ground plane diff --git a/art/prep/goblin-test/prompt_magenta.txt b/art/prep/goblin-test/prompt_magenta.txt new file mode 100644 index 0000000..54ade3f --- /dev/null +++ b/art/prep/goblin-test/prompt_magenta.txt @@ -0,0 +1 @@ +illustrated fantasy RPG art, late-1980s role-playing game cover-illustration sensibility, flat color shapes with hard edges, limited palette of six to eight hues - muted ochre, dusty slate blue, olive green, warm cream highlights, deep umber shadow, no gradients except two-step blends, strong silhouettes, readable at small size, painterly but economical detail, full body of a hunched goblin with olive-green skin, long pointed ears and a large nose, wearing a ragged brown tunic, bare feet, empty-handed, side-on three-quarter view, centered, isolated on a flat solid magenta background, complete silhouette with both arms and both legs visible, no cast shadow, no drop shadow under the feet, no ground plane diff --git a/art/prompts/retro_crpg_style.md b/art/prompts/retro_crpg_style.md index b1d5f9c..737f735 100644 --- a/art/prompts/retro_crpg_style.md +++ b/art/prompts/retro_crpg_style.md @@ -178,8 +178,8 @@ Dann `--cutout 12`. Drei Dinge, die sich bewährt haben: die Pose komplett ersetzt. 3–4 Seeds pro Motiv, dann auswählen. Basisgröße für Kreaturen: **96×96** (Ausgabe 384×384). Die *Zeichnung* darin -hat eine Größenklasse, die Canvas nicht: klein = 56, mittel = 96 (Wolf), -groß = 128 auf eigener Canvas. Umgesetzt mit `--size 56x56 --canvas 96x96` — +hat eine Größenstufe, die Canvas nicht: 56 (Ratte), 72 (Goblin), 96 (Wolf), +128 (Boss auf eigener Canvas). Umgesetzt mit `--size 56x56 --canvas 96x96` — nie über den Prompt („small rat" ändert bei FLUX nur die Pose, nicht den Maßstab). Messwerte und Regel: [`../final/Creatures/README.md`](../final/Creatures/README.md). @@ -188,6 +188,14 @@ Zwei Prompt-Zusätze, die sich am Schwanz bewährt haben: `thin` und `tapering to a point`. Ohne sie malt das Modell eine gleich dicke Röhre, und die Pflicht-Kontur macht daraus bei 96 px ein breites Band. +**Stehende Humanoiden auf magenta Grund.** FLUX malt ihnen fast immer einen +weichen Bodenschatten unter die Füße; der schließt die Lücken zwischen Beinen +und Armen ab, und der Freisteller lässt sie stehen. `flat solid magenta +background` statt Mittelgrau löst das (Schatten wird magenta mitgezeichnet), +freigestellt mit `--cutout 12 --cutout-global --shrink 1 --palette-figure`. +Grau bleibt Standard für alles ohne Bodenschatten. Details: +[`../prep/goblin-test/README.md`](../prep/goblin-test/README.md). + ## 9. Detail-Zusatz für B-Szenen (optional) Der B-Block verlangt „dense detail", nennt aber keine Gegenstände — das Modell diff --git a/art/tools/pixelize.py b/art/tools/pixelize.py index 4243765..2febb9b 100755 --- a/art/tools/pixelize.py +++ b/art/tools/pixelize.py @@ -112,12 +112,20 @@ def resize(im: Image.Image, size: tuple[int, int], resample: int, return out -def cutout(im: Image.Image, tol: float) -> Image.Image: - """Hintergrund von den Bildraendern her wegfluten -> RGBA mit Alpha 0. +def bg_mask(im: Image.Image, tol: float, deshadow: bool = False, + global_key: bool = False) -> Image.Image: + """L-Maske: 255 = Figur, 0 = Hintergrund. - Die Randfarbe wird als Hintergrund angenommen; alles, was zusammenhaengend - innerhalb der Toleranz liegt, wird transparent. Innenliegende Flaechen - gleicher Farbe bleiben stehen (kein Locher-Stanzen). + Standard: nur randverbunden (innenliegende Flaechen gleicher Farbe bleiben + stehen — kein Locher-Stanzen in grauem Fell). + `global_key`: jede hintergrundnahe Flaeche, auch eingeschlossen. Nur sicher, + wenn Figur und Hintergrund weit auseinander liegen (Chromakey, z. B. + Magenta); dann verschwinden auch Luecken zwischen Arm und Koerper. + + `deshadow` nimmt zusaetzlich neutrale Grautoene mit, deren Helligkeit im + Bereich des Hintergrunds liegt: die weichen Bodenschatten, die FLUX unter + stehende Figuren malt. Die Kontur (sehr dunkel) und helle Augen (fast weiss) + bleiben aussen vor; Farbiges ohnehin. """ from collections import deque @@ -131,12 +139,27 @@ def cutout(im: Image.Image, tol: float) -> Image.Image: counts[c] = counts.get(c, 0) + 1 bg = max(counts.items(), key=lambda kv: kv[1])[0] lim = (tol / 100.0 * 255) ** 2 * 3 + bg_lum = (0.2126 * bg[0] + 0.7152 * bg[1] + 0.0722 * bg[2]) / 255.0 + + def neutral_shadow(c: tuple[int, int, int]) -> bool: + lum = (0.2126 * c[0] + 0.7152 * c[1] + 0.0722 * c[2]) / 255.0 + return ((max(c) - min(c)) / 255.0) < 0.09 and \ + 0.55 * bg_lum <= lum <= 1.10 * bg_lum def similar(c: tuple[int, int, int]) -> bool: - return sum((c[i] - bg[i]) ** 2 for i in range(3)) <= lim + if sum((c[i] - bg[i]) ** 2 for i in range(3)) <= lim: + return True + return deshadow and neutral_shadow(c) seen = bytearray(w * h) - q = deque() + if global_key: + for y in range(h): + for x in range(w): + if similar(px[x, y]): + seen[y * w + x] = 1 + q = deque() + else: + q = deque() for x in range(w): for y in (0, h - 1): if not seen[y * w + x] and similar(px[x, y]): @@ -161,9 +184,7 @@ def cutout(im: Image.Image, tol: float) -> Image.Image: for i in range(w * h): if seen[i]: ap[i % w, i // w] = 0 - out = rgb.convert("RGBA") - out.putalpha(alpha) - return out + return alpha def draw_outline(im: Image.Image, mode: str, width: int = 1) -> Image.Image: @@ -258,7 +279,23 @@ def palette_from_image(path: Path, colors: int) -> list[tuple[int, int, int]]: return out -def palette_of(im: Image.Image, colors: int) -> list[tuple[int, int, int]]: +def palette_of(im: Image.Image, colors: int, + keep: Image.Image | None = None) -> list[tuple[int, int, int]]: + """Palette aus dem Bild; mit `keep` (L-Maske) nur aus maskierten Pixeln. + + Das ist wichtig, wenn der Hintergrund eine eigene, weit entfernte Farbe hat + (Chromakey): sonst frisst er Palettenplaetze und die Figur wird flach. + """ + if keep is not None: + rgb = im.convert("RGB") + w, h = rgb.size + px = rgb.load() + kp = keep.load() + samples = [px[x, y] for y in range(h) for x in range(w) if kp[x, y]] + if samples: + strip = Image.new("RGB", (len(samples), 1)) + strip.putdata(samples) + im = strip pal = im.quantize(colors=colors, method=Image.MEDIANCUT) raw = pal.getpalette() or [] used = sorted(set(pal.getdata())) @@ -389,6 +426,18 @@ def main(argv: list[str] | None = None) -> int: ap.add_argument("--cutout", type=float, default=None, metavar="TOL", help="Hintergrund von den Raendern weg freistellen " "(Toleranz 0-100, z. B. 12) -> RGBA") + ap.add_argument("--deshadow", action="store_true", + help="mit --cutout zusaetzlich weiche neutrale Bodenschatten " + "entfernen (Grautoene in Hintergrundhelligkeit)") + ap.add_argument("--shrink", type=int, default=0, choices=[0, 1, 2], + help="Alpha vor Palette und Kontur um N px erodieren — " + "traegt den Farbrand eines Chromakey-Hintergrunds ab") + ap.add_argument("--cutout-global", action="store_true", + help="mit --cutout auch eingeschlossene Hintergrundflaechen " + "entfernen (Chromakey: Luecken zwischen Arm und Koerper)") + ap.add_argument("--palette-figure", action="store_true", + help="mit --cutout die Palette nur aus der Figur ziehen — noetig " + "bei Chromakey, sonst frisst der Hintergrund die Plaetze") ap.add_argument("--outline", default=None, metavar="auto|#rrggbb", help="1-px-Kontur um freigestellte Sprites; 'auto' nimmt " "die angrenzende, abgedunkelte Farbe") @@ -475,6 +524,14 @@ def main(argv: list[str] | None = None) -> int: step += f"+gamma{g}" pre = step + # Palette nur aus der Figur ziehen, damit ein Chromakey-Hintergrund keine + # Plaetze frisst (bei Grau war der Effekt klein, bei Magenta gross). + keep = None + if args.cutout is not None and args.palette_figure: + keep = bg_mask(im, args.cutout, args.deshadow, args.cutout_global) + for _ in range(args.shrink): + keep = keep.filter(ImageFilter.MinFilter(3)) + if args.dither == "floyd": # Floyd-Steinberg macht Pillow selbst, inkl. Palette if args.palette: @@ -488,7 +545,7 @@ def main(argv: list[str] | None = None) -> int: if args.palette: palette = palette_from_image(args.palette, args.colors) else: - palette = palette_of(im, args.colors) + palette = palette_of(im, args.colors, keep) work = im if args.dither == "smart": amp = max(0.0, args.dither_strength) * dither_amplitude(palette) @@ -508,8 +565,20 @@ def main(argv: list[str] | None = None) -> int: step = "resize only" if args.cutout is not None: - im = cutout(im, args.cutout) - step += f"+cutout{args.cutout:g}" + # mit --palette-figure ist die Maske schon vor der Quantisierung gezogen + # (der Hintergrund traegt dann eine beliebige Palettenfarbe, Alpha + # entscheidet); sonst wie bisher auf der quantisierten Datei + mask = keep if keep is not None else bg_mask( + im, args.cutout, args.deshadow, args.cutout_global) + if keep is None: + for _ in range(args.shrink): + mask = mask.filter(ImageFilter.MinFilter(3)) + out = im.convert("RGB").convert("RGBA") + out.putalpha(mask) + im = out + step += f"+cutout{args.cutout:g}" + ("+deshadow" if args.deshadow else "") \ + + ("+global" if args.cutout_global else "") \ + + (f"+shrink{args.shrink}" if args.shrink else "") if args.outline: if im.mode != "RGBA": raise SystemExit("--outline braucht --cutout (Alpha-Kanal)") diff --git a/docs/roadmap.md b/docs/roadmap.md index 7f94d9d..a2c5dee 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -89,8 +89,8 @@ Die Richtungsfrage ist entschieden (Hybrid, siehe auf 192 verdoppeln. Eine Variable pro Probe, an einer echten Karte entschieden — nicht am Schreibtisch. - [x] **Kreaturen-Größen zueinander** (14.11.2026): Canvas bleibt für alle - Kreaturen 96×96, die *Zeichnung* darin hat eine Klasse — klein 56 - (Ratte), mittel 96 (Wolf), groß 128 (Boss, eigene Canvas). Umgesetzt mit + Kreaturen 96×96, die *Zeichnung* darin folgt einer Leiter — 56 (Ratte), + 72 (Goblin), 96 (Wolf), 128 (Boss, eigene Canvas). Umgesetzt mit `pixelize.py --canvas 96x96`; Regel und Messwerte in [`art/final/Creatures/README.md`](../art/final/Creatures/README.md). - [ ] **Referenzblatt** aus je 2–3 freigegebenen Assets pro Kategorie —