Skip to content

Commit 7493d11

Browse files
TMHSDigitalclaude
andcommitted
fix: hand-pump quality pass, cast iron instead of chrome
No geometric defect found. The iron read as chrome (metallic 1.0, roughness 0.38); it is now painted cast iron with dark rust. Per-piece wood, 60 m stage, sorted bevel input, temp glb removed. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Signed-off-by: TMHSDigital <154358121+TMHSDigital@users.noreply.github.com>
1 parent a907852 commit 7493d11

8 files changed

Lines changed: 323 additions & 31 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ Budget-conformance props. Not examples. Conventions: [`showcase/README.md`](show
126126
<a href="showcase/water-trough/"><img src="showcase/water-trough/preview.webp" width="24%" alt="Water trough: a watertight wooden trough with plank ends, contained water, and trestle legs on a dark studio floor" /></a>
127127
<a href="showcase/hitching-post/"><img src="showcase/hitching-post/preview.webp" width="24%" alt="Hitching post: a square timber post with a pyramidal cap, cross-arm, iron bands wrapped around it, and two hitching rings on a dark studio floor" /></a>
128128
<a href="showcase/grindstone/"><img src="showcase/grindstone/preview.webp" width="24%" alt="Grindstone: a stone wheel on a timber A-frame with an iron axle, hubs, crank, and tray on a dark studio floor" /></a>
129-
<a href="showcase/hand-pump/"><img src="showcase/hand-pump/preview.webp" width="24%" alt="Hand pump: a cast-iron village pump on a wooden plinth with a spout and handle on a dark studio floor" /></a>
129+
<a href="showcase/hand-pump/"><img src="showcase/hand-pump/preview.webp" width="24%" alt="Hand pump: a matte black cast-iron village pump on a stepped wooden plinth with a spout and handle on a dark studio floor" /></a>
130130
<a href="showcase/signpost/"><img src="showcase/signpost/preview.webp" width="24%" alt="Signpost: a timber post with two painted fingerboards, iron straps, and a pyramidal cap on a dark studio floor" /></a>
131131
<a href="showcase/chopping-block/"><img src="showcase/chopping-block/preview.webp" width="24%" alt="Chopping block: a bark-sided log round with growth rings and drying checks on its sawn top, a riveted iron hoop, and a felling axe buried in the top, on a dark studio floor" /></a>
132132
<a href="showcase/wooden-bucket/"><img src="showcase/wooden-bucket/preview.webp" width="24%" alt="Wooden bucket: a coopered pail with a three-strand rope bail through iron ear rings and chord-lofted iron hoops on a dark studio floor" /></a>
-528 Bytes
Loading
-406 Bytes
Loading

‎docs/gallery/hand-pump/index.html‎

Lines changed: 156 additions & 16 deletions
Large diffs are not rendered by default.

‎showcase/gallery.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@
234234
"name": "hand-pump",
235235
"dir": "showcase/hand-pump",
236236
"teaches": "A procedural village hand pump whose gooseneck is a 6-gon tube from the lower-column radius, through UVs, bake, LOD, collider, and Unity glTF, asserting recomputed budgets rather than an API contract.",
237-
"alt": "A dark iron village hand pump with a curved spout and lever handle on a square wooden plinth.",
237+
"alt": "A matte black cast-iron village hand pump with a curved spout and lever handle on a stepped wooden plinth.",
238238
"witnessesFix": "Recomputed: 1064 tris, two materials with 564 metal and 144 wood faces, UVs in 0..1 with zero AABB overlap, outer AABB 0.610×0.382×1.052 m, grounded zmin, spout-to-column gap 2.7 mm, flange-to-plinth gap 6.0 mm, column radius 62 mm, LOD ratios in band, convex collider 114 tris, hygiene all zero, non-empty glTF. --skip-decimate exits 9; --stray-vert 15; --lift-z 16; --float-spout 17; --float-flange 18; --skinny-col 19.",
239239
"hero": "docs/gallery/assets/hand-pump-hero.webp",
240240
"preview": "showcase/hand-pump/preview.webp",

‎showcase/hand-pump/README.md‎

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,23 @@ longer beveled with the plinth. Outer AABB is 0.610 × 0.382 × 1.052 m
4949
DECIMATE COLLAPSE triangle counts are **not** identical across series —
5050
5.2.1 is slightly leaner on LOD2. The gate is a ratio band, not an
5151
exact count. Bake pixels are stochastic; the gate is `has_data` plus
52-
operator `FINISHED`, not byte-identity. Construction uses no RNG.
53-
Export byte counts differ by 8 B on 5.2.1 (glTF serializer), not a
54-
gated axis.
52+
operator `FINISHED`, not byte-identity. Construction is closed-form;
53+
the only RNG is the seeded per-piece wood tone. Bevel inputs are sorted by edge index, so the face order is the same on
54+
every run; a Python set of edges handed to the bevel had made it vary.
55+
Export byte counts differ on 5.2.1 (glTF serializer), not a gated axis.
56+
57+
### Surface and stage
58+
59+
The quality pass found no geometric defect: every joint checked in the
60+
inspection sheet (spout root, flange bolts, head and handle pivot,
61+
column step, plinth) seats as the joint budgets say. The defects were
62+
on the surface. The iron was polished metal (metallic 1.0, roughness
63+
0.38) and read as chrome; it is now near-black painted cast iron with
64+
dark rust in the pores. The plinth slabs and the handle grip carry their
65+
own wood tone and grain. The stage grid grew from 14 to 60 m, because
66+
the wall's left edge showed in the corner of the hero. The temp `.glb`
67+
is removed after its size is measured. With no new geometric defect,
68+
there is no new budget.
5569

5670
### Hygiene
5771

‎showcase/hand-pump/hand_pump.py‎

Lines changed: 148 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
``--stray-vert``, ``--lift-z``, ``--float-spout``, ``--float-flange``,
1616
``--skinny-col``.
1717
18-
No RNG. Construction is closed-form. DECIMATE COLLAPSE triangle counts
18+
Construction is closed-form; the only RNG is the seeded per-piece wood
19+
tone. DECIMATE COLLAPSE triangle counts
1920
are not byte-identical across Blender versions — the LOD gate is a
2021
ratio band, not an exact count.
2122
@@ -26,6 +27,7 @@
2627
import argparse
2728
import math
2829
import os
30+
import random
2931
import sys
3032
import tempfile
3133
import traceback
@@ -87,6 +89,11 @@
8789
WOOD_IDX = 0
8890
METAL_IDX = 1
8991

92+
# Per-piece wood tone jitter and grain frequency, as in shipping-crate.
93+
PLANK_TONE_JITTER = 0.28
94+
TONE_SEED = 29
95+
WOOD_GRAIN_SCALE = 30.0
96+
9097
DOUBLES_EPS = 1e-5
9198
AREA_EPS = 1e-10
9299
ZMIN_EPS = 1e-4
@@ -397,6 +404,10 @@ def build_hand_pump_mesh(
397404
)
398405
if bevel_offset > 0.0:
399406
edges = list({e for v in wood for e in v.link_edges})
407+
# set order follows memory addresses; sort so the bevel, and the
408+
# face order it produces, are the same on every run
409+
bm.edges.index_update()
410+
edges.sort(key=lambda e: e.index)
400411
ret = bmesh.ops.bevel(
401412
bm,
402413
geom=edges,
@@ -572,6 +583,132 @@ def principled(name, color, metallic, roughness, noise_scale=0.0, wear=None):
572583
return mat
573584

574585

586+
def _long_axis(pts):
587+
"""Principal axis of a point set, by power iteration on its covariance."""
588+
c = sum(pts, Vector()) / len(pts)
589+
cov = [[0.0] * 3 for _ in range(3)]
590+
for p in pts:
591+
d = p - c
592+
for i in range(3):
593+
for j in range(3):
594+
cov[i][j] += d[i] * d[j]
595+
v = Vector((1.0, 0.3, 0.1))
596+
for _ in range(30):
597+
w = Vector([sum(cov[i][j] * v[j] for j in range(3)) for i in range(3)])
598+
if w.length < 1e-12:
599+
break
600+
v = w.normalized()
601+
return v
602+
603+
604+
def paint_planks(me):
605+
"""Per-shell ``PlankTone`` and ``GrainDir`` face attributes for the wood shader.
606+
607+
Each plinth slab and the handle grip is its own shell, so each gets
608+
one tone and grain running along its own long axis.
609+
"""
610+
tone = [0.5] * len(me.polygons)
611+
grain = [(0.0, 0.0, 1.0)] * len(me.polygons)
612+
owner = {}
613+
rng = random.Random(TONE_SEED)
614+
for g in shells(me):
615+
pts = [me.vertices[i].co.copy() for i in g]
616+
d = _long_axis(pts) if len(pts) > 2 else Vector((0.0, 0.0, 1.0))
617+
t = 0.5 + rng.uniform(-PLANK_TONE_JITTER, PLANK_TONE_JITTER)
618+
for i in g:
619+
owner[i] = (t, tuple(d))
620+
for poly in me.polygons:
621+
t, d = owner[poly.vertices[0]]
622+
tone[poly.index] = t
623+
grain[poly.index] = d
624+
a = me.attributes.new("PlankTone", "FLOAT", "FACE")
625+
a.data.foreach_set("value", tone)
626+
b = me.attributes.new("GrainDir", "FLOAT_VECTOR", "FACE")
627+
b.data.foreach_set("vector", [c for v in grain for c in v])
628+
629+
630+
def _sock(sockets, identifier):
631+
"""A Mix-node socket by identifier; its A/B/Result names repeat per type."""
632+
return next(sk for sk in sockets if sk.identifier == identifier)
633+
634+
635+
def wood_material(name):
636+
"""Grain along each slab and the grip (``GrainDir``), tone per piece (``PlankTone``)."""
637+
mat = bpy.data.materials.new(name)
638+
mat.use_nodes = True
639+
nt = mat.node_tree
640+
bsdf = nt.nodes["Principled BSDF"]
641+
coord = nt.nodes.new("ShaderNodeTexCoord")
642+
gdir = nt.nodes.new("ShaderNodeAttribute")
643+
gdir.attribute_name = "GrainDir"
644+
tone = nt.nodes.new("ShaderNodeAttribute")
645+
tone.attribute_name = "PlankTone"
646+
dot = nt.nodes.new("ShaderNodeVectorMath")
647+
dot.operation = "DOT_PRODUCT"
648+
nt.links.new(coord.outputs["Object"], dot.inputs[0])
649+
nt.links.new(gdir.outputs["Vector"], dot.inputs[1])
650+
squash = nt.nodes.new("ShaderNodeMath")
651+
squash.operation = "MULTIPLY"
652+
squash.inputs[1].default_value = 0.94
653+
nt.links.new(dot.outputs["Value"], squash.inputs[0])
654+
along = nt.nodes.new("ShaderNodeVectorMath")
655+
along.operation = "SCALE"
656+
nt.links.new(gdir.outputs["Vector"], along.inputs[0])
657+
nt.links.new(squash.outputs["Value"], along.inputs["Scale"])
658+
grain_co = nt.nodes.new("ShaderNodeVectorMath")
659+
grain_co.operation = "SUBTRACT"
660+
nt.links.new(coord.outputs["Object"], grain_co.inputs[0])
661+
nt.links.new(along.outputs["Vector"], grain_co.inputs[1])
662+
shift = nt.nodes.new("ShaderNodeVectorMath")
663+
shift.operation = "ADD"
664+
nt.links.new(grain_co.outputs["Vector"], shift.inputs[0])
665+
nt.links.new(tone.outputs["Fac"], shift.inputs[1])
666+
noise = nt.nodes.new("ShaderNodeTexNoise")
667+
noise.inputs["Scale"].default_value = WOOD_GRAIN_SCALE
668+
noise.inputs["Detail"].default_value = 6.0
669+
noise.inputs["Roughness"].default_value = 0.62
670+
nt.links.new(shift.outputs["Vector"], noise.inputs["Vector"])
671+
ramp = nt.nodes.new("ShaderNodeValToRGB")
672+
ramp.color_ramp.elements[0].position = 0.30
673+
ramp.color_ramp.elements[0].color = (0.12, 0.052, 0.018, 1.0)
674+
ramp.color_ramp.elements[1].position = 0.72
675+
ramp.color_ramp.elements[1].color = (0.38, 0.18, 0.065, 1.0)
676+
nt.links.new(noise.outputs["Fac"], ramp.inputs["Fac"])
677+
gain = nt.nodes.new("ShaderNodeMath")
678+
gain.operation = "MULTIPLY_ADD"
679+
gain.inputs[1].default_value = 1.1
680+
gain.inputs[2].default_value = 0.45
681+
nt.links.new(tone.outputs["Fac"], gain.inputs[0])
682+
mix = nt.nodes.new("ShaderNodeMix")
683+
mix.data_type = "RGBA"
684+
mix.blend_type = "MULTIPLY"
685+
_sock(mix.inputs, "Factor_Float").default_value = 1.0
686+
nt.links.new(ramp.outputs["Color"], _sock(mix.inputs, "A_Color"))
687+
nt.links.new(gain.outputs["Value"], _sock(mix.inputs, "B_Color"))
688+
nt.links.new(_sock(mix.outputs, "Result_Color"), bsdf.inputs["Base Color"])
689+
rough = nt.nodes.new("ShaderNodeMapRange")
690+
rough.inputs["To Min"].default_value = 0.72
691+
rough.inputs["To Max"].default_value = 0.52
692+
nt.links.new(noise.outputs["Fac"], rough.inputs["Value"])
693+
nt.links.new(rough.outputs["Result"], bsdf.inputs["Roughness"])
694+
return mat
695+
696+
697+
def pump_materials():
698+
"""(wood, iron): shared by the check, the render and inspection.
699+
700+
A cast-iron pump is painted near-black and weathers to rust at the
701+
edges and pores; the first build was polished metal (metallic 1.0,
702+
roughness 0.38) and read as chrome.
703+
"""
704+
wood = wood_material("HandPumpWood")
705+
metal = principled(
706+
"HandPumpIron", (0.045, 0.047, 0.050, 1.0), 0.55, 0.52,
707+
noise_scale=24.0, wear=(0.09, 0.05, 0.03, 1.0),
708+
)
709+
return wood, metal
710+
711+
575712
def assign_slots(obj, wood, metal):
576713
mats = obj.data.materials
577714
wanted = (wood, metal)
@@ -902,14 +1039,9 @@ def check(
9021039
)
9031040
low = build_hand_pump_mesh("HandPumpLow", bevel_offset=0.004, bevel_segments=2, **kw)
9041041
high = build_hand_pump_mesh("HandPumpHigh", bevel_offset=0.004, bevel_segments=4, **kw)
905-
wood = principled(
906-
"HandPumpWood", (0.36, 0.19, 0.07, 1.0), 0.0, 0.60,
907-
noise_scale=14.0, wear=(0.22, 0.12, 0.05, 1.0),
908-
)
909-
metal = principled(
910-
"HandPumpIron", (0.18, 0.175, 0.17, 1.0), 1.0, 0.38,
911-
noise_scale=18.0, wear=(0.28, 0.24, 0.18, 1.0),
912-
)
1042+
wood, metal = pump_materials()
1043+
paint_planks(low.data)
1044+
paint_planks(high.data)
9131045
assign_slots(low, wood, metal)
9141046
assign_slots(high, wood, metal)
9151047

@@ -965,6 +1097,10 @@ def check(
9651097
os.remove(export_path)
9661098
export_unity(export_path, [low, collider])
9671099
export_size = os.path.getsize(export_path) if os.path.isfile(export_path) else 0
1100+
# Blender points TMPDIR at the working directory, so the export must not
1101+
# outlive the measurement.
1102+
if os.path.exists(export_path):
1103+
os.remove(export_path)
9681104

9691105
hyg = hygiene_audit(low.data)
9701106
zf = zfight_pairs(low.data)
@@ -1120,7 +1256,9 @@ def render_still(low, wood, tex, path, engine):
11201256
floor_me = bpy.data.meshes.new("Floor")
11211257
bm = bmesh.new()
11221258
try:
1123-
bmesh.ops.create_grid(bm, x_segments=1, y_segments=1, size=14.0)
1259+
# Oversized so no edge of the set can enter frame; at 14 m the wall's
1260+
# left edge showed as a bright band in the corner of the hero.
1261+
bmesh.ops.create_grid(bm, x_segments=1, y_segments=1, size=60.0)
11241262
bm.to_mesh(floor_me)
11251263
finally:
11261264
bm.free()

‎showcase/hand-pump/preview.webp‎

-488 Bytes
Loading

0 commit comments

Comments
 (0)