"""Darker night lighting with visible practical sources; still renders only.""" import bpy, os, math from mathutils import Vector ROOT=os.path.dirname(os.path.dirname(os.path.abspath(__file__))) OUT=os.path.join(ROOT,'preview','v4');os.makedirs(OUT,exist_ok=True) bpy.ops.wm.open_mainfile(filepath=os.path.join(ROOT,'preview','v3','halloween_examples.blend')) s=bpy.context.scene;s.render.engine='BLENDER_EEVEE';s.eevee.taa_render_samples=64 s.eevee.use_gtao=True;s.eevee.gtao_distance=2;s.eevee.use_ssr=True;s.eevee.use_ssr_refraction=True s.eevee.use_soft_shadows=True;s.eevee.shadow_cube_size='2048';s.eevee.use_bloom=True;s.eevee.bloom_intensity=.045;s.eevee.bloom_threshold=1.2 s.view_settings.exposure=-.6 s.world.use_nodes=True;bg=s.world.node_tree.nodes.get('Background');bg.inputs['Color'].default_value=(.002,.004,.008,1);bg.inputs['Strength'].default_value=.15 for l in bpy.data.lights: l.use_shadow=True;l.use_contact_shadow=True;l.contact_shadow_distance=.4;l.contact_shadow_bias=.015 moon=bpy.data.lights['Moon'];moon.energy=95;moon.color=(.55,.65,1);moon.size=5 bpy.data.lights['Porch'].energy=0 blue=bpy.data.lights['Grave blue'];blue.energy=30;blue.color=(.12,.24,1);blue.size=.7 red=bpy.data.lights['Hidden red glow'];red.energy=5;red.color=(1,.055,.008);red.shadow_soft_size=.12 bpy.data.objects['Hidden red glow'].location=(-.72,.7,.31) # Light actually emanates from the lit windows, casting warm patches on the path. for x in [-3,0,3]: l=bpy.data.lights.new('Window spill '+str(x),'AREA');l.energy=24;l.color=(1,.59,.28);l.shape='RECTANGLE';l.size=1.3;l.size_y=1.5 l.use_contact_shadow=True o=bpy.data.objects.new(l.name,l);s.collection.objects.link(o);o.location=(x,5.55,2.2);o.rotation_euler=(Vector((x,1,.2))-o.location).to_track_quat('-Z','Y').to_euler() m=bpy.data.materials['Warm window '+str(x)];p=m.node_tree.nodes.get('Principled BSDF');p.inputs['Emission Color'].default_value=(1,.52,.19,1);p.inputs['Emission Strength'].default_value=1.5 # Small visible porch lantern with warm light and subtle irregular flicker. em=bpy.data.materials.new('Lantern glowing glass');em.use_nodes=True;p=em.node_tree.nodes.get('Principled BSDF');p.inputs['Base Color'].default_value=(.6,.18,.02,1);p.inputs['Emission Color'].default_value=(1,.45,.12,1);p.inputs['Emission Strength'].default_value=4 bpy.ops.mesh.primitive_uv_sphere_add(segments=16,ring_count=8,location=(2,5.35,2.15));o=bpy.context.object;o.name='Porch lantern glass';o.scale=(.065,.065,.12);o.data.materials.append(em) for z in [2.02,2.28]: bpy.ops.mesh.primitive_cube_add(size=1,location=(2,5.35,z));o=bpy.context.object;o.name='Lantern metal cap';o.scale=(.19,.16,.035);o.data.materials.append(bpy.data.materials['Dark fabric']) l=bpy.data.lights.new('Porch lantern light','POINT');l.color=(1,.56,.23);l.shadow_soft_size=.09;l.use_contact_shadow=True ob=bpy.data.objects.new(l.name,l);s.collection.objects.link(ob);ob.location=(2,5.20,2.15) for frame in range(1,481,3):l.energy=17+1.8*math.sin(frame*.17)+.8*math.sin(frame*.71);l.keyframe_insert('energy',frame=frame) # Damp pavers catch localized highlights; leave soil and cloth matte. p=bpy.data.materials['Weathered limestone'].node_tree.nodes.get('Principled BSDF');p.inputs['Roughness'].default_value=.48 # Directed flash briefly reveals hand and airborne leaves, rather than lighting the whole garden. ob=bpy.data.objects['Brief reveal'];old=ob.data;flash=bpy.data.lights.new('Directed grave reveal','SPOT');ob.data=flash;flash.use_contact_shadow=True;flash.spot_size=math.radians(65);flash.spot_blend=.65;flash.shadow_soft_size=.13;flash.color=(1,.67,.36) for frame,power in [(1,0),(310,0),(316,700),(320,450),(324,180),(332,380),(340,0),(480,0)]:flash.energy=power;flash.keyframe_insert('energy',frame=frame) # Hint of light scattering in the low mist, without a luminous fog blanket. vol=bpy.data.materials['Thin ground mist'].node_tree.nodes.get('Principled Volume');vol.inputs['Density'].default_value=.035;vol.inputs['Anisotropy'].default_value=.25 s.frame_set(310);s.render.image_settings.file_format='PNG';s.render.filepath=os.path.join(OUT,'example_') bpy.ops.file.pack_all();bpy.ops.wm.save_as_mainfile(filepath=os.path.join(OUT,'halloween_examples.blend')) for frame in [310,322,334]: s.frame_set(frame);s.render.filepath=os.path.join(OUT,'example_%03d.png'%frame);bpy.ops.render.render(write_still=True) print('DARKER EXAMPLES COMPLETE — still images only')