```python
import bpy, math, random, os
from mathutils import Vector
from math import sin, cos, pi

random.seed(23)
bpy.ops.object.select_all(action='SELECT')
bpy.ops.object.delete(use_global=False)

# Materials
def material(name, color, metallic=0, roughness=.45):
    m = bpy.data.materials.new(name)
    m.diffuse_color = (*color, 1)
    m.use_nodes = True
    p = m.node_tree.nodes.get('Principled BSDF')
    p.inputs['Base Color'].default_value = (*color, 1)
    p.inputs['Metallic'].default_value = metallic
    p.inputs['Roughness'].default_value = roughness
    return m

def aged(name, c1, c2, metallic=0, roughness=.4, scale=5, bump=.035):
    m = material(name, c1, metallic, roughness)
    n, l = m.node_tree.nodes, m.node_tree.links
    p = n.get('Principled BSDF')
    tex = n.new('ShaderNodeTexNoise')
    tex.inputs['Scale'].default_value = scale
    tex.inputs['Detail'].default_value = 4
    ramp = n.new('ShaderNodeValToRGB')
    ramp.color_ramp.elements[0].position = .22
    ramp.color_ramp.elements[0].color = (*c1, 1)
    ramp.color_ramp.elements[1].position = .8
    ramp.color_ramp.elements[1].color = (*c2, 1)
    l.new(tex.outputs['Fac'], ramp.inputs[0])
    l.new(ramp.outputs[0], p.inputs['Base Color'])
    fine = n.new('ShaderNodeTexNoise')
    fine.inputs['Scale'].default_value = scale * 24
    fine.inputs['Detail'].default_value = 2
    b = n.new('ShaderNodeBump')
    b.inputs['Strength'].default_value = .22
    b.inputs['Distance'].default_value = bump
    l.new(fine.outputs['Fac'], b.inputs['Height'])
    l.new(b.outputs[0], p.inputs['Normal'])
    return m

ivory = aged('Warm tin glaze • softly crazed porcelain', (.57,.59,.49), (.9,.86,.69), .05,.21,5,.009)
p = ivory.node_tree.nodes.get('Principled BSDF')
p.inputs['Coat Weight'].default_value = .38
p.inputs['Coat Roughness'].default_value = .15
cobalt = aged('Cobalt underglaze', (.008,.026,.057), (.026,.08,.14), .15,.24,12,.005)
gold = aged('Rubbed parcel gilt', (.24,.115,.031), (.65,.40,.12), .8,.29,8,.016)
bronze = aged('Suzanne • excavated bronze and verdigris', (.043,.064,.048), (.28,.145,.057), .77,.34,5,.026)
stone = aged('Bunny • old ivory limestone', (.43,.36,.24), (.77,.69,.50), 0,.49,4,.018)
eye_mat = material('Shadow within carved eyes', (.085,.059,.027),0,.57)
blackstone = aged('Pedestal • charcoal marble', (.019,.023,.022), (.085,.094,.084), .12,.31,3,.008)
paper = aged('Foxed laid paper', (.40,.28,.13), (.76,.64,.39),0,.78,9,.012)
leather = aged('Oxblood calfskin', (.035,.007,.005), (.13,.028,.014),0,.47,7,.018)
red = aged('Cornell red • garnet velvet', (.075,.003,.009), (.30,.013,.026),0,.84,5,.008)
green = aged('Cornell green • malachite velvet', (.006,.035,.018), (.026,.16,.063),0,.82,5,.008)
linen = aged('Unbleached damask', (.37,.32,.24), (.66,.60,.46),0,.82,8,.008)
for m in [red, green, linen]:
    m.node_tree.nodes.get('Principled BSDF').inputs['Sheen Weight'].default_value = .32
wood = aged('Old walnut, lengthwise grain', (.029,.012,.006), (.14,.061,.020),0,.4,4,.028)
n,l = wood.node_tree.nodes,wood.node_tree.links
tc=n.new('ShaderNodeTexCoord')
mapping=n.new('ShaderNodeVectorMath'); mapping.operation='MULTIPLY'
mapping.inputs[1].default_value=(2,65,9)
l.new(tc.outputs['Generated'],mapping.inputs[0])
for node in list(n):
    if node.type=='TEX_NOISE':
        l.new(mapping.outputs[0],node.inputs['Vector'])
backmat = aged('Umber darkness', (.009,.007,.005), (.029,.026,.017),0,.95,3,.035)
chrome = material('Silver squares • polished speculum', (.77,.80,.78),1,.105)
darkchrome = material('Black squares • polished speculum', (.055,.070,.072),1,.14)

def mesh_obj(name, verts, faces, mat=None):
    me=bpy.data.meshes.new(name)
    me.from_pydata(verts,[],faces); me.update()
    ob=bpy.data.objects.new(name,me); bpy.context.collection.objects.link(ob)
    if mat: me.materials.append(mat)
    return ob

def smooth(ob):
    if ob.type=='MESH':
        for p in ob.data.polygons: p.use_smooth=True
    return ob

def bevel(ob, amount=.04, segments=3):
    mod=ob.modifiers.new('Softened edges', 'BEVEL')
    mod.width=amount; mod.segments=segments
    return ob

def cube(name, loc, scale, mat, b=.02):
    bpy.ops.mesh.primitive_cube_add(size=1,location=loc)
    ob=bpy.context.object; ob.name=name
    ob.dimensions=scale
    bpy.ops.object.transform_apply(location=False,rotation=False,scale=True)
    ob.data.materials.append(mat)
    if b: bevel(ob,b)
    return ob

def ellipsoid(name,loc,scale,mat,rot=None):
    bpy.ops.mesh.primitive_uv_sphere_add(segments=48,ring_count=32,location=loc)
    ob=bpy.context.object; ob.name=name; ob.scale=scale
    if rot: ob.rotation_euler=rot
    if mat: ob.data.materials.append(mat)
    smooth(ob)
    return ob

def catmull(points,steps=10):
    p=[Vector(v) for v in points]; out=[]
    for i in range(len(p)-1):
        a=p[max(0,i-1)]; b=p[i]; c=p[i+1]; d=p[min(len(p)-1,i+2)]
        for j in range(steps):
            t=j/steps
            out.append(.5*((2*b)+(-a+c)*t+(2*a-5*b+4*c-d)*t*t+(-a+3*b-3*c+d)*t*t*t))
    out.append(p[-1])
    return out

def lathe(name,profile,mat,origin=(0,0,0),segments=128,interp=5):
    pro=catmull([(r,z,0) for r,z in profile],interp) if interp else [Vector((r,z,0)) for r,z in profile]
    vs=[]; fs=[]
    for p in pro:
        for j in range(segments):
            a=j*2*pi/segments
            vs.append((origin[0]+max(.001,p.x)*cos(a),origin[1]+max(.001,p.x)*sin(a),origin[2]+p.y))
    for i in range(len(pro)-1):
        for j in range(segments):
            a=i*segments+j; b=i*segments+(j+1)%segments
            fs.append((a,b,b+segments,a+segments))
    fs.append(tuple(reversed(range(segments))))
    fs.append(tuple((len(pro)-1)*segments+j for j in range(segments)))
    return smooth(mesh_obj(name,vs,fs,mat))

def tube(name,controls,radii,mat,origin=(0,0,0),sides=24,steps=12,hollow=False):
    pp=catmull([(*v,r) for v,r in zip(controls,radii)],steps)
    vs=[]; fs=[]; count=len(pp)
    frames=[]
    for i,p in enumerate(pp):
        tangent=(Vector(pp[min(i+1,count-1)][:3])-Vector(pp[max(0,i-1)][:3])).normalized()
        ref=Vector((0,1,0))
        if abs(tangent.dot(ref))>.95: ref=Vector((1,0,0))
        u=tangent.cross(ref).normalized(); v=tangent.cross(u).normalized()
        frames.append((u,v))
    layers=2 if hollow else 1
    for layer in range(layers):
        for i,p in enumerate(pp):
            u,v=frames[i]
            r=max(.006,p[3]-(.055 if layer else 0))
            for j in range(sides):
                vv=Vector(p[:3])+Vector(origin)+r*(u*cos(2*pi*j/sides)+v*sin(2*pi*j/sides))
                vs.append(vv)
    for layer in range(layers):
        off=layer*count*sides
        for i in range(count-1):
            for j in range(sides):
                a=off+i*sides+j;b=off+i*sides+(j+1)%sides
                face=(a,b,b+sides,a+sides)
                fs.append(tuple(reversed(face)) if layer else face)
    if hollow:
        for j in range(sides):
            a=(count-1)*sides+j;b=(count-1)*sides+(j+1)%sides
            fs.append((a,b,b+count*sides,a+count*sides))
    else:
        fs.append(tuple(reversed(range(sides))))
        fs.append(tuple((count-1)*sides+j for j in range(sides)))
    return smooth(mesh_obj(name,vs,fs,mat))

def torus(name,loc,major,minor,mat):
    bpy.ops.mesh.primitive_torus_add(major_radius=major,minor_radius=minor,major_segments=128,minor_segments=12,location=loc)
    ob=bpy.context.object; ob.name=name; ob.data.materials.append(mat);smooth(ob)
    return ob

# The old table: its front rail remains exposed below the textiles.
cube('Single broad walnut table top',(0,0,-.17),(9.1,4.6,.34),wood,.065)
cube('Front apron',(0,-2.13,-.55),(8.75,.15,.64),wood,.04)
cube('Front moulding',(0,-2.24,-.35),(8.94,.075,.10),wood,.023)
for x in [-3.9,3.9]:
    for y in [-1.75,1.75]:
        lathe('Turned walnut table leg',[(.15,-2.8),(.19,-2.65),(.14,-2.35),(.12,-1.4),(.23,-1.12),(.19,-.83),(.20,-.35)],wood,(x,y,0),64,5)
cube('Dark floor',(0,0,-2.94),(200,200,.2),backmat,.0)
cube('Unlit plaster background',(0,4.9,3.5),(30,.25,15),backmat,.0)

# Geometric woven cloth, with folds modeled rather than shaded on.
def table_cloth(name,center,width,length,mat,zbase,phase=0):
    nx,ny=70,112
    vs=[];fs=[]
    for j in range(ny+1):
        v=j/ny
        if v<.73:
            q=v/.73
            y=2.05-4.34*q
            z=zbase
        else:
            q=(v-.73)/.27
            y=-2.29-.13*sin(q*pi*.7)
            z=zbase-length*q
        for i in range(nx+1):
            u=i/nx
            x=center+(u-.5)*width+.095*sin(v*7+phase)*sin(pi*u)
            fold=sin(u*11*pi+v*2.4+phase)+.33*sin(u*23*pi-v*4)
            amp=.026 if v<.7 else .067
            zz=z+amp*fold+.016*sin(v*24+u*9)
            if v<.73:
                zz+=.04*(abs(2*u-1)**8)*sin(v*10+phase)**2
            else:
                y+=.055*fold*q
                zz+=.09*sin(u*8*pi+phase)*(q**5)
            vs.append((x,y,zz))
    for j in range(ny):
        for i in range(nx):
            a=j*(nx+1)+i
            fs.append((a,a+1,a+nx+2,a+nx+1))
    ob=smooth(mesh_obj(name,vs,fs,mat))
    sub=ob.modifiers.new('Supple folds','SUBSURF');sub.levels=1
    sol=ob.modifiers.new('Woven edge','SOLIDIFY');sol.thickness=.014
    return ob

table_cloth('Heavy crimson drape, left',-3.05,2.70,1.95,red,.065,1.4)
table_cloth('Ivory linen cascading over the edge',-.25,4.55,1.17,linen,.12,.1)

# A green hanging textile opposite the red one, pooling on the far right.
vs=[];fs=[];nx=64;ny=110
for j in range(ny+1):
    t=j/ny
    if t<.58:
        q=t/.58
        y=2.22-.15*q
        z=4.5*(1-q)+.11
    elif t<.9:
        q=(t-.58)/.32
        y=2.07-4.35*q; z=.11
    else:
        q=(t-.9)/.1
        y=-2.28-.1*sin(q*pi*.6);z=.11-q*1.6
    for i in range(nx+1):
        u=i/nx
        fold=sin(u*9*pi+.4*sin(t*6))+.32*sin(u*19*pi+t*4)
        x=3.63+(u-.5)*1.83+.06*sin(t*8)
        yy=y+(.11*fold if t<.58 else .035*fold)
        zz=z+(.035*fold if t>=.58 else .06*sin(u*7))
        vs.append((x,yy,zz))
for j in range(ny):
    for i in range(nx):
        a=j*(nx+1)+i;fs.append((a,a+1,a+nx+2,a+nx+1))
ob=smooth(mesh_obj('Green velvet, opposing wing',vs,fs,green))
sub=ob.modifiers.new('Soft cloth','SUBSURF');sub.levels=1
sol=ob.modifiers.new('Velvet thickness','SOLIDIFY');sol.thickness=.016

# UTAH: a true surface-of-revolution vessel with hollow rising spout.
T=(-.48,-.42,.19)
lathe('Utah teapot • generous squat belly',
      [(.02,.04),(.64,.04),(.72,.10),(.76,.20),(.96,.35),(1.095,.61),
       (1.14,.88),(1.10,1.15),(.99,1.39),(.83,1.57),(.80,1.61)],
      ivory,T)
lathe('Low porcelain foot',[(.61,.02),(.70,.035),(.73,.10),(.70,.16)],ivory,T)
lathe('Cobalt foot band',[(.712,.064),(.732,.083),(.73,.11)],cobalt,T,128,3)
lathe('Rolled shoulder lip',[(.78,1.54),(.835,1.57),(.85,1.615),(.80,1.65),(.77,1.64)],ivory,T)
lathe('Cobalt rim',[(.842,1.587),(.851,1.609),(.833,1.629)],cobalt,T,128,3)
lathe('Utah domed lid',[(.025,1.895),(.22,1.86),(.46,1.78),(.65,1.697),(.81,1.65),(.82,1.626)],ivory,T)
torus('Fine gilded lid edge',(T[0],T[1],T[2]+1.65),.791,.012,gold)
lathe('Lid knob',[(.10,1.84),(.105,1.93),(.18,1.98),(.195,2.06),(.145,2.13),(.025,2.145)],ivory,T,96,7)
torus('Cobalt knob collar',(T[0],T[1],T[2]+1.93),.105,.017,cobalt)
sp=[(-.94,0,.61),(-1.27,0,.79),(-1.51,0,1.17),(-1.70,0,1.53),(-2.05,0,1.73)]
tube('Utah swept hollow spout',sp,[.35,.29,.205,.145,.19],ivory,T,48,16,True)
tube('Cobalt lip on spout',[(-2.004,0,1.711),(-2.05,0,1.73)],[.181,.195],cobalt,T,48,8,True)
tube('Utah high loop handle',
     [(.89,0,1.39),(1.37,0,1.55),(1.78,0,1.40),(1.85,0,.94),(1.51,0,.49),(.96,0,.43)],
     [.145,.13,.13,.14,.14,.18],ivory,T,32,15)
for z,r in [(.235,.80),(.29,.87),(1.455,.943)]:
    torus('Hand-painted cobalt fillet',(T[0],T[1],T[2]+z),r,.010,cobalt)

# Discreet blue botanical brushwork follows the three-dimensional belly.
def radius_at(z):
    prof=[(.35,.96),(.61,1.095),(.88,1.14),(1.15,1.10),(1.39,.99)]
    for (a,r),(b,s) in zip(prof,prof[1:]):
        if a<=z<=b:return r+(s-r)*(z-a)/(b-a)
    return 1.0
for k in range(9):
    theta=2*pi*k/9
    stem=[]
    for j in range(7):
        z=.53+j*.095;a=theta+.032*sin(j*.7)
        r=radius_at(z)+.008
        stem.append((r*cos(a),r*sin(a),z))
    tube('Cobalt fern • stem',stem,[.008]*7,cobalt,T,8,4)
    for j in range(1,5):
        z=.54+j*.11
        for side in [-1,1]:
            pts=[]
            for q in range(4):
                f=q/3; a=theta+side*.13*f
                zz=z+.075*f
                r=radius_at(zz)+.010
                pts.append((r*cos(a),r*sin(a),zz))
            tube('Cobalt fern • leaf',pts,[.006,.017,.012,.002],cobalt,T,8,4)

# The leather folio under the Stanford sculpture.
book_center=Vector((-2.62,.72,.13))
book_angle=-.12
def book_world(p):
    x,y,z=p
    return book_center+Vector((x*cos(book_angle)-y*sin(book_angle),x*sin(book_angle)+y*cos(book_angle),z))
for name,z,dims,mat in [
    ('Folio lower leather board',.045,(2.06,1.58,.09),leather),
    ('Text block',.205,(1.94,1.46,.25),paper),
    ('Folio upper leather board',.37,(2.08,1.59,.095),leather)]:
    ob=cube(name,book_world((0,0,z)),dims,mat,.035)
    ob.rotation_euler[2]=book_angle
for i in range(13):
    z=.10+i*.017
    ob=cube('Uneven page edges',book_world((.015,-.738,z)),(1.87,.011,.004),paper,.002)
    ob.rotation_euler[2]=book_angle
ob=cube('Rounded calfskin spine',book_world((-.99,0,.21)),(.16,1.56,.34),leather,.06)
ob.rotation_euler[2]=book_angle
for y in [-.57,-.33,.34,.57]:
    ob=cube('Raised gilt spine rib',book_world((-1.071,y,.21)),(.018,.052,.27),gold,.012)
    ob.rotation_euler[2]=book_angle

# STANFORD: unified sculptural, crouched rabbit, not a collection of balls.
B=Vector((-2.64,.70,.55))
parts=[]
def bunny_part(name,loc,sc,rot=None):
    ob=ellipsoid(name,B+Vector(loc),sc,stone,rot)
    parts.append(ob);return ob
bunny_part('Rabbit round back',(.15,.12,.69),(.64,.48,.70),(0,-.17,0))
bunny_part('Rabbit heavy folded haunch',(.45,.02,.40),(.46,.43,.39))
bunny_part('Rabbit chest',(-.27,-.16,.69),(.36,.36,.58),(0,-.20,0))
bunny_part('Rabbit high head',(-.38,-.22,1.28),(.365,.33,.37),(0,-.12,-.08))
bunny_part('Rabbit muzzle',(-.53,-.445,1.15),(.255,.225,.18))
bunny_part('Rabbit near folded foreleg',(-.37,-.39,.36),(.15,.17,.32),(0,.18,-.08))
bunny_part('Rabbit near forepaw',(-.49,-.47,.12),(.25,.17,.115))
bunny_part('Rabbit far foreleg',(-.59,-.08,.33),(.12,.14,.28))
bunny_part('Rabbit far forepaw',(-.70,-.19,.12),(.21,.14,.11))
bunny_part('Rabbit folded rear foot',(.40,-.30,.14),(.40,.21,.14))
bunny_part('Rabbit tail',(.73,.34,.45),(.22,.21,.235))
# Elliptical curved ears with their tips folding in different directions.
def rabbit_ear(name, centers, widths, depths):
    ps=catmull([(*p,w,d) for p,w,d in zip(centers,widths,depths)],12)
    vs=[];fs=[];sides=32
    for p in ps:
        for j in range(sides):
            a=j*2*pi/sides
            # Front surface is indented, giving a stone-carved ear channel.
            xx=p[0]+p[3]*cos(a)
            yy=p[1]+p[4]*sin(a)
            if sin(a)<0: yy+=.035*(-sin(a))**5
            vs.append(tuple(B+Vector((xx,yy,p[2]))))
    for i in range(len(ps)-1):
        for j in range(sides):
            a=i*sides+j;b=i*sides+(j+1)%sides
            fs.append((a,b,b+sides,a+sides))
    fs.append(tuple(reversed(range(sides))))
    fs.append(tuple((len(ps)-1)*sides+j for j in range(sides)))
    ob=smooth(mesh_obj(name,vs,fs,stone));parts.append(ob)
rabbit_ear('Rabbit long listening ear',
           [(-.51,-.15,1.47),(-.57,-.11,1.77),(-.66,-.04,2.11),(-.66,.015,2.33),(-.59,.00,2.39)],
           [.13,.145,.12,.07,.008],[.09,.092,.075,.05,.009])
rabbit_ear('Rabbit softly folded second ear',
           [(-.23,-.10,1.48),(-.15,-.035,1.78),(-.12,.02,2.03),(-.23,.035,2.22),(-.34,-.005,2.24)],
           [.12,.15,.135,.087,.008],[.082,.09,.075,.052,.009])
bpy.ops.object.select_all(action='DESELECT')
for ob in parts:
    ob.select_set(True)
bpy.context.view_layer.objects.active=parts[0]
bpy.ops.object.join()
rabbit=bpy.context.object;rabbit.name='STANFORD • single carved crouching bunny'
bpy.ops.object.transform_apply(location=False,rotation=False,scale=True)
rem=rabbit.modifiers.new('Joined sculptural masses','REMESH');rem.mode='VOXEL';rem.voxel_size=.025
bpy.ops.object.modifier_apply(modifier=rem.name)
sm=rabbit.modifiers.new('Stone sculpt smoothing','SMOOTH');sm.factor=.65;sm.iterations=5
bpy.ops.object.modifier_apply(modifier=sm.name)
smooth(rabbit)
sub=rabbit.modifiers.new('Sculpt finish','SUBSURF');sub.levels=1
# Shallow actual carved sockets; dark recesses, no cartoon white eyeballs.
for loc in [(-.54,-.509,1.35),(-.696,-.282,1.36)]:
    cut=ellipsoid('Eye socket tool',B+Vector(loc),(.069,.061,.060),None)
    bpy.context.view_layer.objects.active=rabbit
    mod=rabbit.modifiers.new('Carved eye recess','BOOLEAN');mod.operation='DIFFERENCE';mod.object=cut
    # Apply before subdivision to keep the sculpt modest in size.
    bpy.ops.object.modifier_move_up(modifier=mod.name)
    bpy.ops.object.modifier_apply(modifier=mod.name)
    bpy.data.objects.remove(cut,do_unlink=True)
ellipsoid('Quiet inset rabbit eye',B+Vector((-.54,-.48,1.35)),(.034,.022,.030),eye_mat)
ellipsoid('Rabbit small carved nose',B+Vector((-.62,-.63,1.15)),(.062,.036,.043),stone)

# SUZANNE as the patinated portrait in the back rank.
S=(1.40,1.04,.17)
cube('Portrait plinth, bottom',(S[0],S[1],S[2]+.075),(1.43,1.1,.15),blackstone,.04)
cube('Portrait plinth, marble block',(S[0],S[1],S[2]+.27),(1.21,.94,.29),blackstone,.035)
cube('Portrait plinth, top bevel',(S[0],S[1],S[2]+.455),(1.35,1.04,.11),blackstone,.035)
lathe('Bust tapered bronze socle',[(.34,.49),(.37,.54),(.26,.62),(.24,.90),(.39,1.05)],bronze,S,96,6)
bpy.ops.mesh.primitive_monkey_add(location=(S[0],S[1],S[2]+1.60))
suz=bpy.context.object;suz.name='SUZANNE • bronze portrait'
suz.scale=(.83,.83,.83);suz.rotation_euler[2]=.12
suz.data.materials.append(bronze);smooth(suz)
sub=suz.modifiers.new('Foundry sculpt surface','SUBSURF');sub.levels=2;sub.render_levels=2
# A little bronze tablet on the front of the marble.
cube('Bust inscription plate',(S[0],S[1]-.478,S[2]+.27),(.66,.025,.15),gold,.015)
def text_obj(name,body,loc,size,mat,rotation=(pi/2,0,0),align='CENTER'):
    cu=bpy.data.curves.new(name,'FONT');cu.body=body;cu.align_x=align;cu.align_y='CENTER';cu.size=size;cu.extrude=.0008
    ob=bpy.data.objects.new(name,cu);bpy.context.collection.objects.link(ob)
    ob.location=loc;ob.rotation_euler=rotation;cu.materials.append(mat)
    # Mesh lettering also survives the interactive export.
    bpy.context.view_layer.objects.active=ob;ob.select_set(True)
    bpy.ops.object.convert(target='MESH');ob.select_set(False)
    return ob
text_obj('Foundry signature','SVZANNA', (S[0],S[1]-.495,S[2]+.27),.085,blackstone)

# Reflective checker sphere: two true metal materials, not a flat painted decal.
C=Vector((2.10,-1.14,.91)); R=.745
vs=[];fs=[];nlon=144;nlat=96
for i in range(nlat+1):
    th=pi*i/nlat
    for j in range(nlon):
        ph=2*pi*j/nlon
        vs.append(tuple(C+Vector((R*sin(th)*cos(ph),R*sin(th)*sin(ph),R*cos(th)))))
for i in range(nlat):
    for j in range(nlon):
        a=i*nlon+j;b=i*nlon+(j+1)%nlon
        fs.append((a,b,b+nlon,a+nlon))
orb=smooth(mesh_obj('SPECVLVM • the ray tracer’s checkered sphere',vs,fs))
orb.data.materials.append(chrome);orb.data.materials.append(darkchrome)
for i in range(nlat):
    for j in range(nlon):
        orb.data.polygons[i*nlon+j].material_index=((i//12)+(j//12))%2
torus('Sphere resting ring',(C.x,C.y,.184),.18,.027,bronze)

# A traditional pear supplies one quiet note of gold.
pear_mat=aged('Russet pear skin',(.18,.13,.018),(.57,.39,.066),0,.44,7,.017)
P=(-2.94,-1.27,.12)
profile=[(.035,.02),(.20,.045),(.32,.15),(.355,.29),(.31,.43),(.23,.57),(.16,.73),(.105,.83),(.02,.865)]
pear=lathe('One ripe russet pear',profile,pear_mat,P,96,8)
for v in pear.data.vertices:
    a=math.atan2(v.co.y-P[1],v.co.x-P[0])
    z=v.co.z-P[2]
    v.co.x+=.042*z*z
    v.co.z+=.009*sin(a*5)*sin(pi*z/.88)
tube('Pear stem',[(.03,0,.83),(.055,.005,.96),(.015,.035,1.07)],[.028,.022,.015],wood,P,12,8)
leafmat=aged('Pear leaf, fading olive',(.035,.056,.012),(.14,.17,.026),0,.61,8,.009)
vs=[];fs=[]
for i in range(17):
    t=i/16
    center=Vector((P[0]+.03+.49*t,P[1]+.015+.12*sin(t*pi),P[2]+.96+.08*sin(t*pi)-.11*t))
    w=.095*sin(pi*t)
    for side in [-1,0,1]:
        vs.append(tuple(center+Vector((0,w*side,-.025*abs(side)*sin(pi*t)))))
for i in range(16):
    for j in range(2):
        a=i*3+j;fs.append((a,a+1,a+4,a+3))
leaf=smooth(mesh_obj('Pear curling leaf',vs,fs,leafmat))
sol=leaf.modifiers.new('Leaf substance','SOLIDIFY');sol.thickness=.004
sub=leaf.modifiers.new('Leaf softness','SUBSURF');sub.levels=2

# A tiny maker's mark, beneath the teapot handle.
text_obj('Ceramic maker’s year','1975',(T[0]+.45,T[1]-.99,T[2]+.40),.052,cobalt)

# Warm, directional window light. The restrained fill is almost imperceptible.
world=bpy.data.worlds.new('Unlit room')
bpy.context.scene.world=world;world.use_nodes=True
world.node_tree.nodes['Background'].inputs[0].default_value=(.12,.145,.18,1)
world.node_tree.nodes['Background'].inputs[1].default_value=.095

def aim(ob,target):
    ob.rotation_euler=(Vector(target)-ob.location).to_track_quat('-Z','Y').to_euler()

def area(name,loc,energy,color,size,target,size_y=None):
    data=bpy.data.lights.new(name,'AREA');data.energy=energy;data.color=color
    if size_y:
        data.shape='RECTANGLE';data.size=size;data.size_y=size_y
    else:data.shape='DISK';data.size=size
    ob=bpy.data.objects.new(name,data);bpy.context.collection.objects.link(ob);ob.location=loc;aim(ob,target)
    return ob
key=area('One high western window',(-4.5,-3.6,6.4),1050,(1.0,.77,.51),3.0,(-.4,0,.65),3.7)
area('Faint reflected room light',(3,-5,3.7),65,(.60,.70,.85),5,(0,0,1))
# Narrow mullions in front of the source give the chrome a recognizable old window.
direction=(Vector((-.4,0,.65))-key.location).normalized()
rot=key.rotation_euler.to_quaternion()
center=key.location+direction*.12
for name,offset,dims in [
    ('Window central mullion',(0,0,0),(.070,3.85,.065)),
    ('Window crossbar',(0,.2,0),(3.12,.065,.065))]:
    ob=cube(name,center+rot@Vector(offset),dims,wood,.005)
    ob.rotation_euler=key.rotation_euler

# Camera: an intimate, slightly elevated view, with all silhouettes kept legible.
bpy.ops.object.camera_add(location=(5.9,-15.4,7.0))
camera=bpy.context.object;camera.name='The still life • presentation'
aim(camera,(-.12,-.02,.85))
camera.data.type='PERSP';camera.data.lens=56
camera.data.sensor_width=36
camera.data.dof.use_dof=True
focus=bpy.data.objects.new('Focus on the porcelain',None);bpy.context.collection.objects.link(focus)
focus.location=(-.48,-.4,1.15)
camera.data.dof.focus_object=focus;camera.data.dof.aperture_fstop=9
scene=bpy.context.scene;scene.camera=camera
scene.render.engine='CYCLES'
scene.cycles.samples=64
scene.cycles.use_denoising=True
scene.cycles.max_bounces=10
scene.cycles.diffuse_bounces=4
scene.cycles.glossy_bounces=6
scene.render.resolution_x=1536;scene.render.resolution_y=1536
scene.render.resolution_percentage=100
scene.render.image_settings.file_format='PNG'
scene.render.film_transparent=False
scene.view_settings.view_transform='AgX'
try: scene.view_settings.look='AgX - Medium High Contrast'
except: pass
scene.view_settings.exposure=.35
scene.render.image_settings.color_mode='RGBA'
# Organize and save the complete native scene.
scene['Title']='DE LVCE ET VMBRA — a history of appearances'
scene['Description']='Utah porcelain, Stanford limestone, Suzanne bronze, and the speculum of ray tracing; Cornell red and green in an old room.'
bpy.ops.object.select_all(action='DESELECT')
os.makedirs('/mnt/data',exist_ok=True)
bpy.ops.wm.save_as_mainfile(filepath='/mnt/data/scene.blend')
```