```python
import bpy
import bmesh
import math
from mathutils import Vector, Matrix

def reset_scene():
    bpy.ops.object.select_all(action='SELECT')
    bpy.ops.object.delete()

def set_render_settings():
    scene = bpy.context.scene
    scene.render.engine = 'CYCLES'
    scene.cycles.use_denoising = True
    scene.render.resolution_x = 1536
    scene.render.resolution_y = 1536

    # Modern color management
    scene.view_settings.view_transform = 'AgX'
    scene.view_settings.look = 'Medium High Contrast'

def create_subdivided_mesh(name, vertices, faces, subdiv_levels=2):
    mesh = bpy.data.meshes.new(name)
    mesh.from_pydata(vertices, [], faces)
    mesh.update()

    obj = bpy.data.objects.new(name, mesh)
    bpy.context.collection.objects.link(obj)

    # Shade smooth
    for poly in mesh.polygons:
        poly.use_smooth = True

    # Add Subdivision Modifier
    subdiv = obj.modifiers.new(name="Subdivision", type='SUBSURF')
    subdiv.levels = subdiv_levels
    subdiv.render_levels = subdiv_levels

    return obj

def get_boot_vertices():
    """Generates all vertices for the custom boot base mesh profile."""
    rings = []
    num_rings = 11  # 0 to 10
    num_cols = 16

    angles = [i * 2 * math.pi / num_cols for i in range(num_cols)]

    for r in range(num_rings):
        ring_coords = []
        v = r / (num_rings - 1)  # 0 to 1

        for c in range(num_cols):
            theta = angles[c]

            # Base Footprint Shape
            x = math.sin(theta) * 0.52
            y = math.cos(theta) * 0.85 + 0.2

            # Right-foot arch shape (inner side is X < 0)
            if x < 0:
                dist_to_arch = abs(y - 0.1)
                if dist_to_arch < 0.5:
                    indent = 0.18 * math.cos(dist_to_arch * math.pi / 1.0)
                    x += indent

            # Default elevation Z
            curr_z = v * 2.2

            # Ring deforming to sculpt ankle, toe box and worn slumping
            if r == 0:
                curr_z = 0.05
            elif r == 1:
                curr_z = 0.25
                if y > 0:
                    x *= 0.95
                    y *= 0.95
            elif r == 2:
                curr_z = 0.55
                if y > 0.2:
                    curr_z = 0.45 + (1.0 - (y / 1.05)) * 0.1
                    x *= 0.9
            elif r == 3:
                curr_z = 0.95
                if y > 0.1:
                    y = y * 0.45 + 0.05
            elif 4 <= r <= 7:
                # Ankle Shaft
                curr_z = 0.95 + (r - 3) * (0.95 / 4.0)
                r_shaft = 0.38
                x = math.sin(theta) * r_shaft
                y = math.cos(theta) * r_shaft - 0.18
            else:
                # Padded loop/collar system (Rings 8, 9, 10 roll over smoothly)
                r_shaft = 0.38
                if r == 8:
                    curr_z = 1.95
                    x = math.sin(theta) * (r_shaft * 1.05)
                    y = math.cos(theta) * (r_shaft * 1.05) - 0.18
                elif r == 9:
                    curr_z = 1.92  # rolled downwards
                    x = math.sin(theta) * (r_shaft * 1.15)
                    y = math.cos(theta) * (r_shaft * 1.15) - 0.18
                elif r == 10:
                    curr_z = 1.83  # folded inside
                    x = math.sin(theta) * (r_shaft * 0.98)
                    y = math.cos(theta) * (r_shaft * 0.98) - 0.18

            # Add authentic leather slump and owner physical walk distortion
            if r >= 4:
                # Slump slightly backward and to the side (asymmetric wear)
                x += 0.08 * (v - 0.3)
                y -= 0.1 * (v - 0.3)

            # Instep leather collapsing folder zones
            if r in [2, 3] and y > -0.1:
                curr_z -= 0.06
                curr_z += 0.04 * math.sin(x * 10.0)

            ring_coords.append(Vector((x, y, curr_z)))

        rings.append(ring_coords)
    return rings

def build_boot_upper():
    rings = get_boot_vertices()
    num_rings = len(rings)
    num_cols = len(rings[0])

    vertices = []
    for ring in rings:
        for v in ring:
            vertices.append(v)

    is_split_start_ring = 3
    faces = []
    for r in range(num_rings - 1):
        for c in range(num_cols):
            next_c = (c + 1) % num_cols
            is_gap = False
            # Cut slit for tongue down the front lace panels
            if r >= is_split_start_ring:
                if c in [15, 0]:
                    is_gap = True

            if not is_gap:
                v1 = r * num_cols + c
                v2 = r * num_cols + next_c
                v3 = (r + 1) * num_cols + next_c
                v4 = (r + 1) * num_cols + c
                faces.append((v1, v2, v3, v4))

    upper_obj = create_subdivided_mesh("BootUpper", vertices, faces, subdiv_levels=2)

    # Thick/plump leather solidify modifier
    solidify = upper_obj.modifiers.new(name="Solidify", type='SOLIDIFY')
    solidify.thickness = 0.035
    solidify.offset = -1.0

    return upper_obj

def create_boot_tongue():
    rings = []
    num_rings = 8
    num_cols = 6

    for r in range(num_rings):
        v = r / (num_rings - 1)
        z = 0.75 + v * 1.35
        ring_coords = []
        for c in range(num_cols):
            u = c / (num_cols - 1)
            # Width of tongue
            x = (u - 0.5) * 0.45

            # Arched forward position
            y = -0.1 + (v * 0.28) - (x**2 * 0.4)
            if r >= 5:
                y += (r - 4) * 0.09  # top slump

            ring_coords.append(Vector((x, y, z)))
        rings.append(ring_coords)

    vertices = []
    for ring in rings:
        for v in ring:
            vertices.append(v)

    faces = []
    for r in range(num_rings - 1):
        for c in range(num_cols - 1):
            v1 = r * num_cols + c
            v2 = r * num_cols + (c + 1)
            v3 = (r + 1) * num_cols + (c + 1)
            v4 = (r + 1) * num_cols + c
            faces.append((v1, v2, v3, v4))

    # Add micro leather folds to tongue
    for idx, vert in enumerate(vertices):
        vert.y += 0.04 * math.sin(vert.z * 11.0)
        vert.x += 0.02 * math.cos(vert.z * 8.0)

    tongue = create_subdivided_mesh("BootTongue", vertices, faces, subdiv_levels=2)
    solidify = tongue.modifiers.new(name="Solidify", type='SOLIDIFY')
    solidify.thickness = 0.025
    solidify.offset = -1.0
    return tongue

def create_boot_sole():
    upper_rings = get_boot_vertices()
    ring_base = upper_rings[0]

    num_cols = 16
    layers = [0.06, -0.04, -0.18]

    vertices = []
    for layer_z in layers:
        for c in range(num_cols):
            v = ring_base[c]
            scale_factor = 1.07

            # Create physical tread teeth details inside outsole layer
            if layer_z == -0.18:
                if c % 2 == 0:
                    scale_factor = 1.13  # Wide tread block
                else:
                    scale_factor = 1.02  # Inward tread lug

            x = v.x * scale_factor
            y = v.y * scale_factor
            z = layer_z

            # Wear and heel roll
            if y < -0.3:
                if x > 0:  # rolled wear on outer side of foot
                    z += 0.028

            vertices.append(Vector((x, y, z)))

    faces = []
    for r in range(len(layers) - 1):
        for c in range(num_cols):
            next_c = (c + 1) % num_cols
            v1 = r * num_cols + c
            v2 = r * num_cols + next_c
            v3 = (r + 1) * num_cols + next_c
            v4 = (r + 1) * num_cols + c
            faces.append((v1, v2, v3, v4))

    # Bottom cap (outsole base face)
    bottom_ring = [(len(layers) - 1) * num_cols + c for c in range(num_cols)]
    bottom_ring.reverse()
    faces.append(bottom_ring)

    # Top Cap (welt base face)
    top_ring = [c for c in range(num_cols)]
    faces.append(top_ring)

    sole_obj = create_subdivided_mesh("BootSole", vertices, faces, subdiv_levels=2)

    # Create solid block heel underneath (Y from -1.35 to -0.2)
    layers_heel = [-0.18, -0.38]
    val_subset = [0, 1, 2, 3, 4, 12, 13, 14, 15] # heel sector columns

    heel_verts = []
    for l_z in layers_heel:
        for c in val_subset:
            v = ring_base[c]
            # Outer heel edge has subtle roll
            z_offset = 0.038 if (v.x > 0 and v.y < -0.4) else 0.0
            heel_verts.append(Vector((v.x * 1.06, v.y * 1.05, l_z + z_offset)))

    # Simple clean cube configuration for heel block
    heel_faces = [
        [0, 1, 2, 3, 12, 11, 10, 9], # simplified loop
    ]
    # Build a procedurally approximated box block matching sole
    bpy.ops.mesh.primitive_cube_add(size=1.0)
    heel_obj = bpy.context.active_object
    heel_obj.name = "HeelBlock"
    heel_obj.location = (0.05, -0.65, -0.28)
    heel_obj.scale = (0.8, 0.65, 0.2)

    # Shade smooth with Subdiv
    for poly in heel_obj.data.polygons:
        poly.use_smooth = True
    subdiv = heel_obj.modifiers.new(name="Subdiv", type='SUBSURF')
    subdiv.levels = 2

    return sole_obj, heel_obj

def place_welt_stitching():
    upper_rings = get_boot_vertices()
    ring_base = upper_rings[0]
    num_stitches = 44

    # Template Stitch base geometry
    bpy.ops.mesh.primitive_cylinder_add(radius=0.007, depth=0.038)
    st = bpy.context.active_object
    st.name = "StitchMaster"
    st.scale = (1.6, 0.4, 1.0) # Thread shape

    thread_mat = bpy.data.materials.new(name="StitchThread")
    thread_mat.use_nodes = True
    thread_mat.node_tree.nodes['Principled BSDF'].inputs['Base Color'].default_value = (0.75, 0.62, 0.44, 1.0)
    thread_mat.node_tree.nodes['Principled BSDF'].inputs['Roughness'].default_value = 0.95
    st.data.materials.append(thread_mat)

    st.hide_render = True
    st.hide_viewport = True

    for i in range(num_stitches):
        t = i / num_stitches
        theta = t * 2 * math.pi

        # Profile outline
        x = math.sin(theta) * 0.545
        y = math.cos(theta) * 0.88 + 0.2
        if x < 0:
            dist_to_arch = abs(y - 0.1)
            if dist_to_arch < 0.5:
                indent = 0.18 * math.cos(dist_to_arch * math.pi / 1.0)
                x += indent

        z = 0.065

        # Path tangent calculation to align stitch rotation
        next_t = (i + 1) / num_stitches
        next_theta = next_t * 2 * math.pi
        nx = math.sin(next_theta) * 0.545
        ny = math.cos(next_theta) * 0.88 + 0.2
        if nx < 0:
            dist_to_arch = abs(ny - 0.1)
            if dist_to_arch < 0.5:
                indent = 0.18 * math.cos(dist_to_arch * math.pi / 1.0)
                nx += indent

        tangent = Vector((nx - x, ny - y, 0.0)).normalized()
        angle = math.atan2(tangent.y, tangent.x)

        # Clone stitch instance
        st_clone = st.copy()
        st_clone.data = st.data.copy()
        st_clone.location = Vector((x, y, z))
        st_clone.rotation_euler = (0, 0, angle)
        st_clone.hide_values_clear()
        st_clone.hide_viewport = False
        st_clone.hide_render = False
        bpy.context.collection.objects.link(st_clone)

def place_eyelets():
    upper_rings = get_boot_vertices()

    # Grommet metal rim
    bpy.ops.mesh.primitive_torus_add(align='WORLD', location=(0,0,0), major_radius=0.035, minor_radius=0.012)
    ey = bpy.context.active_object
    ey.name = "EyeletMaster"

    ey_mat = bpy.data.materials.new(name="BrassEyelet")
    ey_mat.use_nodes = True
    nodes = ey_mat.node_tree.nodes
    bsdf = nodes['Principled BSDF']
    bsdf.inputs['Base Color'].default_value = (0.7, 0.53, 0.32, 1.0) # brass plating
    bsdf.inputs['Metallic'].default_value = 1.0
    bsdf.inputs['Roughness'].default_value = 0.35
    ey.data.materials.append(ey_mat)

    ey.hide_render = True
    ey.hide_viewport = True

    left_coords = []
    right_coords = []

    # 6 Eyelets per side
    for r in [3, 4, 5, 6, 7, 8]:
        v_l = upper_rings[r][1] + Vector((-0.01, 0.02, 0.01))
        v_r = upper_rings[r][15] + Vector((0.01, 0.02, 0.01))

        left_coords.append(v_l)
        right_coords.append(v_r)

        for v, side in [(v_l, 'L'), (v_r, 'R')]:
            ey_cl = ey.copy()
            ey_cl.data = ey.data.copy()
            ey_cl.location = v
            rot_y = 0.45 if side == 'L' else -0.45
            ey_cl.rotation_euler = (0.35, rot_y, 0.0)
            ey_cl.hide_values_clear()
            ey_cl.hide_viewport = False
            ey_cl.hide_render = False
            bpy.context.collection.objects.link(ey_cl)

    return left_coords, right_coords

def create_bezier_spline(curve_data, points):
    spline = curve_data.splines.new('BEZIER')
    spline.bezier_points.add(len(points) - 1)
    for j, p in enumerate(points):
        bp = spline.bezier_points[j]
        bp.co = p
        bp.handle_left = p - Vector((0.05 if j > 0 else 0, 0, 0.08))
        bp.handle_right = p + Vector((0.05 if j < len(points) - 1 else 0, 0, 0.08))

def place_laces(left_coords, right_coords):
    curve_data = bpy.data.curves.new('LacesCurve', type='CURVE')
    curve_data.dimensions = '3D'
    curve_data.bevel_depth = 0.014
    curve_data.bevel_resolution = 4

    lace_mat = bpy.data.materials.new(name="DustyLaces")
    lace_mat.use_nodes = True
    lace_mat.node_tree.nodes['Principled BSDF'].inputs['Base Color'].default_value = (0.5, 0.41, 0.32, 1.0)
    lace_mat.node_tree.nodes['Principled BSDF'].inputs['Roughness'].default_value = 0.95
    curve_data.materials.append(lace_mat)

    # 1. Criss cross lacing (Eyelet 0 to 4)
    for i in range(4):
        # Left down to Right up
        p1 = left_coords[i]
        p4 = right_coords[i+1]
        p2 = p1 * 0.7 + p4 * 0.3 + Vector((0, 0.05, -0.06))
        p3 = p1 * 0.3 + p4 * 0.7 + Vector((0, 0.05, -0.06))
        create_bezier_spline(curve_data, [p1, p2, p3, p4])

        # Right down to Left up
        p1_r = right_coords[i]
        p4_r = left_coords[i+1]
        p2_r = p1_r * 0.7 + p4_r * 0.3 + Vector((0, 0.05, -0.06))
        p3_r = p1_r * 0.3 + p4_r * 0.7 + Vector((0, 0.05, -0.06))
        create_bezier_spline(curve_data, [p1_r, p2_r, p3_r, p4_r])

    # 2. Hanging ends (One aglet missing, one frayed)
    path_left = [
        left_coords[4],
        left_coords[5],
        left_coords[5] + Vector((-0.12, 0.12, -0.1)),
        left_coords[5] + Vector((-0.24, 0.16, -0.32)),
        left_coords[5] + Vector((-0.18, 0.08, -0.68))  # lower hanging end
    ]
    create_bezier_spline(curve_data, path_left)

    path_right = [
        right_coords[4],
        right_coords[5],
        right_coords[5] + Vector((0.18, 0.11, -0.15)),
        right_coords[5] + Vector((0.28, 0.08, -0.44)),
        right_coords[5] + Vector((0.15, 0.03, -0.85))  # touches ground
    ]
    create_bezier_spline(curve_data, path_right)

    curve_obj = bpy.data.objects.new('Laces', curve_data)
    bpy.context.collection.objects.link(curve_obj)

    # Clean left plastic aglet
    bpy.ops.mesh.primitive_cylinder_add(radius=0.015, depth=0.07)
    aglet = bpy.context.active_object
    aglet.name = "PlasticAglet"
    aglet.location = path_left[-1]

    aglet_mat = bpy.data.materials.new(name="AgletPlastic")
    aglet_mat.use_nodes = True
    aglet_mat.node_tree.nodes['Principled BSDF'].inputs['Base Color'].default_value = (0.1, 0.1, 0.1, 1.0)
    aglet.data.materials.append(aglet_mat)

    # Missing aglet / split frayed tip on right lace
    bpy.ops.mesh.primitive_ico_sphere_add(radius=0.024, subdivisions=2)
    fray = bpy.context.active_object
    fray.name = "FrayedTip"
    fray.location = path_right[-1]
    fray.data.materials.append(lace_mat)

def place_heel_pull():
    upper_rings = get_boot_vertices()
    top_back = upper_rings[7][8]
    mid_back = upper_rings[5][8]

    p1 = mid_back
    p2 = top_back + Vector((0.0, -0.22, 0.12))
    p3 = top_back

    curve_data = bpy.data.curves.new('HeelPullCurve', type='CURVE')
    curve_data.dimensions = '3D'
    curve_data.bevel_depth = 0.009
    curve_data.bevel_resolution = 4

    web_mat = bpy.data.materials.new(name="PullWebbing")
    web_mat.use_nodes = True
    web_mat.node_tree.nodes['Principled BSDF'].inputs['Base Color'].default_value = (0.12, 0.12, 0.12, 1.0)
    curve_data.materials.append(web_mat)

    create_bezier_spline(curve_data, [p1, p2, p3])
    curve_obj = bpy.data.objects.new('HeelPull', curve_data)
    bpy.context.collection.objects.link(curve_obj)

def create_leather_material():
    mat = bpy.data.materials.new(name="WornFullGrainLeather")
    mat.use_nodes = True
    nodes = mat.node_tree.nodes
    links = mat.node_tree.links
    nodes.clear()

    # Base output/nodes
    output = nodes.new(type='ShaderNodeOutputMaterial')
    bsdf = nodes.new(type='ShaderNodeBsdfPrincipled')
    links.new(bsdf.outputs['BSDF'], output.inputs['Surface'])

    # Coordinates
    tex_coord = nodes.new(type='ShaderNodeTexCoord')

    # Leather Pore microstructure
    noise_grain = nodes.new(type='ShaderNodeTextureNoise')
    noise_grain.inputs['Scale'].default_value = 160.0
    noise_grain.inputs['Detail'].default_value = 15.0
    noise_grain.inputs['Roughness'].default_value = 0.65

    bump_grain = nodes.new(type='ShaderNodeBump')
    bump_grain.inputs['Strength'].default_value = 0.09
    links.new(noise_grain.outputs['Fac'], bump_grain.inputs['Height'])
    links.new(bump_grain.outputs['Normal'], bsdf.inputs['Normal'])

    # Scuffed Toe abrasion system
    math_sub = nodes.new(type='ShaderNodeVectorMath')
    math_sub.operation = 'SUBTRACT'
    math_sub.inputs[1].default_value = Vector((0.0, 0.72, 0.32)) # relative toe box center
    links.new(tex_coord.outputs['Object'], math_sub.inputs[0])

    math_len = nodes.new(type='ShaderNodeVectorMath')
    math_len.operation = 'LENGTH'
    links.new(math_sub.outputs['Vector'], math_len.inputs[0])

    scuff_ramp = nodes.new(type='ShaderNodeValToRGB')
    scuff_ramp.color_ramp.interpolation = 'SMOOTH'
    scuff_ramp.color_ramp.elements[0].position = 0.16
    scuff_ramp.color_ramp.elements[0].color = (0.0, 0.0, 0.0, 1.0)
    scuff_ramp.color_ramp.elements[1].position = 0.36
    scuff_ramp.color_ramp.elements[1].color = (1.0, 1.0, 1.0, 1.0)
    links.new(math_len.outputs['Value'], scuff_ramp.inputs['Value'])

    # Salt/Water Tide line simulation
    sep_xyz = nodes.new(type='ShaderNodeSeparateXYZ')
    links.new(tex_coord.outputs['Object'], sep_xyz.inputs['Vector'])

    noise_salt = nodes.new(type='ShaderNodeTextureNoise')
    noise_salt.inputs['Scale'].default_value = 9.0

    salt_math = nodes.new(type='ShaderNodeMath')
    salt_math.operation = 'ADD'
    links.new(sep_xyz.outputs['Z'], salt_math.inputs[0])
    links.new(noise_salt.outputs['Fac'], salt_math.inputs[1])

    salt_ramp = nodes.new(type='ShaderNodeValToRGB')
    salt_ramp.color_ramp.elements[0].position = 0.18
    salt_ramp.color_ramp.elements[0].color = (0.0, 0.0, 0.0, 1.0)
    salt_ramp.color_ramp.elements[1].position = 0.22
    salt_ramp.color_ramp.elements[1].color = (1.0, 1.0, 1.0, 1.0)
    salt_ramp.color_ramp.elements.new(0.24)
    salt_ramp.color_ramp.elements[2].color = (0.0, 0.0, 0.0, 1.0)
    links.new(sep_xyz.outputs['Z'], salt_ramp.inputs['Value'])

    # Master Color mixing
    leather_tan = (0.32, 0.2, 0.12, 1.0)      # Inner scuffed leather
    leather_dark = (0.12, 0.06, 0.03, 1.0)    # Outer burnished full grain leather

    mix_scuff = nodes.new(type='ShaderNodeMix')
    mix_scuff.data_type = 'RGBA'
    mix_scuff.inputs[6].default_value = leather_tan
    mix_scuff.inputs[7].default_value = leather_dark
    links.new(scuff_ramp.outputs['Color'], mix_scuff.inputs['Factor'])

    mix_salt = nodes.new(type='ShaderNodeMix')
    mix_salt.data_type = 'RGBA'
    mix_salt.inputs[6].default_value = (0.64, 0.62, 0.58, 1.0)  # Crusty salt white
    links.new(mix_scuff.outputs['Result'], mix_salt.inputs[7])
    links.new(salt_ramp.outputs['Color'], mix_salt.inputs['Factor'])
    links.new(mix_salt.outputs['Result'], bsdf.inputs['Base Color'])

    # Master Roughness: scuffed areas are dry/matte, burnished areas are polished
    mix_rough = nodes.new(type='ShaderNodeMix')
    mix_rough.data_type = 'FLOAT'
    mix_rough.inputs[6].default_value = 0.95  # scuff roughness
    mix_rough.inputs[7].default_value = 0.42  # polished base leather
    links.new(scuff_ramp.outputs['Color'], mix_rough.inputs['Factor'])
    links.new(mix_rough.outputs['Result'], bsdf.inputs['Roughness'])

    return mat

def create_sole_material():
    mat = bpy.data.materials.new(name="DriedMudRubberSole")
    mat.use_nodes = True
    nodes = mat.node_tree.nodes
    links = mat.node_tree.links
    nodes.clear()

    output = nodes.new(type='ShaderNodeOutputMaterial')
    bsdf = nodes.new(type='ShaderNodeBsdfPrincipled')
    links.new(bsdf.outputs['BSDF'], output.inputs['Surface'])

    # Mud gradient (bottom of sole receives heavy dry mud)
    tex_coord = nodes.new(type='ShaderNodeTexCoord')
    sep_xyz = nodes.new(type='ShaderNodeSeparateXYZ')
    links.new(tex_coord.outputs['Object'], sep_xyz.inputs['Vector'])

    noise = nodes.new(type='ShaderNodeTextureNoise')
    noise.inputs['Scale'].default_value = 6.0

    mud_ramp = nodes.new(type='ShaderNodeValToRGB')
    mud_ramp.color_ramp.elements[0].position = -0.35
    mud_ramp.color_ramp.elements[0].color = (0.35, 0.27, 0.18, 1.0)  # dry mud
    mud_ramp.color_ramp.elements[1].position = -0.05
    mud_ramp.color_ramp.elements[1].color = (0.05, 0.05, 0.05, 1.0)  # clean tread black rubber
    links.new(sep_xyz.outputs['Z'], mud_ramp.inputs['Value'])

    links.new(mud_ramp.outputs['Color'], bsdf.inputs['Base Color'])
    bsdf.inputs['Roughness'].default_value = 0.88

    return mat

def create_studio_sweep():
    # Large backdrop sweep plane matching user specs
    bpy.ops.mesh.primitive_plane_add(size=15.0, location=(0, 2.0, -0.4))
    sweep = bpy.context.active_object
    sweep.name = "StudioSweep"

    grid_mesh = sweep.data
    bpy.ops.object.mode_set(mode='EDIT')
    bpy.ops.mesh.subdivide(number_cuts=4)
    bpy.ops.object.mode_set(mode='OBJECT')

    # Elegant curved backdrop sweep shape
    for v in grid_mesh.vertices:
        if v.co.y > 1.0:
            dist = (v.co.y - 1.0) / 6.0
            v.co.z += (dist ** 2.2) * 8.0

    # Shade smooth
    for poly in grid_mesh.polygons:
        poly.use_smooth = True

    subdiv = sweep.modifiers.new(name="Subdiv", type='SUBSURF')
    subdiv.levels = 3

    sweep_mat = bpy.data.materials.new(name="BackdropSweep")
    sweep_mat.use_nodes = True
    bsdf = sweep_mat.node_tree.nodes['Principled BSDF']
    # Neutral warm off-white sweep
    bsdf.inputs['Base Color'].default_value = (0.83, 0.82, 0.8, 1.0)
    bsdf.inputs['Roughness'].default_value = 0.62
    sweep.data.materials.append(sweep_mat)

def setup_camera():
    cam_data = bpy.data.cameras.new("HeroCamera")
    cam_obj = bpy.data.objects.new("HeroCamera", cam_data)
    bpy.context.collection.objects.link(cam_obj)

    # Placing camera near boot-top height, beautiful 3-quarter view
    cam_obj.location = (2.2, -2.4, 1.35)

    track_to = cam_obj.constraints.new(type='TRACK_TO')
    target = bpy.data.objects.new("CamTarget", None)
    target.location = (0.0, 0.1, 0.7)
    bpy.context.collection.objects.link(target)

    track_to.target = target
    track_to.track_axis = 'TRACK_NEGATIVE_Z'
    track_to.up_axis = 'UP_Y'

    cam_data.lens = 85.0  # Premium product photograph lens
    bpy.context.scene.camera = cam_obj

def setup_lighting():
    # Large soft main key light raking creases beautifully
    bpy.ops.object.light_add(type='AREA', radius=1.6, location=(-2.2, -1.8, 2.4))
    key = bpy.context.active_object
    key.data.energy = 240.0
    key.data.color = (1.0, 0.96, 0.9)

    # Soft ambient fill safeguarding shadow details
    bpy.ops.object.light_add(type='AREA', radius=2.5, location=(2.6, -1.2, 1.4))
    fill = bpy.context.active_object
    fill.data.energy = 60.0
    fill.data.color = (0.92, 0.95, 1.0)

    # Subtle silhouette rim popping shape from sweep background
    bpy.ops.object.light_add(type='SPOT', location=(1.0, 3.2, 1.8))
    rim = bpy.context.active_object
    rim.data.energy = 140.0
    rim.data.spot_size = 0.72
    rim.data.spot_blend = 1.0

    track_to = rim.constraints.new(type='TRACK_TO')
    track_to.target = bpy.data.objects["CamTarget"]
    track_to.track_axis = 'TRACK_NEGATIVE_Z'
    track_to.up_axis = 'UP_Y'

def main():
    reset_scene()
    set_render_settings()

    # 1. Build sole assembly
    sole_obj, heel_obj = create_boot_sole()
    sole_mat = create_sole_material()
    sole_obj.data.materials.append(sole_mat)
    heel_obj.data.materials.append(sole_mat)

    # 2. Build boot upper body
    upper = build_boot_upper()

    # 3. Build boot tongue
    tongue = create_boot_tongue()
    tongue.data.materials.append(upper.data.materials[0])

    # 4. Detail overlays
    place_welt_stitching()
    left_ey, right_ey = place_eyelets()
    place_laces(left_ey, right_ey)
    place_heel_pull()

    # 5. Core Scene setups
    create_studio_sweep()
    setup_camera()
    setup_lighting()

    # Move entire boot slightly off-angle for asymmetrical product placement look
    boot_parent = bpy.data.objects.new("BootParent", None)
    bpy.context.collection.objects.link(boot_parent)
    boot_parent.location = (0, 0, 0)
    boot_parent.rotation_euler = (0, 0, 0.15)  # minor tilt

    for obj in bpy.context.scene.objects:
        if obj.name in ["BootUpper", "BootTongue", "BootSole", "HeelBlock", "Laces", "HeelPull", "PlasticAglet", "FrayedTip"] or "EyeletMaster" in obj.name or "StitchMaster" in obj.name:
            obj.parent = boot_parent

if __name__ == "__main__":
    main()
```