Datasets:
Upload scripts/lane32_morph.py with huggingface_hub
Browse files- scripts/lane32_morph.py +106 -0
scripts/lane32_morph.py
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Lane 32: Morph-Bench — benchmark methodology lane.
|
| 2 |
+
Key visual: radar/spider chart with 3 overlaid polygons (baseline comparisons).
|
| 3 |
+
"""
|
| 4 |
+
import sys, os
|
| 5 |
+
sys.path.insert(0, os.path.dirname(__file__))
|
| 6 |
+
from render_protocol import (
|
| 7 |
+
clean_scene, setup_world, render_2x, W2X, H2X, WIRE_COLOR,
|
| 8 |
+
)
|
| 9 |
+
import bpy, math, random
|
| 10 |
+
|
| 11 |
+
OUT_2X = "/Users/Zer0pa/ZPE/ZPE-Animation-Workspace/blender-proto/lane32_morph_2x.png"
|
| 12 |
+
OUT_FINAL = "/Users/Zer0pa/ZPE/ZPE-Animation-Workspace/final-572x534/key-visuals/lane32_Morph-Bench.png"
|
| 13 |
+
|
| 14 |
+
scene = clean_scene()
|
| 15 |
+
random.seed(20098)
|
| 16 |
+
|
| 17 |
+
AXES = 7 # 7 benchmark dimensions
|
| 18 |
+
R_MAX = 1.2
|
| 19 |
+
|
| 20 |
+
def curve_from(name, pts, cyclic=False, depth=0.012):
|
| 21 |
+
cd = bpy.data.curves.new(name, type='CURVE'); cd.dimensions = '3D'
|
| 22 |
+
sp = cd.splines.new('POLY')
|
| 23 |
+
if cyclic: sp.use_cyclic_u = True
|
| 24 |
+
sp.points.add(len(pts) - 1)
|
| 25 |
+
for i, p in enumerate(pts):
|
| 26 |
+
sp.points[i].co = (*p, 1.0)
|
| 27 |
+
cd.bevel_depth = depth
|
| 28 |
+
obj = bpy.data.objects.new(name, cd); scene.collection.objects.link(obj)
|
| 29 |
+
return obj
|
| 30 |
+
|
| 31 |
+
# Radial axes (light)
|
| 32 |
+
axes_list = []
|
| 33 |
+
for i in range(AXES):
|
| 34 |
+
a = i * 2 * math.pi / AXES + math.pi / 2
|
| 35 |
+
x = R_MAX * math.cos(a); z = R_MAX * math.sin(a)
|
| 36 |
+
ax = curve_from(f"Axis_{i}", [(0, 0, 0), (x, 0, z)], cyclic=False, depth=0.004)
|
| 37 |
+
axes_list.append(ax)
|
| 38 |
+
|
| 39 |
+
# Reference rings at 1/3, 2/3, full
|
| 40 |
+
ring_radii = [R_MAX * r for r in (0.33, 0.66, 1.0)]
|
| 41 |
+
rings = []
|
| 42 |
+
for j, r in enumerate(ring_radii):
|
| 43 |
+
pts = []
|
| 44 |
+
for i in range(60):
|
| 45 |
+
a = i * 2 * math.pi / 60 + math.pi / 2
|
| 46 |
+
pts.append((r * math.cos(a), 0, r * math.sin(a)))
|
| 47 |
+
rings.append(curve_from(f"Ring_{j}", pts, cyclic=True, depth=0.004))
|
| 48 |
+
|
| 49 |
+
# 3 overlaid polygons (benchmark scores) — each a closed curve with random radii per axis
|
| 50 |
+
scores_set = [
|
| 51 |
+
[random.uniform(0.30, 0.95) for _ in range(AXES)],
|
| 52 |
+
[random.uniform(0.45, 0.85) for _ in range(AXES)],
|
| 53 |
+
[random.uniform(0.55, 0.78) for _ in range(AXES)],
|
| 54 |
+
]
|
| 55 |
+
polygons = []
|
| 56 |
+
for k, scores in enumerate(scores_set):
|
| 57 |
+
pts = []
|
| 58 |
+
for i, s in enumerate(scores):
|
| 59 |
+
a = i * 2 * math.pi / AXES + math.pi / 2
|
| 60 |
+
r = s * R_MAX
|
| 61 |
+
pts.append((r * math.cos(a), 0, r * math.sin(a)))
|
| 62 |
+
polygons.append(curve_from(f"Poly_{k}", pts, cyclic=True, depth=0.014))
|
| 63 |
+
|
| 64 |
+
# Materials
|
| 65 |
+
mat_light = bpy.data.materials.new("Light"); mat_light.use_nodes = True
|
| 66 |
+
nt = mat_light.node_tree
|
| 67 |
+
for n in list(nt.nodes): nt.nodes.remove(n)
|
| 68 |
+
out = nt.nodes.new("ShaderNodeOutputMaterial")
|
| 69 |
+
emi = nt.nodes.new("ShaderNodeEmission")
|
| 70 |
+
emi.inputs["Color"].default_value = (0.22, 0.22, 0.24, 1.0)
|
| 71 |
+
emi.inputs["Strength"].default_value = 1.0
|
| 72 |
+
nt.links.new(emi.outputs[0], out.inputs[0])
|
| 73 |
+
|
| 74 |
+
mat_bright = bpy.data.materials.new("Bright"); mat_bright.use_nodes = True
|
| 75 |
+
nt = mat_bright.node_tree
|
| 76 |
+
for n in list(nt.nodes): nt.nodes.remove(n)
|
| 77 |
+
out = nt.nodes.new("ShaderNodeOutputMaterial")
|
| 78 |
+
emi = nt.nodes.new("ShaderNodeEmission")
|
| 79 |
+
emi.inputs["Color"].default_value = WIRE_COLOR
|
| 80 |
+
emi.inputs["Strength"].default_value = 3.0
|
| 81 |
+
nt.links.new(emi.outputs[0], out.inputs[0])
|
| 82 |
+
|
| 83 |
+
# Apply: axes + rings = light, polygons = bright
|
| 84 |
+
for obj in axes_list + rings:
|
| 85 |
+
obj.data.materials.append(mat_light)
|
| 86 |
+
for obj in polygons:
|
| 87 |
+
obj.data.materials.append(mat_bright)
|
| 88 |
+
|
| 89 |
+
setup_world()
|
| 90 |
+
|
| 91 |
+
target = bpy.data.objects.new("Target", None); target.location = (0, 0, 0)
|
| 92 |
+
scene.collection.objects.link(target)
|
| 93 |
+
cam_data = bpy.data.cameras.new("Cam"); cam_data.lens = 50
|
| 94 |
+
cam_data.clip_start = 0.001
|
| 95 |
+
cam = bpy.data.objects.new("Cam", cam_data); scene.collection.objects.link(cam)
|
| 96 |
+
|
| 97 |
+
half_fov = math.atan((36/2) / 50)
|
| 98 |
+
dist = R_MAX / math.tan(half_fov) * 1.18
|
| 99 |
+
cam.location = (0, -dist, 0)
|
| 100 |
+
trk = cam.constraints.new('TRACK_TO')
|
| 101 |
+
trk.target = target; trk.track_axis = 'TRACK_NEGATIVE_Z'; trk.up_axis = 'UP_Y'
|
| 102 |
+
scene.camera = cam
|
| 103 |
+
|
| 104 |
+
print(f"[lane32] rendering → {OUT_2X}")
|
| 105 |
+
render_2x(OUT_2X)
|
| 106 |
+
print(f"[lane32] done")
|