agent-manifesto-kit 1.8.1 → 1.8.2

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 (38) hide show
  1. package/README.md +18 -0
  2. package/collection/skills/concept-asset-builder/SKILL.md +124 -0
  3. package/collection/skills/concept-asset-builder/agents/openai.yaml +4 -0
  4. package/collection/skills/concept-asset-builder/assets/templates/agent_brief.md +56 -0
  5. package/collection/skills/concept-asset-builder/assets/templates/rubric.json +50 -0
  6. package/collection/skills/concept-asset-builder/assets/templates/rubric_example_vending.json +14 -0
  7. package/collection/skills/concept-asset-builder/assets/templates/scene_style_example.md +30 -0
  8. package/collection/skills/concept-asset-builder/assets/templates/wear_description_example.md +50 -0
  9. package/collection/skills/concept-asset-builder/assets/templates/zones.json +10 -0
  10. package/collection/skills/concept-asset-builder/assets/templates/zones_example_vending.json +69 -0
  11. package/collection/skills/concept-asset-builder/references/examples/postbox_blender.py +1112 -0
  12. package/collection/skills/concept-asset-builder/references/examples/postbox_wear_three.js +742 -0
  13. package/collection/skills/concept-asset-builder/references/examples/vending_materials_blender.py +487 -0
  14. package/collection/skills/concept-asset-builder/references/examples/vending_wear_three.js +798 -0
  15. package/collection/skills/concept-asset-builder/references/field-lessons.md +36 -0
  16. package/collection/skills/concept-asset-builder/references/wear-language.md +36 -0
  17. package/collection/skills/concept-asset-builder/scripts/blender/bake_export.py +174 -0
  18. package/collection/skills/concept-asset-builder/scripts/blender/render_views.py +100 -0
  19. package/collection/skills/concept-asset-builder/scripts/blender/studio.py +73 -0
  20. package/collection/skills/concept-asset-builder/scripts/capture.mjs +44 -0
  21. package/collection/skills/concept-asset-builder/scripts/codex_review.sh +88 -0
  22. package/collection/skills/concept-asset-builder/scripts/compare_to.py +24 -0
  23. package/collection/skills/concept-asset-builder/scripts/composite_godot.py +13 -0
  24. package/collection/skills/concept-asset-builder/scripts/crop.py +9 -0
  25. package/collection/skills/concept-asset-builder/scripts/gen_texture.sh +18 -0
  26. package/collection/skills/concept-asset-builder/scripts/godot/capture.gd +122 -0
  27. package/collection/skills/concept-asset-builder/scripts/godot/project.godot +18 -0
  28. package/collection/skills/concept-asset-builder/scripts/init_workspace.sh +17 -0
  29. package/collection/skills/concept-asset-builder/scripts/measure_silhouette.py +40 -0
  30. package/collection/skills/concept-asset-builder/scripts/metrics.py +144 -0
  31. package/collection/skills/concept-asset-builder/scripts/sheet.py +19 -0
  32. package/collection/skills/concept-asset-builder/scripts/test_tools.py +121 -0
  33. package/collection/skills/concept-asset-builder/scripts/threejs/index.html +23 -0
  34. package/collection/skills/concept-asset-builder/scripts/threejs/model.js +9 -0
  35. package/collection/skills/concept-asset-builder/scripts/threejs/studio.js +178 -0
  36. package/collection/skills/concept-asset-builder/scripts/wear_stats.py +130 -0
  37. package/collection/skills/concept-scene-builder/SKILL.md +16 -3
  38. package/package.json +1 -1
@@ -0,0 +1,36 @@
1
+ # Field lessons (real runs: post box pilot, 6 owner rounds + 2 agent experiments; vending machine via the conveyor)
2
+
3
+ ## Results to calibrate expectations
4
+ - Post box, hand-iterated with the owner: silhouette IoU 0.84 → 0.96 after measuring; independent reviewer 4–6.5 → 7.5/10 over 3 rounds; the owner still found 7 issues per round for 3 more rounds, mostly wear.
5
+ - Post box, agents + Codex reviewer, no owner: three.js 5 → 7, Blender 6 → 6.5 (reviewer v1, no rubric, no memory).
6
+ - Vending machine from scratch through the conveyor (style file + reviewer v2): Blender 6.3 → 6.9 → 7.1 → 7.2, three.js 6.25 → 6.85 → 6.9 → 6.9; none of the pilot's owner complaints repeated. Shape 8–9, paint 8, parts 7–8, chips 6, drips 5–6.
7
+
8
+ ## Measuring
9
+ - Geometry measured from pixels beat eyeballing immediately (IoU 0.84–0.93 on the first build). The two corrections later were base height (a contact shadow is part of the silhouette) and body radius.
10
+ - Count facets from the sheet: the owner had to point out "equal-sided octagon", not a 16-gon.
11
+ - Metric masks lie unless resolution-normalised: a 15 px window meant 3.8 cm on the concept and 1.9 cm on 2x renders, the reviewer believed "half the rust" and kept asking for more. Normalise scale, use windows in metres, drop vertical components > 20 cm (edges, grooves), overlay masks and look.
12
+ - Silhouette masks must exclude the ground shadow (background scaled by a near-constant factor).
13
+ - Colour statistics matching is not the look matching; the reviewer and close-ups decide.
14
+
15
+ ## Reviewers
16
+ - Without a rubric and memory, the reviewer contradicted itself between rounds ("lips overloaded" → "lips too fresh") and gave the same score four times while major issues dropped from 9 to 6. A weighted rubric computed by a script + the previous review + the builder's decisions log fixed it: monotonic scores, no reversals.
17
+ - A reviewer of the same model that also built the thing anchors on its intentions; use another model or a fresh context with only the inputs.
18
+ - The reviewer trusts numbers it is given; give it only numbers you have validated by overlay.
19
+ - The owner's eye still catches things the reviewer does not (mould on a hood, a too-white sign, a door that reads noisy, sharp three.js edges). Keep the owner checkpoint on the pilot and on wear.
20
+
21
+ ## Textures from image models
22
+ - Albedo textures from Codex image generation are good paint bases but bake in chips, moss, stains and "panel seams". One cap texture had 23% chips (concept ~8%) and was unusable. Clean with hue/lightness filters; never let the texture carry the wear.
23
+ - Box-projected textures sample random parts of a texture: a cap's top faces sampled the mossy bottom band → "mould on the cap". Map each part to a clean band of the texture.
24
+
25
+ ## Light, colour, engines
26
+ - Lights must turn with the camera (the concept sheet lights every view the same way); otherwise back views are 30% darker.
27
+ - AgX/ACES desaturated or shifted the red; Standard (Blender) / Neutral (three.js) kept the albedo hue. Exposure was the first big fix (renders were pink and clipped).
28
+ - Joining parts before baking made the Bevel/AO masks treat joints as edges → light outlines around the hood and the sign ("over-sharpened, noisy edges" in the engine). Bake parts separately into one atlas, join after.
29
+ - Baked AO + runtime AO = double darkening. Calibrating the engine with a material colour multiplier tinted chips and the sign blue; calibrate with light/exposure.
30
+ - Tone mapping darkened the page background in three.js (and only for one viewer, which made it look "too dark"); compensate the background or composite it.
31
+
32
+ ## Process
33
+ - Words before code: when a result is "far from the concept", write how the concept looks, how ours looks, and the top differences with one fix each.
34
+ - New effects at low strength first; every full-strength first pass overshot.
35
+ - Debug masks by rendering the mask itself (white on black / emission) — two "invisible effect" bugs were a noise Scale left at the default (5× too fine) and a falloff region too small to cross the threshold.
36
+ - Builders as fresh agents with a written brief take 40–95 minutes per object and engine; run engines in parallel, give each its own files, and let them log deviations from the spec.
@@ -0,0 +1,36 @@
1
+ # Wear language (shared by every object of a scene)
2
+
3
+ The owner judged this language "like in real life" on the pilot object; the reviewer and the measurements are built around it. Adapt colours to the object (primer, rust, grime from the concept), keep the behaviour.
4
+
5
+ ## 1. Chips — flakes, not paint spots
6
+ - Paint flaked off down to primer/metal: ragged edge, small satellite flecks next to it, a thin (1–2 mm) darker rusty rim, often vertically elongated (h/w 1.3–2). Inside a large chip the primer may be slightly mottled.
7
+ - Distribution per side: many small (< 2 cm, ~65%), some medium (2–5 cm, ~25–30%), 1–3 large (5–10 cm) — every side, including the back and the sides (an empty back reads as unfinished).
8
+ - About half sit on/near edges (facet edges, rims, frames, corners), half on faces. Protruding parts (rings, lids, frames, handles) chip more.
9
+ - Never: round or even blobs, "peas" of one size, stamped repeats, chips concentrated as big bright patches (they read as paint spots).
10
+
11
+ **Blender** (`references/examples/postbox_blender.py`, `weathered_paint`): threshold an anisotropic fractal noise (Object coords, scale ~9/9/4.5 per metre, detail 12, roughness 0.72) at a high value (~0.615); lower the threshold near edges (edge mask, below) for edge chips; a second band slightly below the threshold gives the rim; hand-place 2–4 medium/large chips on bare sides with a spherical falloff that lowers the threshold (`spots`). The vending example (`vending_materials_blender.py`, `paint`) uses size classes from cells; either works if the size histogram matches the description.
12
+ **Three.js** (`references/examples/postbox_wear_three.js`, `vending_wear_three.js`): explicit chip placement in a canvas in object/UV space with a seeded RNG (count and size classes from the description, half snapped to edges), each chip shaped by thresholded domain-warped fbm plus a second octave at ~3.5× frequency for a ragged edge, satellite flecks, rim band. Pure per-pixel noise thresholds tend to give either confetti or blobs.
13
+
14
+ ## 2. Edge wear — edges and protruding parts first
15
+ - A broken strip of primer 2–8 mm wide along edges, with gaps (on 30–60% of an edge's length), bare grey-brown metal in the very core of the strongest spots. Strength: lids/caps/ridges > rims and frames > handles > body vertical edges > flat faces.
16
+ - Real rounded geometry is a precondition: a sharp edge has nothing to wear and looks like cardboard.
17
+
18
+ **Blender**: edge mask = 1 − dot(Bevel node normal (radius ~1–1.5 cm), geometry normal), broken by a mid-frequency noise; for large radii the Bevel node sees nothing — use a mask from the normal (e.g. the band where the normal turns on a rounded roof). Mix primer, then metal on the strongest band; metal gets lower roughness/higher metallic.
19
+ **Three.js**: compute distance-to-edge per vertex or in the wear canvas from the known geometry (facet edges, rims, frame outlines), break it into runs with a 1D noise along the edge.
20
+
21
+ ## 3. Rust drips — clusters from real sources
22
+ - Sources only: seams, the bottom of protruding parts (rings, boxes, panels, frames, buttons, handles, vents), hinges, screws. Never a uniform row around the whole object at one height with equal spacing ("comb"), never long streaks (> 15 cm), never thin hairlines everywhere ("wood grain").
23
+ - A cluster: a stain at the source 2–2.5× wider than the drip below it (12–25 mm tall, rounded bottom), then 1–5 thin strands; strand lengths follow a bell curve across the cluster (centre longest, may be skewed), typical 3–8 cm, a few up to 12–15 cm; clusters vary in size (0.4–1×) and spacing (roughly half of the possible slots are used).
24
+ - Colour: orange-brown in the strand, darker brown at the source; on light paint they read by hue, on red paint by darkness.
25
+ - Small parts people look at closely (doors, hatches, slots): drips matter more than abrasion there — heavy wear on them reads as noise.
26
+
27
+ **Blender** (`drips()` in the post box example): per source (height, max length, optional front half-width, seed): arc/x coordinate cut into ~7.5 cm cells; per-cell white noise picks active/centre/width/size; strands from 1D noise along the arc at ~150 cycles/m; length = maxlen · exp(−2.6 t²) · jitter(0.55–1) · size.
28
+ **Three.js**: the same model per pixel in a canvas (the post box example), strands 2–3.5 mm wide so they survive the capture resolution.
29
+
30
+ ## 4. Grime and mould
31
+ - Olive grime/mould only where water and dirt collect: the bottom 5–10 cm of the body, feet, plinths, ledges of the base. Never on lids, hoods, panels, doors or rings.
32
+ - Generated textures often carry green/brown patches: remove them with a hue filter on the parts that must stay clean.
33
+
34
+ ## 5. Signs, marks, small details
35
+ - Dull, not fresh: off-white/cream instead of white, slightly soft edges, a few small chips through to the paint, light grime.
36
+ - Openings (slots, windows, pickup flaps) stay crisp: little wear right at the opening edge, a visible inner floor/lip, dark brown rather than pure black inside.
@@ -0,0 +1,174 @@
1
+ """Bake the procedural Cycles look of blender/object.blend into textures and export out/object.glb.
2
+
3
+ Run: Blender -b --factory-startup blender/object.blend --python blender/bake_export.py -- [--res 2048] [--samples 64]
4
+ Bakes base colour (incl. procedural chips / drips / crevice grime), ambient occlusion, roughness and the
5
+ tangent-space normal of the bump detail onto one atlas UV, multiplies AO into the base colour (static prop),
6
+ and exports a single-material GLB for the three.js viewer (pipeline C).
7
+ """
8
+ import bpy, os, sys
9
+ import numpy as np
10
+
11
+ ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
12
+ argv = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
13
+ RES = int(argv[argv.index("--res") + 1]) if "--res" in argv else 2048
14
+ SAMPLES = int(argv[argv.index("--samples") + 1]) if "--samples" in argv else 64
15
+ TEXDIR = os.path.join(ROOT, "out/glb_tex")
16
+ os.makedirs(TEXDIR, exist_ok=True)
17
+
18
+ scene = bpy.context.scene
19
+ scene.render.engine = "CYCLES"
20
+ scene.cycles.samples = SAMPLES
21
+ dg = bpy.context.evaluated_depsgraph_get()
22
+
23
+ # 1. evaluated copies of every visible part, joined into one object at the origin
24
+ parts = []
25
+ for o in list(scene.objects):
26
+ if o.type != "MESH" or o.hide_render or o.is_shadow_catcher:
27
+ continue
28
+ oe = o.evaluated_get(dg)
29
+ me = bpy.data.meshes.new_from_object(oe, preserve_all_data_layers=True, depsgraph=dg)
30
+ me.transform(o.matrix_world)
31
+ no = bpy.data.objects.new(o.name + "_eval", me)
32
+ scene.collection.objects.link(no)
33
+ parts.append(no)
34
+ for o in list(scene.objects):
35
+ if o not in parts and o.type == "MESH":
36
+ o.hide_render = True
37
+ o.hide_set(True)
38
+
39
+ bpy.ops.object.select_all(action="DESELECT")
40
+ for p in parts:
41
+ p.select_set(True)
42
+ if not p.data.uv_layers:
43
+ p.data.uv_layers.new(name="UVMap")
44
+ for i, slot in enumerate(p.material_slots):
45
+ if slot.material is None:
46
+ slot.material = next((m for m in bpy.data.materials if m.users), None)
47
+ bpy.context.view_layer.objects.active = parts[0]
48
+
49
+ # 2. one shared atlas UV over all parts (multi-object edit packs every island into the same 0-1 space).
50
+ # Parts stay SEPARATE while baking: joined, the Bevel/AO masks saw the joints (hood/body, mark/body) as edges
51
+ # and baked light outlines around them (user r6: "noise along the edges" in C).
52
+ for p in parts:
53
+ uvl = p.data.uv_layers.new(name="bake")
54
+ p.data.uv_layers.active = uvl
55
+ bpy.ops.object.mode_set(mode="EDIT")
56
+ bpy.ops.mesh.select_all(action="SELECT")
57
+ bpy.ops.uv.smart_project(angle_limit=1.15, island_margin=0.006, area_weight=0.0, scale_to_bounds=True)
58
+ try:
59
+ bpy.ops.uv.pack_islands(margin=0.006, rotate=True)
60
+ except Exception as e:
61
+ print("pack_islands skipped:", e)
62
+ bpy.ops.object.mode_set(mode="OBJECT")
63
+ mats = {s_.material for p in parts for s_ in p.material_slots if s_.material}
64
+
65
+
66
+ # 3. bake helpers
67
+ def target_image(name, non_color=False):
68
+ img = bpy.data.images.new(name, RES, RES, alpha=False, float_buffer=False)
69
+ if non_color:
70
+ img.colorspace_settings.name = "Non-Color"
71
+ for mat_ in mats:
72
+ nt = mat_.node_tree
73
+ n = nt.nodes.get("__bake__") or nt.nodes.new("ShaderNodeTexImage")
74
+ n.name = "__bake__"
75
+ n.image = img
76
+ nt.nodes.active = n
77
+ return img
78
+
79
+
80
+ def bake(kind, img, **kw):
81
+ bpy.ops.object.select_all(action="DESELECT")
82
+ for p in parts:
83
+ p.select_set(True)
84
+ bpy.context.view_layer.objects.active = parts[0]
85
+ bpy.ops.object.bake(type=kind, margin=12, use_clear=True, uv_layer="bake", **kw)
86
+ path = os.path.join(TEXDIR, img.name + ".png")
87
+ img.filepath_raw = path
88
+ img.file_format = "PNG"
89
+ img.save()
90
+ print("baked", kind, "->", path)
91
+ return img
92
+
93
+
94
+ col = bake("DIFFUSE", target_image("basecolor_raw"), pass_filter={"COLOR"})
95
+ ao = bake("AO", target_image("ao", non_color=True))
96
+ rough = bake("ROUGHNESS", target_image("roughness", non_color=True))
97
+ nrm = bake("NORMAL", target_image("normal", non_color=True), normal_space="TANGENT")
98
+
99
+
100
+ def px(img):
101
+ a = np.empty(RES * RES * 4, np.float32)
102
+ img.pixels.foreach_get(a)
103
+ return a.reshape(RES, RES, 4)
104
+
105
+
106
+ # 4. AO into base colour (sRGB display values are stored in pixels for byte images)
107
+ c, a = px(col), px(ao)
108
+ aof = 0.55 + 0.45 * a[..., :1]
109
+ out = c.copy()
110
+ out[..., :3] = np.clip(c[..., :3] * aof, 0, 1)
111
+ final = bpy.data.images.new("basecolor", RES, RES, alpha=False)
112
+ final.pixels.foreach_set(out.ravel())
113
+ final.filepath_raw = os.path.join(TEXDIR, "basecolor.png")
114
+ final.file_format = "PNG"
115
+ final.save()
116
+
117
+ # 5. join the parts now (after baking) and give them a single glTF-friendly material
118
+ bpy.ops.object.select_all(action="DESELECT")
119
+ for p in parts:
120
+ p.select_set(True)
121
+ bpy.context.view_layer.objects.active = parts[0]
122
+ bpy.ops.object.join()
123
+ obj = bpy.context.view_layer.objects.active
124
+ obj.name = "object"
125
+ me = obj.data
126
+
127
+ mat = bpy.data.materials.new("object_baked")
128
+ nt = mat.node_tree
129
+ for n in list(nt.nodes):
130
+ nt.nodes.remove(n)
131
+ outn = nt.nodes.new("ShaderNodeOutputMaterial")
132
+ bsdf = nt.nodes.new("ShaderNodeBsdfPrincipled")
133
+ nt.links.new(bsdf.outputs["BSDF"], outn.inputs["Surface"])
134
+ uvn = nt.nodes.new("ShaderNodeUVMap")
135
+ uvn.uv_map = "bake"
136
+
137
+
138
+ def tex(img_path, non_color):
139
+ t = nt.nodes.new("ShaderNodeTexImage")
140
+ t.image = bpy.data.images.load(img_path)
141
+ if non_color:
142
+ t.image.colorspace_settings.name = "Non-Color"
143
+ nt.links.new(uvn.outputs["UV"], t.inputs["Vector"])
144
+ return t
145
+
146
+
147
+ tb = tex(os.path.join(TEXDIR, "basecolor.png"), False)
148
+ nt.links.new(tb.outputs["Color"], bsdf.inputs["Base Color"])
149
+ tr = tex(os.path.join(TEXDIR, "roughness.png"), True)
150
+ sep = nt.nodes.new("ShaderNodeSeparateColor")
151
+ nt.links.new(tr.outputs["Color"], sep.inputs["Color"])
152
+ nt.links.new(sep.outputs[0], bsdf.inputs["Roughness"])
153
+ bsdf.inputs["Metallic"].default_value = 0.0
154
+ tn = tex(os.path.join(TEXDIR, "normal.png"), True)
155
+ nm = nt.nodes.new("ShaderNodeNormalMap")
156
+ nm.uv_map = "bake"
157
+ nt.links.new(tn.outputs["Color"], nm.inputs["Color"])
158
+ nt.links.new(nm.outputs["Normal"], bsdf.inputs["Normal"])
159
+
160
+ me.materials.clear()
161
+ me.materials.append(mat)
162
+ for poly in me.polygons:
163
+ poly.material_index = 0
164
+ for uvl in [u for u in me.uv_layers if u.name != "bake"]:
165
+ me.uv_layers.remove(uvl)
166
+
167
+ bpy.ops.object.select_all(action="DESELECT")
168
+ obj.select_set(True)
169
+ bpy.context.view_layer.objects.active = obj
170
+ glb = os.path.join(ROOT, "out/object.glb")
171
+ bpy.ops.export_scene.gltf(filepath=glb, export_format="GLB", use_selection=True, export_yup=True,
172
+ export_apply=True, export_normals=True, export_tangents=True, export_materials="EXPORT")
173
+ print("exported", glb, "tris:", sum(len(p.vertices) - 2 for p in me.polygons))
174
+ bpy.ops.wm.save_as_mainfile(filepath=os.path.join(ROOT, "blender/object_baked.blend"))
@@ -0,0 +1,100 @@
1
+ """Render the five concept views of blender/object.blend with Cycles.
2
+
3
+ Run: Blender -b blender/object.blend --python blender/render_views.py -- [view ...] [--samples N]
4
+ Writes out/blender/raw/<view>.png (RGBA, transparent background + shadow) and
5
+ out/blender/<view>.png (composited on the spec background colour).
6
+ """
7
+ import bpy, json, math, os, sys
8
+ from mathutils import Vector
9
+ from bpy_extras.object_utils import world_to_camera_view
10
+
11
+ ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
12
+ SPEC = json.load(open(os.path.join(ROOT, "spec/object.json")))
13
+ argv = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
14
+ samples = None
15
+ if "--samples" in argv:
16
+ i = argv.index("--samples")
17
+ samples = int(argv[i + 1])
18
+ del argv[i:i + 2]
19
+ views = argv or list(SPEC["cameras"]["views"].keys())
20
+
21
+ scene = bpy.context.scene
22
+ if samples:
23
+ scene.cycles.samples = samples
24
+ cam = scene.camera
25
+ el = math.radians(SPEC["cameras"]["elevation_deg"])
26
+ fill = SPEC["cameras"].get("fill", 0.92)
27
+ rig = scene.objects.get("light_rig")
28
+
29
+ dg = bpy.context.evaluated_depsgraph_get()
30
+ pts = []
31
+ for o in scene.objects:
32
+ if o.type == "MESH" and not o.hide_render and not o.is_shadow_catcher:
33
+ oe = o.evaluated_get(dg)
34
+ pts += [oe.matrix_world @ Vector(c) for c in oe.bound_box]
35
+ lo = Vector((min(p.x for p in pts), min(p.y for p in pts), min(p.z for p in pts)))
36
+ hi = Vector((max(p.x for p in pts), max(p.y for p in pts), max(p.z for p in pts)))
37
+ corners = [Vector((x, y, z)) for x in (lo.x, hi.x) for y in (lo.y, hi.y) for z in (lo.z, hi.z)]
38
+ target = (lo + hi) / 2
39
+
40
+
41
+ def place(az_deg, d):
42
+ global el
43
+ az = math.radians(az_deg)
44
+ # spec: camera at (sin az, ., cos az) in (x, z-front); blender front is -Y
45
+ off = Vector((d * math.sin(az) * math.cos(el), -d * math.cos(az) * math.cos(el), d * math.sin(el)))
46
+ cam.location = target + off
47
+ cam.rotation_euler = (-off).to_track_quat("-Z", "Y").to_euler()
48
+ bpy.context.view_layer.update()
49
+
50
+
51
+ def fit(az_deg):
52
+ d = 5.0
53
+ for _ in range(6):
54
+ place(az_deg, d)
55
+ ys = [world_to_camera_view(scene, cam, c).y for c in corners]
56
+ ext = max(ys) - min(ys)
57
+ d *= ext / fill
58
+ place(az_deg, d)
59
+ # centre vertically
60
+ ys = [world_to_camera_view(scene, cam, c).y for c in corners]
61
+ return d
62
+
63
+
64
+ raw_dir = os.path.join(ROOT, "out/blender/raw")
65
+ os.makedirs(raw_dir, exist_ok=True)
66
+ for v in views:
67
+ az = SPEC["cameras"]["views"][v]
68
+ el = math.radians(SPEC["cameras"].get("elevation_overrides", {}).get(v, SPEC["cameras"]["elevation_deg"]))
69
+ fit(az)
70
+ if rig: # lights turn with the camera: every concept view is lit the same way
71
+ rig.rotation_euler = (0, 0, math.radians(az))
72
+ scene.render.filepath = os.path.join(raw_dir, v + ".png")
73
+ scene.render.image_settings.file_format = "PNG"
74
+ scene.render.image_settings.color_mode = "RGBA"
75
+ bpy.ops.render.render(write_still=True)
76
+ print("rendered", v)
77
+
78
+ # composite onto background (numpy ships with Blender)
79
+ import numpy as np
80
+ bg_hex = SPEC["palette"]["background"].lstrip("#")
81
+ bgc = np.array([int(bg_hex[i:i + 2], 16) / 255 for i in (0, 2, 4)], dtype=np.float32)
82
+ for v in views:
83
+ img = bpy.data.images.load(os.path.join(raw_dir, v + ".png"))
84
+ w, h = img.size
85
+ px = np.empty(w * h * 4, dtype=np.float32)
86
+ img.pixels.foreach_get(px)
87
+ px = px.reshape(h, w, 4)
88
+ a = px[..., 3:4].copy()
89
+ # shadow-catcher pixels are black with partial alpha: soften the ground shadow (concept has a faint one)
90
+ shadow = (px[..., :3].max(2, keepdims=True) < 0.03) & (a < 0.995)
91
+ a = np.where(shadow, a * 0.2, a)
92
+ # PNG loaded as straight alpha in display space
93
+ rgb = px[..., :3] * a + bgc * (1 - a)
94
+ out = np.concatenate([rgb, np.ones_like(a)], axis=2)
95
+ o = bpy.data.images.new(v + "_comp", w, h, alpha=False)
96
+ o.pixels.foreach_set(out.ravel())
97
+ o.filepath_raw = os.path.join(ROOT, "out/blender", v + ".png")
98
+ o.file_format = "PNG"
99
+ o.save()
100
+ print("composited", v)
@@ -0,0 +1,73 @@
1
+ """Shared neutral studio for every object of the scene (same as the post box studio, scaled to the object height).
2
+ Usage inside a build script (Blender, background):
3
+ import sys, os; sys.path.insert(0, os.path.dirname(__file__)); import studio
4
+ ... build the object (Z-up, front faces -Y, ground at z=0) ...
5
+ studio.setup(SPEC) # render settings, world, camera-relative light rig, shadow catcher, camera
6
+ studio.save(ROOT, "object") # -> blender/object.blend (render_views.py renders it)
7
+ Do not change the light values: all objects of the scene must be lit identically.
8
+ """
9
+ import bpy, math, os
10
+ from mathutils import Vector
11
+
12
+
13
+ def _link(obj):
14
+ bpy.context.scene.collection.objects.link(obj)
15
+ return obj
16
+
17
+
18
+ def setup(spec):
19
+ scene = bpy.context.scene
20
+ scene.render.engine = "CYCLES"
21
+ scene.cycles.samples = 128
22
+ scene.cycles.use_denoising = True
23
+ try:
24
+ prefs = bpy.context.preferences.addons["cycles"].preferences
25
+ prefs.compute_device_type = "METAL"
26
+ prefs.get_devices()
27
+ for d in prefs.devices:
28
+ d.use = True
29
+ scene.cycles.device = "GPU"
30
+ except Exception as e:
31
+ print("GPU setup failed, using CPU:", e)
32
+ scene.render.film_transparent = True
33
+ scene.render.resolution_x, scene.render.resolution_y = spec["cameras"]["image"]
34
+ scene.render.resolution_percentage = 100
35
+ scene.view_settings.view_transform = "Standard"
36
+ try:
37
+ scene.view_settings.look = "None"
38
+ except Exception:
39
+ pass
40
+ scene.view_settings.exposure = -0.3
41
+ world = bpy.data.worlds.new("studio")
42
+ scene.world = world
43
+ nt = world.node_tree
44
+ bg = nt.nodes.get("Background") or nt.nodes.new("ShaderNodeBackground")
45
+ bg.inputs["Color"].default_value = (1, 1, 1, 1)
46
+ bg.inputs["Strength"].default_value = 0.16
47
+ out = nt.nodes.get("World Output") or nt.nodes.new("ShaderNodeOutputWorld")
48
+ nt.links.new(bg.outputs["Background"], out.inputs["Surface"])
49
+ k = spec["height"] / 1.35 # post box studio scaled to this object's size
50
+ ty = spec["cameras"].get("target_y", spec["height"] * 0.5)
51
+ rig = _link(bpy.data.objects.new("light_rig", None))
52
+ rig.location = (0, 0, ty)
53
+ for name, az, el, dist, size, power in (("key", -40, 38, 4.0, 3.0, 210), ("fill", 55, 15, 4.0, 3.0, 85), ("rim", 170, 35, 4.0, 2.5, 70)):
54
+ a, e = math.radians(az), math.radians(el)
55
+ d = dist * k
56
+ off = Vector((d * math.sin(a) * math.cos(e), -d * math.cos(a) * math.cos(e), d * math.sin(e)))
57
+ ld = bpy.data.lights.new(name, "AREA"); ld.shape = "DISK"; ld.size = size * k; ld.energy = power * k * k
58
+ lo = _link(bpy.data.objects.new(name, ld))
59
+ lo.location = rig.location + off
60
+ lo.rotation_euler = (-off).to_track_quat("-Z", "Y").to_euler()
61
+ lo.parent = rig
62
+ lo.location = off
63
+ bpy.ops.mesh.primitive_plane_add(size=10 * k, location=(0, 0, 0))
64
+ g = bpy.context.active_object; g.name = "shadow_catcher"; g.is_shadow_catcher = True
65
+ cd = bpy.data.cameras.new("cam"); cd.sensor_fit = "VERTICAL"; cd.angle_y = math.radians(spec["cameras"]["fov_deg"])
66
+ scene.camera = _link(bpy.data.objects.new("cam", cd))
67
+
68
+
69
+ def save(root, name="object"):
70
+ os.makedirs(os.path.join(root, "blender"), exist_ok=True)
71
+ path = os.path.join(root, "blender", f"{name}.blend")
72
+ bpy.ops.wm.save_as_mainfile(filepath=path)
73
+ print("saved", path)
@@ -0,0 +1,44 @@
1
+ // Capture fixed-camera renders of pipeline A (threejs) and C (Blender GLB in three.js).
2
+ // Usage: node tools/capture.mjs [threejs|glb|all] [--views front,3q] [--query ao=0] [--base http://localhost:5181]
3
+ // Needs the vite server running (npx vite --port 5181).
4
+ import { chromium } from 'playwright';
5
+ import { readFileSync, mkdirSync } from 'node:fs';
6
+ import { fileURLToPath } from 'node:url';
7
+ import path from 'node:path';
8
+
9
+ const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
10
+ const spec = JSON.parse(readFileSync(path.join(root, 'spec/object.json'), 'utf8'));
11
+ const what = process.argv[2] || 'all';
12
+ const baseIdx = process.argv.indexOf('--base');
13
+ const base = baseIdx > 0 ? process.argv[baseIdx + 1] : 'http://localhost:5191';
14
+ const [w, h] = spec.cameras.image;
15
+ const viewsIdx = process.argv.indexOf('--views');
16
+ const views = viewsIdx > 0 ? process.argv[viewsIdx + 1].split(',') : Object.keys(spec.cameras.views);
17
+ const qIdx = process.argv.indexOf('--query');
18
+ const extraQuery = qIdx > 0 ? `&${process.argv[qIdx + 1]}` : '';
19
+
20
+ const targets = [];
21
+ if (what === 'threejs' || what === 'all') targets.push({ page: 'threejs/index.html', out: 'out/threejs' });
22
+ if (what === 'glb' || what === 'all') targets.push({ page: 'threejs/glb.html', out: 'out/glb_in_three' });
23
+
24
+ const browser = await chromium.launch({ args: ['--use-angle=metal', '--enable-gpu', '--ignore-gpu-blocklist'] });
25
+ const page = await browser.newPage({ viewport: { width: w, height: h }, deviceScaleFactor: 1 });
26
+ page.on('pageerror', (e) => console.error('pageerror:', e.message));
27
+ // optional maps (roughness/normal) are probed and may 404: not an error
28
+ page.on('console', (m) => { if (m.type() === 'error' && !m.text().includes('404')) console.error('console:', m.text()); });
29
+
30
+ for (const t of targets) {
31
+ mkdirSync(path.join(root, t.out), { recursive: true });
32
+ for (const v of views) {
33
+ await page.goto(`${base}/${t.page}?view=${v}${extraQuery}`);
34
+ await page.waitForFunction(() => window.__ready === true, null, { timeout: 60000 });
35
+ if (await page.evaluate(() => window.__missing === true)) {
36
+ console.log(`${t.page}: GLB missing, skipped`);
37
+ break;
38
+ }
39
+ const file = path.join(root, t.out, `${v}.png`);
40
+ await page.locator('canvas').screenshot({ path: file });
41
+ console.log('saved', path.relative(root, file));
42
+ }
43
+ }
44
+ await browser.close();
@@ -0,0 +1,88 @@
1
+ #!/bin/bash
2
+ # v2 context-free review by Codex CLI with a fixed rubric and memory of the previous round.
3
+ # Usage: tools/codex_review.sh <pipeline> <round> (pipeline = blender | threejs | any folder name in out/)
4
+ # Reviewer model: CODEX_MODEL (default gpt-6.2-sol), reasoning effort high. Needs the Codex CLI with image input.
5
+ # Inputs: out/<pipeline>/{3q,front,back,left,right}.png, brief/wear_description.md, brief/scene_style.md,
6
+ # brief/rubric.json, reviews/<pipeline>_r<round-1>.md (if any), reviews/<pipeline>_decisions.md (optional,
7
+ # written by the builder: what it changed and why, incl. deliberate deviations).
8
+ # Output: reviews/<pipeline>_r<round>.md (+ .json scores, .log), reviews/img/<pipeline>_r<round>_*.png
9
+ set -u
10
+ ROOT="$(cd "$(dirname "$0")/.." && pwd)"
11
+ PIPE="${1:?pipeline}"; ROUND="${2:?round}"; PREV=$((ROUND - 1))
12
+ MODEL="${CODEX_MODEL:-gpt-6.2-sol}"
13
+ IMG="$ROOT/reviews/img"; mkdir -p "$IMG"
14
+ TAG="${PIPE}_r${ROUND}"
15
+ for v in 3q front back left right; do python3 "$ROOT/tools/sheet.py" "$IMG/${TAG}_$v.png" "$v" "$PIPE" 1.0; done
16
+ python3 - "$ROOT" "$PIPE" "$IMG/$TAG" <<'PY'
17
+ import sys, pathlib
18
+ from PIL import Image
19
+ root, pipe, base = pathlib.Path(sys.argv[1]), sys.argv[2], sys.argv[3]
20
+ H = 1100
21
+ def crop(p, fr):
22
+ im = Image.open(p).convert("RGB")
23
+ if im.height != H: im = im.resize((round(im.width * H / im.height), H), Image.LANCZOS)
24
+ w = im.width; x0, y0, x1, y1 = fr
25
+ c = im.crop((int(x0 * w), int(y0 * H), int(x1 * w), int(y1 * H)))
26
+ return c.resize((c.width * 2, c.height * 2), Image.LANCZOS)
27
+ for v, fr, n in (("front", (0.0, 0.0, 1.0, 0.5), "detail_front_top"), ("front", (0.0, 0.45, 1.0, 1.0), "detail_front_bottom"),
28
+ ("back", (0.0, 0.3, 1.0, 1.0), "detail_back")):
29
+ a, b = crop(root / f"reference/crops/{v}.png", fr), crop(root / f"out/{pipe}/{v}.png", fr)
30
+ s = Image.new("RGB", (a.width + b.width + 16, max(a.height, b.height)), "black"); s.paste(a, (0, 0)); s.paste(b, (a.width + 16, 0))
31
+ s.save(f"{base}_{n}.png")
32
+ PY
33
+ STATS_C=$(python3 "$ROOT/tools/wear_stats.py" 2>/dev/null | sed -n '/^\[/,$p')
34
+ STATS_R=$(python3 "$ROOT/tools/wear_stats.py" "$ROOT/out/$PIPE" 2>/dev/null | sed -n '/^\[/,$p')
35
+ PREV_TXT="(none: first round)"; [ -f "$ROOT/reviews/${PIPE}_r${PREV}.md" ] && PREV_TXT=$(cat "$ROOT/reviews/${PIPE}_r${PREV}.md")
36
+ DEC_TXT="(none)"; [ -f "$ROOT/reviews/${PIPE}_decisions.md" ] && DEC_TXT=$(cat "$ROOT/reviews/${PIPE}_decisions.md")
37
+ IMGS=(); for f in "$IMG/${TAG}_"*.png; do IMGS+=(-i "$f"); done
38
+ SCORES_EXAMPLE=$(python3 -c "import json,sys; r=json.load(open(sys.argv[1]))['criteria']; print(json.dumps({'scores': {c['id']: 'n' for c in r}}).replace('\"n\"','n'))" "$ROOT/brief/rubric.json")
39
+ command codex exec -m "$MODEL" -c model_reasoning_effort=high --skip-git-repo-check --sandbox read-only \
40
+ -C "$ROOT" "${IMGS[@]}" -o "$ROOT/reviews/${TAG}.md" > "$ROOT/reviews/${TAG}.log" 2>&1 <<PROMPT
41
+ You are an independent art reviewer. Your only context is this message and the attached images.
42
+ Images *_<view>.png: LEFT the reference concept, RIGHT a 3D render of the same object (views 3q, front, back, left, right).
43
+ *_detail_*.png: 2x close-ups, LEFT concept, RIGHT render. Lighting and camera are fixed by the studio and NOT under review.
44
+
45
+ OBJECT AND WEAR DESCRIPTION (source of truth, Russian):
46
+ $(cat "$ROOT/brief/wear_description.md")
47
+
48
+ SCENE STYLE RULES agreed with the owner on a previous object (must hold here too):
49
+ $(cat "$ROOT/brief/scene_style.md")
50
+
51
+ RUBRIC (score each criterion 0-10; 10 = indistinguishable from the concept for that criterion):
52
+ $(cat "$ROOT/brief/rubric.json")
53
+
54
+ MEASUREMENTS (same script on both; read the caveats in the description):
55
+ --- concept ---
56
+ $STATS_C
57
+ --- render ---
58
+ $STATS_R
59
+
60
+ YOUR PREVIOUS REVIEW OF THIS RENDER PIPELINE (round $PREV):
61
+ $PREV_TXT
62
+
63
+ BUILDER'S DECISIONS LOG:
64
+ $DEC_TXT
65
+
66
+ Rules for consistency: do not reverse a requirement you made in the previous round unless the description or the style rules say otherwise; if you change your mind, say so explicitly and why. For each item of your previous top list say fixed / improved / open. Judge against the description and the concept, not your taste.
67
+
68
+ Answer in Russian, markdown, concise:
69
+ 1. A fenced json block exactly like $SCORES_EXAMPLE (integers 0-10, one per rubric criterion).
70
+ 2. Table: | критерий | что на рендере vs описание | оценка | конкретная правка (что, где, сколько) |.
71
+ 3. Status of the previous round's top items (fixed / improved / open).
72
+ 4. Top-5 fixes ranked by impact.
73
+ Do not modify any files.
74
+ PROMPT
75
+ python3 - "$ROOT" "$TAG" <<'PY'
76
+ import sys, re, json, pathlib
77
+ root, tag = pathlib.Path(sys.argv[1]), sys.argv[2]
78
+ txt = (root / f"reviews/{tag}.md").read_text() if (root / f"reviews/{tag}.md").exists() else ""
79
+ m = re.search(r"\{\s*\"scores\"\s*:\s*\{.*?\}\s*\}", txt, re.S)
80
+ rub = json.loads((root / "brief/rubric.json").read_text())["criteria"]
81
+ if not m:
82
+ print("no scores json found"); sys.exit(0)
83
+ sc = json.loads(m.group(0))["scores"]
84
+ total = sum(c["weight"] * float(sc.get(c["id"], 0)) for c in rub)
85
+ out = {"scores": sc, "weighted_total": round(total, 2)}
86
+ (root / f"reviews/{tag}.json").write_text(json.dumps(out, indent=1, ensure_ascii=False))
87
+ print(f"weighted total {total:.2f}/10 -> reviews/{tag}.json")
88
+ PY
@@ -0,0 +1,24 @@
1
+ """Zone brightness/chroma of one pipeline vs another (default: godot vs blender).
2
+ Usage: python3 tools/compare_to.py [pipe] [ref] [views]"""
3
+ import sys, pathlib
4
+ import numpy as np
5
+ sys.path.insert(0, str(pathlib.Path(__file__).parent))
6
+ import metrics as M
7
+ pipe = sys.argv[1] if len(sys.argv) > 1 else "godot"
8
+ ref = sys.argv[2] if len(sys.argv) > 2 else "blender"
9
+ views = sys.argv[3].split(",") if len(sys.argv) > 3 else M.VIEWS
10
+ acc = {}
11
+ for v in views:
12
+ out = {}
13
+ for p in (pipe, ref):
14
+ img = M.load(M.ROOT / f"out/{p}/{v}.png"); m = M.mask_of(img); b = M.bbox(m)
15
+ zs = M.zone_stats(img, m, b)
16
+ out[p] = zs
17
+ for z in M.ZONES:
18
+ a, r = out[pipe][z], out[ref][z]
19
+ d = [a["L_p10_p90"][0] - r["L_p10_p90"][0], a["lab_median"][0] - r["lab_median"][0],
20
+ a["L_p10_p90"][1] - r["L_p10_p90"][1], a["chroma_median"] - r["chroma_median"]]
21
+ acc.setdefault(z, []).append(d)
22
+ print(f"mean {pipe}-{ref} (Lp10 Lp50 Lp90 chroma):")
23
+ for z, ds in acc.items():
24
+ print(f" {z:5s}", " ".join(f"{x:+6.1f}" for x in np.mean(ds, 0)))
@@ -0,0 +1,13 @@
1
+ """Composite Godot RGBA captures (out/godot/raw) onto the spec background -> out/godot/<view>.png"""
2
+ import json, pathlib
3
+ import numpy as np
4
+ from PIL import Image
5
+ ROOT = pathlib.Path(__file__).resolve().parent.parent
6
+ bg = json.loads((ROOT / "spec/object.json").read_text())["palette"]["background"].lstrip("#")
7
+ bgc = np.array([int(bg[i:i + 2], 16) for i in (0, 2, 4)], np.float32)
8
+ for p in sorted((ROOT / "out/godot/raw").glob("*.png")):
9
+ a = np.asarray(Image.open(p).convert("RGBA")).astype(np.float32)
10
+ al = a[..., 3:4] / 255
11
+ rgb = a[..., :3] * al + bgc * (1 - al)
12
+ Image.fromarray(rgb.round().astype(np.uint8)).save(ROOT / "out/godot" / p.name)
13
+ print("composited", p.name, "alpha range", float(al.min()), float(al.max()))
@@ -0,0 +1,9 @@
1
+ """Crop concept views by reference/boxes.json -> reference/crops/<name>.png"""
2
+ import json, sys, pathlib
3
+ from PIL import Image
4
+ root = pathlib.Path(__file__).resolve().parent.parent
5
+ img = Image.open(root / "reference/concept.png").convert("RGB")
6
+ (root / "reference/crops").mkdir(parents=True, exist_ok=True)
7
+ for name, box in json.loads((root / "reference/boxes.json").read_text()).items():
8
+ img.crop(tuple(box)).save(root / f"reference/crops/{name}.png")
9
+ print(name, box)
@@ -0,0 +1,18 @@
1
+ #!/bin/bash
2
+ # Generate one albedo texture with Codex CLI image generation (gpt-6.2-sol, high).
3
+ # Usage: tools/gen_texture.sh <out.png relative to the experiment root> <WxH> <seamless: x|xy|none> "<description>"
4
+ # The concept sheet is attached as the style reference. Flat albedo only (no light/shadows/objects/text).
5
+ set -u
6
+ ROOT="$(cd "$(dirname "$0")/.." && pwd)"
7
+ OUT="$1"; SIZE="$2"; SEAM="$3"; DESC="$4"
8
+ mkdir -p "$ROOT/textures/logs"
9
+ command codex exec -m "${CODEX_MODEL:-gpt-6.2-sol}" -c model_reasoning_effort=high --skip-git-repo-check \
10
+ --sandbox workspace-write -C "$ROOT" -i "$ROOT/reference/concept.png" > "$ROOT/textures/logs/$(basename "$OUT").log" 2>&1 <<PROMPT
11
+ Generate a texture for a game asset with your image generation tool. The attached image is the concept sheet: match
12
+ its colours and material look. TEXTURE: $DESC
13
+ Rules: flat albedo only, evenly lit, no shading, no shadows, no highlights, no perspective, no objects, no text,
14
+ no border, fills the canvas. Save it as $OUT (create folders), then with python3 (PIL + numpy installed) resize to
15
+ $SIZE and make it seamless ($SEAM: x = horizontally, xy = both, none = not) by cross-fading opposite edges over ~6%
16
+ (blend only, no mirroring). Verify the file exists and print its size. Create no other files.
17
+ PROMPT
18
+ echo "exit $? -> $OUT"