[AI Collaboration] Learning English through AI-Driven 3D Modeling: Procedural Zebra Patterns

Learning English through AI-Driven 3D Modeling: Procedural Zebra Patterns

The Story

Capturing the striking contrast of a zebra's coat in 3D requires more than just simple shapes; it demands procedural logic. By analyzing the reference photo, Gemini developed a Python script that uses mathematical wave textures to simulate stripes across a series of scaled spheres. This approach provides a practical way to master technical English terms while constructing a complex, recognizable animal model in Blender.

Zebra Reference

Reference Image

Zebra 3D Model

3D Model Render


AI's Explanation

  1. Procedural Texturing: "To generate the stripes, I utilized a wave texture node combined with a color ramp, allowing for dynamic control over the stripe frequency and sharpness."
  2. Coordinate Mapping: "I connected a mapping node to the texture coordinates. This ensures the stripes flow consistently across the body, neck, and legs by adjusting the vector scales."
  3. Data-Driven Construction: "Instead of manual placement, I iterated through a structured dataset containing the location, scale, and rotation for each body part, such as the muzzle and hooves."

Key Words and Phrases

wave texture

A mathematical pattern generator in 3D software that creates repeating bands or rings, ideal for zebra stripes.

Context: "I utilized a wave texture node to generate the stripes."

mapping

The process of determining how a 2D texture or pattern is wrapped around a 3D object's surface.

Context: "I connected a mapping node to the texture coordinates."

iterate

To perform a process repeatedly; in this script, it refers to processing each part in a list to build the entire animal.

Context: "I iterated through a structured dataset containing the location and scale for each body part."

Script Preview

Copy and paste the code below into Blender's Text Editor to generate your own 3D zebra.

Python
import bpy
import math

def update_zebra_soft_toy_with_eyes():
    # Delete all existing objects
    bpy.ops.object.select_all(action='SELECT')
    bpy.ops.object.delete()

    # 1. Material Setup (Stripes)
    mat_stripes = bpy.data.materials.new(name="Zebra_Stripes")
    mat_stripes.use_nodes = True
    nodes = mat_stripes.node_tree.nodes
    links = mat_stripes.node_tree.links
    nodes.clear()

    tex_coord = nodes.new('ShaderNodeTexCoord')
    mapping = nodes.new('ShaderNodeMapping')
    wave = nodes.new('ShaderNodeTexWave') 
    ramp = nodes.new('ShaderNodeValToRGB')
    bsdf = nodes.new('ShaderNodeBsdfPrincipled')
    output = nodes.new('ShaderNodeOutputMaterial')

    wave.wave_type = 'BANDS'
    wave.bands_direction = 'Z'
    wave.inputs['Scale'].default_value = 5.0
    wave.inputs['Distortion'].default_value = 12.0
    
    ramp.color_ramp.elements[0].position = 0.48
    ramp.color_ramp.elements[0].color = (0, 0, 0, 1)
    ramp.color_ramp.elements[1].position = 0.52
    ramp.color_ramp.elements[1].color = (0.95, 0.95, 0.85, 1)

    links.new(tex_coord.outputs['Generated'], mapping.inputs['Vector'])
    links.new(mapping.outputs['Vector'], wave.inputs['Vector'])
    links.new(wave.outputs['Color'], ramp.inputs['Fac'])
    links.new(ramp.outputs['Color'], bsdf.inputs['Base Color'])
    links.new(bsdf.outputs['BSDF'], output.inputs['Surface'])

    # 2. Material Setup (Matte Black: Muzzle, Hooves)
    mat_black = bpy.data.materials.new(name="Zebra_Black")
    mat_black.use_nodes = True
    bsdf_black = mat_black.node_tree.nodes["Principled BSDF"]
    bsdf_black.inputs['Base Color'].default_value = (0.02, 0.02, 0.02, 1)
    bsdf_black.inputs['Roughness'].default_value = 0.9

    # 3. Material Setup (Glossy Black: Eyes)
    mat_eyes = bpy.data.materials.new(name="Zebra_Eyes")
    mat_eyes.use_nodes = True
    bsdf_eyes = mat_eyes.node_tree.nodes["Principled BSDF"]
    bsdf_eyes.inputs['Base Color'].default_value = (0, 0, 0, 1)
    bsdf_eyes.inputs['Roughness'].default_value = 0.1

    # Dataset for body parts
    body_parts = [
        ("Body", (0, 0, 1.2), (1.1, 1.6, 1.0), (0, 0, 0), mat_stripes),
        ("Neck", (0, 1.4, 2.1), (0.45, 0.7, 1.1), (math.radians(-25), 0, 0), mat_stripes),
        ("Head", (0, 2.1, 2.8), (0.35, 0.7, 0.45), (math.radians(-15), 0, 0), mat_stripes),
        ("Muzzle", (0, 2.65, 2.65), (0.22, 0.28, 0.28), (math.radians(-15), 0, 0), mat_black),
        ("Leg_FR", (0.5, 1.1, 0.6), (0.15, 0.15, 1.1), (0, 0, 0), mat_stripes),
        ("Leg_FL", (-0.5, 1.1, 0.6), (0.15, 0.15, 1.1), (0, 0, 0), mat_stripes),
        ("Leg_BR", (0.5, -1.0, 0.6), (0.18, 0.18, 1.1), (0, 0, 0), mat_stripes),
        ("Leg_BL", (-0.5, -1.0, 0.6), (0.18, 0.18, 1.1), (0, 0, 0), mat_stripes),
        ("Hoof_FR", (0.5, 1.1, -0.4), (0.18, 0.18, 0.15), (0, 0, 0), mat_black),
        ("Hoof_FL", (-0.5, 1.1, -0.4), (0.18, 0.18, 0.15), (0, 0, 0), mat_black),
        ("Hoof_BR", (0.5, -1.0, -0.4), (0.21, 0.21, 0.15), (0, 0, 0), mat_black),
        ("Hoof_BL", (-0.5, -1.0, -0.4), (0.21, 0.21, 0.15), (0, 0, 0), mat_black),
        ("Tail", (0, -1.65, 0.9), (0.04, 0.04, 0.6), (math.radians(-15), 0, 0), mat_stripes),
        ("Ear_R", (0.2, 2.0, 3.2), (0.1, 0.05, 0.25), (math.radians(-20), 0, 0), mat_stripes),
        ("Ear_L", (-0.2, 2.0, 3.2), (0.1, 0.05, 0.25), (math.radians(-20), 0, 0), mat_stripes),
        ("Mane", (0, 1.5, 2.75), (0.05, 0.5, 1.0), (math.radians(-55), 0, 0), mat_stripes),
        ("Eye_R", (0.3, 2.3, 2.9), (0.05, 0.05, 0.05), (0, 0, 0), mat_eyes),
        ("Eye_L", (-0.3, 2.3, 2.9), (0.05, 0.05, 0.05), (0, 0, 0), mat_eyes)
    ]

    for name, pos, sc, rot, m in body_parts:
        bpy.ops.mesh.primitive_uv_sphere_add(radius=1.0, location=pos)
        obj = bpy.context.active_object
        obj.name = name
        obj.scale = sc
        obj.rotation_euler = rot
        obj.data.materials.append(m)
        bpy.ops.object.shade_smooth()

update_zebra_soft_toy_with_eyes()

Comments

Popular posts from this blog

シャキシャキ美味しい!スナップエンドウ、英語でどう言う?

[AI & Seasonal English]: 半夏生編 -「半夏生」で日本の美しい暦と英語を学ぼう!

[AI & Seasonal English] 【スパイス香る】ドイツのクリスマスパン「シュトーレン(Stollen)」の歴史と「しっとり感」を語る英語