"""Original reproducible studio recipe for the pinned full-detail functional SELENE. Import alongside selene_studio.Studio. Preparation uses public command adapters, never native JSON edits, hidden geometry reduction or measured-property guesses. The final request and recipe receipts describe authored appearance choices. """ from __future__ import annotations import copy,json,math def build(studio, width=800, height=500, samples=128): if not (isinstance(width,int) and isinstance(height,int) and 1<=width<=8192 and 1<=height<=8192 and width*height<=16_777_216): raise ValueError('Image dimensions exceed the native GPU envelope') if not isinstance(samples,int) or not 1<=samples<=4096: raise ValueError('Samples must be an integer in 1..4096') scene=studio.scene bodies=scene['bodies'] lo=scene['bounds']['min'];hi=scene['bounds']['max'] if isinstance(lo,dict):lo=[lo[k] for k in ('x','y','z')];hi=[hi[k] for k in ('x','y','z')] center=[(a+b)/2 for a,b in zip(lo,hi)] extent=max(b-a for a,b in zip(lo,hi)) ground={'id':'studio-ground','center_mm':[center[0],center[1],lo[2]-0.1], 'half_u_mm':[extent*2.5,0,0],'half_v_mm':[0,extent*2.5,0], 'reflectance_linear':[0.18,0.19,0.21]} glass=[] maps=[] bindings=[] for b in bodies: if b['opacity'] < 1: name=b['name'];kind='diffuser' if 'diffuser' in name.lower() else 'lens' if 'lens' in name.lower() else 'vial' if 'vial' in name.lower() else 'window' # Full closed solid validation remains in the actual native executor. # These RGB absorption choices are authored, not measured glass spectra. sigma={'vial':[0.002,0.0006,0.0004],'lens':[0.008,0.003,0.001], 'window':[0.0002,0.0002,0.0002],'diffuser':[0.015,0.003,0.001]}[kind] glass.append({'body_index':b['ordinal'],'body_name':name,'ior':1.49 if kind=='diffuser' else 1.5, 'absorption_per_mm':sigma,'boundary':'closed_mesh','thickness_mm':0.0,'shadow_transmission':True}) name=b['name'].lower() surface=None;preserve_palette=False metal_names=('Structural electronics tub','Arm structural nose','Rear science outrigger','Sample compartment','Unified sensor crossbeam') paint_prefix=('Shoulder link ','Elbow link ','Distal wrist link ','Orange solar frame ','Payload rail ','Orange side service strip ','18650 removable battery tray') if b['opacity'] == 1: if b['name'] in metal_names or b['name'].startswith(('Solar outrigger beam ','Suspension chassis shoe ')): surface='SURF-007' elif b['name'] in ('Raspberry Pi 5 PCB','Battery management board'): surface='SURF-036';preserve_palette=True elif b['name'].startswith(paint_prefix) and b['color']==[233,137,53]: surface='SURF-015';preserve_palette=True elif b['name'].startswith(('Forearm cross brace ','Sensor rear cover')): surface='SURF-014';preserve_palette=True elif b['name'].startswith('TPU wheel tyre '): surface='SURF-024';preserve_palette=True elif b['name']=='Basalt pebble': surface='SURF-047' if surface: bounds=b['bounds'];mn=bounds['min'];mx=bounds['max'] if isinstance(mn,dict):mn=[mn[k] for k in ('x','y','z')];mx=[mx[k] for k in ('x','y','z')] axis=min(range(3),key=lambda i:mx[i]-mn[i]);plane=['yz','zx','xy'][axis] prepared=studio.call('render.library.surface.prepare',{'id':surface,'body_index':b['ordinal'],'body_name':b['name'],'plane':plane}) texture=prepared['texture'] if preserve_palette:texture.pop('base_color_srgb',None) maps.append(texture) bindings.append({'body':b['name'],'surface':surface,'plane':plane,'preserve_native_palette':preserve_palette, 'projection':'static-world planar appearance mapping; no geometric displacement'}) if len(maps)>128:raise ValueError('Explicit reviewed material targets exceed 128 bindings') if len(glass)>32:raise ValueError('Native transparent body count exceeds the explicitly admitted contract') # The original orthographic hero camera is kept initially for full-master comparison. camera={'target':[87.0,0.0,145.0],'yaw':-0.66,'pitch':0.53,'roll':0.0,'distance':630.0,'fov':0.0} # HDR alone owns illumination for the initial beauty-light assessment. params={'progressive':True,'samples':samples,'max_depth':12,'seed':21026,'tone_map':'aces_fitted','denoise':True, 'settings':{'width':width,'height':height,'camera':camera,'background':[232,236,242], 'exposure_ev':-2.0,'stage':[ground]}, 'environment':{'kind':'builtin_hdr','id':'HDR-002','rotation_rad':0.35,'intensity':1.0}, 'lighting':{'environment':[0.0,0.0,0.0],'area_lights':[],'sun':None}, 'raytrace':{'dielectrics':glass,'clear_coats':[],'textures':maps}} recipe={'scope':'Native full visible functional SELENE; authored optical appearance only', 'master_visibility_preserved':True,'model_geometry_or_engineering_properties_changed':False, 'glass_body_count':len(glass),'mapped_bodies':bindings, 'limitations':['RGB glass absorption is an authored illustrative value, not a measured optical dataset.', 'The LED diffusers are transmission surfaces; no mesh emission or volumetric scattering is claimed.', 'Planar normal maps change shading only, not silhouette or CAD geometry.'], 'request':params} studio.write('hero-recipe.json',recipe) print(json.dumps({'glass_bodies':len(glass),'mapped_body_count':len(bindings),'surface_ids':sorted({x['surface'] for x in bindings}),'bounds':scene['bounds']}),flush=True) return params def fit_camera(scene, aspect, yaw=-0.66, pitch=0.53, fov=0.46, margin=0.08): """Original analytic fit of captured body AABB corners, excluding stage/lights. Derives the smallest distance at a fixed target/rotation satisfying a frame margin for every captured corner. No renderer projection code is invoked. """ import itertools if not all(math.isfinite(x) for x in (aspect,yaw,pitch,fov,margin)) or aspect<=0 or not 0h or b