Skip to content

Commit dc04ef3

Browse files
TMHSDigitalclaude
andcommitted
fix(examples): redesign swatch-grid as a labelled sample case on a walnut riser
The six material spheres stood on six loose graphite plinths. They now sit in their gunmetal collars on a two-tier walnut riser (object-space wave-texture grain), with an engraved brass plaque leaning in front of each collar that names its material (LABELS: GOLD, COPPER, RED PLASTIC, BLUE PLASTIC, EMISSIVE, WHITE ROUGH) as an extruded text object. The tier heights are the old plinth heights, so every sphere keeps its position and the pixel check still samples the same projected sphere centres. Materials, the engine-id witness, the distinct-colour check and verify_png are unchanged. Evidence (live runs, local): - .scratch/blender-5.2.1-windows-x64/blender.exe (Blender 5.2.1 LTS): check-only exit 0 (eevee_engine_id=BLENDER_EEVEE accepted, BLENDER_EEVEE_NEXT rejected; set_specular -> Specular IOR Level). --same-base exits 3 ("distinct swatch colors 1 != 6"). --output: framing fill x=0.806 y=0.800, margins l/r 0.097 b 0.028 t 0.172; verify distinct_regions=6, closest pair 0.246. - .scratch/blender-4.5.11-windows-x64/blender.exe (Blender 4.5.11 LTS): --output exits 0 (BLENDER_EEVEE_NEXT accepted), framing_ok, verify distinct_regions=6. - Contact sheet: candidate luma 0.271 / stage 0.155 / warmth +0.285 / sat 0.295, against armature-bend 0.243/0.192/-0.144/0.237, damped-track-aim 0.237/0.218/+0.105/0.178 and bmesh-gear 0.237/0.252/+0.092/0.153 -- darkest stage and warmest pool in the set. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent ecb452c commit dc04ef3

7 files changed

Lines changed: 104 additions & 13 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ or expand a category below.
238238
<table>
239239
<tr>
240240
<td width="46%" valign="middle">
241-
<a href="examples/swatch-grid/"><img src="examples/swatch-grid/preview.webp" alt="Swatch grid: a tiered material library in a dark studio - six spheres seated in chrome collars on graphite plinths, mirror gold, brushed copper and red plastic on tall plinths behind blue plastic, a glowing orange emissive globe and matte white in front, rendered with EEVEE" /></a>
241+
<a href="examples/swatch-grid/"><img src="examples/swatch-grid/preview.webp" alt="Swatch grid: six material spheres on a two-tier walnut riser, each labelled by an engraved brass plaque — mirror gold, copper and red plastic behind; blue plastic, a glowing emissive globe and white rough in front" /></a>
242242
</td>
243243
<td valign="middle">
244244

7.33 KB
Loading
4.75 KB
Loading

‎examples/gallery.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"name": "swatch-grid",
1010
"dir": "examples/swatch-grid",
1111
"teaches": "Procedural Principled materials — metal and dielectric, the emission pattern, and the cross-version set_specular shim.",
12-
"alt": "Six material spheres on graphite plinths in two tiers: mirror gold, brushed copper and red behind; blue, a glowing orange emissive globe and matte white in front.",
12+
"alt": "Six material spheres in gunmetal collars on a two-tier walnut riser, each over an engraved brass plaque: gold, copper, red plastic behind; blue plastic, emissive, white rough in front.",
1313
"witnessesFix": "EEVEE engine-id mapping: BLENDER_EEVEE on 5.x, BLENDER_EEVEE_NEXT on 4.2–4.5.",
1414
"hero": "docs/gallery/assets/swatch-grid-hero.webp",
1515
"preview": "examples/swatch-grid/preview.webp",

‎examples/swatch-grid/README.md‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Swatch Grid
22

33
A runnable example that renders a tiered 3×2 material library — one sphere per material, each
4-
seated in a chrome collar on a graphite plinth — to a single PNG. It demonstrates the [`procedural-materials-and-shaders`](../../skills/procedural-materials-and-shaders/SKILL.md)
4+
seated in a gunmetal collar on a two-tier walnut riser behind an engraved brass name plaque — to a single PNG. It demonstrates the [`procedural-materials-and-shaders`](../../skills/procedural-materials-and-shaders/SKILL.md)
55
patterns end to end:
66

77
- **Principled BSDF** metals (gold, copper: high metallic, low roughness) and dielectrics
@@ -39,9 +39,13 @@ blender --background --python swatch_grid.py -- --output swatch.png --engine cyc
3939

4040
The swatches stand as a tiered material library on the default stage (floor,
4141
wall at y = 9, warm key, cool fill and rim, warm wedge pooling on the floor
42-
behind the display). Each sphere sits in a gunmetal collar on a bevelled
43-
graphite plinth; the back row stands on tall plinths so every sphere clears
44-
the one in front of it. A 50 mm camera looks down on the display with a
42+
behind the display). Each sphere sits in a gunmetal collar on a two-tier
43+
walnut riser (oiled-grain wave texture in object space); the back tier stands
44+
taller so every sphere clears the one in front of it. A brass plaque leans in
45+
front of each collar with the material's name set into it as an extruded
46+
text object (`LABELS`, in grid order), so the display reads as a labelled
47+
sample case. The plaques sit below the sphere centres the pixel check
48+
samples, so `verify_png` is unaffected. A 50 mm camera looks down on the display with a
4549
`TRACK_TO` aim, which keeps the floor/wall seam above the back row.
4650

4751
The emissive swatch used to be a bare `Emission` at strength 1.4: under the

‎examples/swatch-grid/preview.webp‎

6.5 KB
Loading

‎examples/swatch-grid/swatch_grid.py‎

Lines changed: 94 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,19 +165,106 @@ def make_cylinder(name, radius, height, bevel, segments=64):
165165
return me
166166

167167

168+
LABELS = ("GOLD", "COPPER", "RED PLASTIC", "BLUE PLASTIC", "EMISSIVE", "WHITE ROUGH")
169+
TIER_DEPTH = 1.30 # front-to-back depth of each riser tier
170+
TIER_HALF_W = 2.28 # half-width of the riser, past the outer spheres
171+
172+
173+
def make_block(name, sx, sy, sz, bevel):
174+
"""A bevelled box standing on z=0, centred on x/y."""
175+
me = bpy.data.meshes.new(name)
176+
bm = bmesh.new()
177+
try:
178+
bmesh.ops.create_cube(bm, size=1.0)
179+
for v in bm.verts:
180+
v.co.x *= sx
181+
v.co.y *= sy
182+
v.co.z = (v.co.z + 0.5) * sz
183+
bmesh.ops.bevel(bm, geom=list(bm.edges), offset=bevel, segments=3, profile=0.5,
184+
affect='EDGES', clamp_overlap=True)
185+
bm.to_mesh(me)
186+
finally:
187+
bm.free()
188+
for p in me.polygons:
189+
p.use_smooth = True
190+
me.set_sharp_from_angle(angle=math.radians(40.0))
191+
return me
192+
193+
194+
def make_walnut():
195+
"""Oiled walnut: a stretched wave-texture grain over a noise-warped base."""
196+
mat = bpy.data.materials.new("Walnut")
197+
mat.use_nodes = True
198+
nt = mat.node_tree
199+
b = nt.nodes["Principled BSDF"]
200+
b.inputs["Roughness"].default_value = 0.42
201+
coord = nt.nodes.new("ShaderNodeTexCoord")
202+
mapping = nt.nodes.new("ShaderNodeMapping")
203+
mapping.inputs["Scale"].default_value = (0.25, 1.0, 1.0) # stretched: grain runs along X
204+
nt.links.new(coord.outputs["Object"], mapping.inputs["Vector"])
205+
wave = nt.nodes.new("ShaderNodeTexWave")
206+
wave.inputs["Scale"].default_value = 3.0
207+
wave.bands_direction = 'Z'
208+
wave.inputs["Distortion"].default_value = 1.6
209+
wave.inputs["Detail"].default_value = 4.0
210+
nt.links.new(mapping.outputs["Vector"], wave.inputs["Vector"])
211+
ramp = nt.nodes.new("ShaderNodeValToRGB")
212+
ramp.color_ramp.elements[0].color = (0.075, 0.037, 0.018, 1)
213+
ramp.color_ramp.elements[1].color = (0.13, 0.068, 0.034, 1)
214+
nt.links.new(wave.outputs["Fac"], ramp.inputs["Fac"])
215+
nt.links.new(ramp.outputs["Color"], b.inputs["Base Color"])
216+
return mat
217+
218+
219+
def make_plaque(name, text, loc, brass, ink):
220+
"""A brass plaque tilted toward the camera with the material's name set
221+
into it: a bevelled plate plus an extruded text object riding its face."""
222+
import mathutils
223+
tilt = math.radians(58.0) # plate leans back, face up-and-forward
224+
plate = bpy.data.objects.new(name, make_block(name, 0.86, 0.20, 0.022, 0.006))
225+
plate.location = loc
226+
plate.rotation_euler = (tilt, 0.0, 0.0)
227+
plate.data.materials.append(brass)
228+
cu = bpy.data.curves.new(name + "Text", type='FONT')
229+
cu.body = text
230+
cu.size = 0.085
231+
cu.align_x = 'CENTER'
232+
cu.align_y = 'CENTER'
233+
cu.extrude = 0.0025
234+
cu.space_character = 1.12
235+
txt = bpy.data.objects.new(name + "Text", cu)
236+
txt.data.materials.append(ink)
237+
# ride the plate's top face: parent, then sit just proud of it
238+
txt.parent = plate
239+
txt.location = (0.0, 0.0, 0.0245)
240+
return plate, txt
241+
242+
168243
def build_scene(mats):
169244
sc = bpy.context.scene
170245
coll = bpy.context.collection
171-
plinth_mat, _ = make_principled("PlinthGraphite", (0.055, 0.056, 0.062, 1), 0.0, 0.42,
172-
specular=0.5)
246+
walnut = make_walnut()
173247
collar_mat, _ = make_principled("CollarGunmetal", (0.30, 0.30, 0.32, 1), 1.0, 0.32)
248+
brass, _ = make_principled("PlaqueBrass", (0.80, 0.58, 0.28, 1), 1.0, 0.30)
249+
ink, _ = make_principled("PlaqueInk", (0.02, 0.018, 0.016, 1), 0.0, 0.6)
174250
swatches, stands = [], []
251+
# a two-tier walnut riser: each row of spheres stands on its own tier, so
252+
# the back row clears the front one (tier tops at the old plinth heights)
253+
for r, (y, h) in enumerate(ROWS):
254+
tier = bpy.data.objects.new(f"Tier{r}", make_block(f"Tier{r}", 2 * TIER_HALF_W,
255+
TIER_DEPTH, h, 0.03))
256+
tier.location = (0.0, y + (0.12 if r == 0 else 0.0), 0.0)
257+
tier.data.materials.append(walnut)
258+
coll.objects.link(tier)
259+
stands.append(tier)
175260
i = 0
176261
for r, (y, h) in enumerate(ROWS):
177262
for c, x in enumerate(COL_X):
178-
plinth = bpy.data.objects.new(f"Plinth{i}", make_cylinder(f"Plinth{i}", 0.44, h, 0.035))
179-
plinth.location = (x, y, 0.0)
180-
plinth.data.materials.append(plinth_mat)
263+
plaque, txt = make_plaque(f"Plaque{i}", LABELS[i],
264+
(x, y - 0.52, h + 0.06), brass, ink)
265+
coll.objects.link(plaque)
266+
coll.objects.link(txt)
267+
stands += [plaque, txt]
181268
collar = bpy.data.objects.new(f"Collar{i}", make_cylinder(f"Collar{i}", 0.30, 0.07, 0.02))
182269
collar.location = (x, y, h)
183270
collar.data.materials.append(collar_mat)
@@ -196,10 +283,10 @@ def build_scene(mats):
196283
seat = h + 0.07 + math.sqrt(SPHERE_R ** 2 - 0.26 ** 2)
197284
ob.location = (x, y, seat)
198285
ob.data.materials.append(mats[i])
199-
for o in (plinth, collar, ob):
286+
for o in (collar, ob):
200287
coll.objects.link(o)
201288
swatches.append(ob)
202-
stands += [plinth, collar]
289+
stands.append(collar)
203290
i += 1
204291

205292
# default stage: floor + back wall share the studio material

0 commit comments

Comments
 (0)