Rice cube: procedural rice material and displaced filleted cubes
Two halves, one pipeline. make_rice_texture.py models short-grain rice as randomly oriented 3D ellipsoids (surface height solved as the quadratic root, so any orientation works -- including grains standing on end), scattered by Poisson disk on a torus and unioned into a height field. Because the scatter wraps by index, the baked height/normal/AO/albedo set tiles exactly; that is proven by translating the whole scatter a quarter patch and requiring a rolled copy back (0.0 mm error), not by sampling a seam line, which turned out to be a coin flip. make_rice_cube.py displaces a filleted cube with that height map: voxel remesh for uniform vertex density, then triplanar sampling of the height field in Geometry Nodes on object-space position. Exports STL via Blender and a hand-rolled core-1.0 3MF, because this Blender build has no 3MF support and the nix store is read-only. Kept here: the procedural map set, the render of each body that was built (40 mm / 4 mm fillet, and 160 mm / 8 mm), and the A/B sheets that record why -- fusing is voxel resolution, relief ratio 0.6 beats the map's own 0.9 on a small body, and the fillet only reads once the body is large relative to the relief. Not kept: mesh binaries (560 MB, 384 MB of it one STL), the scan extract, and the baseline runs whose renders survive inside the sheets. rebuild.sh regenerates all of it, in dependency order, including the sheets.
This commit is contained in:
+74
@@ -0,0 +1,74 @@
|
||||
"""Side-by-side A/B sheet: full frame on top, zoomed crop underneath.
|
||||
|
||||
python3 compare.py --title "voxel 0.3 vs 0.2" \
|
||||
"voxel 0.3=out/preview_g5_00.png" "voxel 0.2=out_crisp/preview_g5_00.png"
|
||||
|
||||
The zoom row is the point: fusing and crease softness are invisible at full
|
||||
frame and obvious at 3x. Panes must share a camera for the crop to line up, which
|
||||
the cube renders do.
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import os
|
||||
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
|
||||
FONT = "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf"
|
||||
BOLD = "/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf"
|
||||
PANEL_W = 760
|
||||
|
||||
|
||||
def parse_pane(text):
|
||||
if "=" not in text:
|
||||
raise SystemExit(f"expected label=path, got {text!r}")
|
||||
label, path = text.split("=", 1)
|
||||
if not os.path.exists(path):
|
||||
raise SystemExit(f"missing {path}")
|
||||
return label, path
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("panes", nargs="+")
|
||||
parser.add_argument("--title", default="comparison")
|
||||
parser.add_argument("--out", default="compare.png")
|
||||
parser.add_argument("--crop", default="0.36,0.24,0.80,0.62",
|
||||
help="left,top,right,bottom as fractions")
|
||||
args = parser.parse_args()
|
||||
|
||||
panes = [parse_pane(text) for text in args.panes]
|
||||
left, top, right, bottom = (float(v) for v in args.crop.split(","))
|
||||
|
||||
full, zoom = [], []
|
||||
for _, path in panes:
|
||||
image = Image.open(path).convert("RGB")
|
||||
height = int(image.height * PANEL_W / image.width)
|
||||
full.append(image.resize((PANEL_W, height), Image.LANCZOS))
|
||||
box = (int(left * image.width), int(top * image.height),
|
||||
int(right * image.width), int(bottom * image.height))
|
||||
zoom.append(image.crop(box).resize((PANEL_W, height), Image.LANCZOS))
|
||||
|
||||
gap, header = 10, 96
|
||||
width = PANEL_W * len(panes) + gap * (len(panes) + 1)
|
||||
height = header + full[0].height * 2 + gap * 3
|
||||
sheet = Image.new("RGB", (width, height), (28, 29, 31))
|
||||
draw = ImageDraw.Draw(sheet)
|
||||
draw.text((gap, 12), args.title, font=ImageFont.truetype(BOLD, 26),
|
||||
fill=(238, 238, 238))
|
||||
draw.text((gap, 46), "top: full frame · bottom: "
|
||||
"same crop, not resampled from the other pane",
|
||||
font=ImageFont.truetype(FONT, 16), fill=(150, 152, 155))
|
||||
|
||||
label_font = ImageFont.truetype(FONT, 18)
|
||||
for index, (label, _) in enumerate(panes):
|
||||
x = gap + index * (PANEL_W + gap)
|
||||
draw.text((x + 2, 70), label, font=label_font, fill=(205, 205, 208))
|
||||
sheet.paste(full[index], (x, header))
|
||||
sheet.paste(zoom[index], (x, header + full[index].height + gap))
|
||||
|
||||
sheet.save(args.out)
|
||||
print(f"wrote {args.out} ({sheet.width}x{sheet.height})")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user