Add Blender worlds for Terra, Odyssey and Vortex
pauljd/davidson-ci: Davidson CI / quality (push) Failing after 1m33s
pauljd/davidson-ci: Davidson CI / ai-review (push) Failing after 1m23s

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-11-02 16:38:58 +00:00
co-authored by Claude Opus 5.5
parent 1489ec168a
commit 05475584f7
+141
View File
@@ -215,6 +215,121 @@ def black_hole():
light_ring('halo', 6.15, 11.5, (math.radians(84), 0, 0), 2.4, .4, halo)
return hole, light_ring
def noise_ramp(n, l, source, scale, detail, stops, distortion=0):
noise = n.new('ShaderNodeTexNoise'); noise.inputs['Scale'].default_value = scale; noise.inputs['Detail'].default_value = detail; noise.inputs['Distortion'].default_value = distortion
l.new(source, noise.inputs['Vector'])
r = ramp(n, stops); l.new(noise.outputs['Fac'], r.inputs['Fac'])
return r
def glow_shell(name, radius, colour, strength, blend=.2, power=5):
air = sphere(name, radius)
m, n, l = material(name); out = n['Material Output']; n.remove(n['Principled BSDF'])
fresnel = n.new('ShaderNodeLayerWeight'); fresnel.inputs['Blend'].default_value = blend
raised = n.new('ShaderNodeMath'); raised.operation = 'POWER'; raised.inputs[1].default_value = power
l.new(fresnel.outputs['Facing'], raised.inputs[0])
glow = n.new('ShaderNodeEmission'); glow.inputs['Color'].default_value = hexrgb(colour); glow.inputs['Strength'].default_value = strength
clear = n.new('ShaderNodeBsdfTransparent'); mix = n.new('ShaderNodeMixShader')
l.new(raised.outputs[0], mix.inputs[0]); l.new(clear.outputs[0], mix.inputs[1]); l.new(glow.outputs[0], mix.inputs[2]); l.new(mix.outputs[0], out.inputs['Surface'])
air.data.materials.append(m); air.visible_shadow = False
return air
def earth(radius=10):
"""Oceans, land and ice, a separate moving layer of cloud, and the thin blue edge of the air."""
body = sphere('earth', radius, 192)
m, n, l = material('earth'); bsdf = n['Principled BSDF']
coord = n.new('ShaderNodeTexCoord')
land = noise_ramp(n, l, coord.outputs['Object'], .22, 12, [(.47, '#000000'), (.5, '#FFFFFF')], .4)
surface = noise_ramp(n, l, coord.outputs['Object'], .6, 10, [(.32, '#7A6A3A'), (.46, '#2E6B34'), (.62, '#1E5A2C'), (.72, '#8A7A52')], .3)
ocean = noise_ramp(n, l, coord.outputs['Object'], .5, 6, [(.3, '#04204F'), (.7, '#0A4C86')])
mixed = n.new('ShaderNodeMix'); mixed.data_type = 'RGBA'
l.new(land.outputs['Color'], mixed.inputs[0]); l.new(ocean.outputs['Color'], mixed.inputs[6]); l.new(surface.outputs['Color'], mixed.inputs[7])
sep = n.new('ShaderNodeSeparateXYZ'); l.new(coord.outputs['Object'], sep.inputs[0])
absolute = n.new('ShaderNodeMath'); absolute.operation = 'ABSOLUTE'; l.new(sep.outputs['Z'], absolute.inputs[0])
polar = n.new('ShaderNodeMath'); polar.operation = 'GREATER_THAN'; polar.inputs[1].default_value = radius * .84; l.new(absolute.outputs[0], polar.inputs[0])
iced = n.new('ShaderNodeMix'); iced.data_type = 'RGBA'; l.new(polar.outputs[0], iced.inputs[0]); l.new(mixed.outputs[2], iced.inputs[6]); iced.inputs[7].default_value = hexrgb('#F2F7FF')
l.new(iced.outputs[2], bsdf.inputs['Base Color'])
rough = n.new('ShaderNodeMapRange'); rough.inputs['To Min'].default_value = .5; rough.inputs['To Max'].default_value = .9
l.new(land.outputs['Color'], rough.inputs['Value']); l.new(rough.outputs[0], bsdf.inputs['Roughness'])
body.data.materials.append(m); spin(body, 'z', .03)
clouds = sphere('clouds', radius * 1.012, 192)
m, n, l = material('clouds'); out = n['Material Output']; n.remove(n['Principled BSDF'])
coord = n.new('ShaderNodeTexCoord')
cover = noise_ramp(n, l, coord.outputs['Object'], .75, 14, [(.52, '#000000'), (.66, '#FFFFFF')], .25)
white = n.new('ShaderNodeBsdfDiffuse'); white.inputs['Color'].default_value = (1, 1, 1, 1)
clear = n.new('ShaderNodeBsdfTransparent'); mix = n.new('ShaderNodeMixShader')
l.new(cover.outputs['Color'], mix.inputs[0]); l.new(clear.outputs[0], mix.inputs[1]); l.new(white.outputs[0], mix.inputs[2]); l.new(mix.outputs[0], out.inputs['Surface'])
clouds.data.materials.append(m); spin(clouds, 'z', .045)
glow_shell('air', radius * 1.035, '#4FA8FF', 2.6, .16, 4)
return body
def flare(position, size, colour, strength):
"""The sun itself, a bright sphere the camera can look towards."""
ball = sphere('flare', size, 48); ball.location = position
m, n, l = material('flare'); out = n['Material Output']; n.remove(n['Principled BSDF'])
glow = n.new('ShaderNodeEmission'); glow.inputs['Color'].default_value = hexrgb(colour); glow.inputs['Strength'].default_value = strength
l.new(glow.outputs[0], out.inputs['Surface']); ball.data.materials.append(m); ball.visible_shadow = False
return ball
def moon_ground():
"""A cratered plain the camera skims over, real geometry that catches the low sun."""
bpy.ops.mesh.primitive_grid_add(x_subdivisions=1400, y_subdivisions=1400, size=260, location=(0, 60, 0)); ground = bpy.context.active_object; ground.name = 'ground'
bpy.ops.object.shade_smooth()
rng = random.Random(41)
craters = [(rng.uniform(-120, 120), rng.uniform(-60, 180), rng.uniform(1.5, 12)) for _ in range(180)]
mesh = ground.data
wave = lambda x, y: .9 * math.sin(x * .07 + 1) * math.cos(y * .05) + .35 * math.sin(x * .23 + y * .19) + .12 * math.sin(x * .9 + y * 1.1)
for vertex in mesh.vertices:
x, y = vertex.co.x, vertex.co.y + 60
height = wave(x, y)
for cx, cy, r in craters:
d = math.hypot(x - cx, y - cy)
if d < r * 1.5:
t = d / r
height += -r * .24 * max(0, 1 - t * t) ** 2 + r * .09 * math.exp(-((t - 1) / .22) ** 2)
vertex.co.z = height
mesh.update()
m, n, l = material('regolith'); bsdf = n['Principled BSDF']; bsdf.inputs['Roughness'].default_value = .95
coord = n.new('ShaderNodeTexCoord')
tone = noise_ramp(n, l, coord.outputs['Object'], .5, 12, [(.3, '#3C3E44'), (.7, '#8C8E92')])
bump = n.new('ShaderNodeBump'); bump.inputs['Strength'].default_value = .6
fine = n.new('ShaderNodeTexNoise'); fine.inputs['Scale'].default_value = 6; fine.inputs['Detail'].default_value = 14
l.new(coord.outputs['Object'], fine.inputs['Vector']); l.new(fine.outputs['Fac'], bump.inputs['Height']); l.new(bump.outputs[0], bsdf.inputs['Normal'])
l.new(tone.outputs['Color'], bsdf.inputs['Base Color']); ground.data.materials.append(m)
return ground
def tunnel():
"""Vortex: a real tube of light to fly down, with hoops rushing past, twisting as it goes."""
bpy.ops.mesh.primitive_cylinder_add(vertices=128, radius=16, depth=900, end_fill_type='NOTHING', rotation=(math.pi / 2, 0, 0), location=(0, 380, 0)); tube = bpy.context.active_object; tube.name = 'tube'
bpy.ops.object.shade_smooth()
m, n, l = material('tube'); out = n['Material Output']; n.remove(n['Principled BSDF'])
coord = n.new('ShaderNodeTexCoord'); sep = n.new('ShaderNodeSeparateXYZ'); l.new(coord.outputs['Object'], sep.inputs[0])
angle = n.new('ShaderNodeMath'); angle.operation = 'ARCTAN2'; l.new(sep.outputs['X'], angle.inputs[0]); l.new(sep.outputs['Y'], angle.inputs[1])
cosine = n.new('ShaderNodeMath'); cosine.operation = 'COSINE'; sine = n.new('ShaderNodeMath'); sine.operation = 'SINE'
twist = n.new('ShaderNodeMath'); twist.operation = 'ADD'
along = n.new('ShaderNodeMath'); along.operation = 'MULTIPLY'; along.inputs[1].default_value = .012
l.new(sep.outputs['Z'], along.inputs[0]); l.new(angle.outputs[0], twist.inputs[0]); l.new(along.outputs[0], twist.inputs[1])
l.new(twist.outputs[0], cosine.inputs[0]); l.new(twist.outputs[0], sine.inputs[0])
place = n.new('ShaderNodeCombineXYZ')
for source, slot in ((cosine, 0), (sine, 1)):
wide = n.new('ShaderNodeMath'); wide.operation = 'MULTIPLY'; wide.inputs[1].default_value = 16
l.new(source.outputs[0], wide.inputs[0]); l.new(wide.outputs[0], place.inputs[slot])
length = n.new('ShaderNodeMath'); length.operation = 'MULTIPLY'; length.inputs[1].default_value = .012
l.new(sep.outputs['Z'], length.inputs[0]); l.new(length.outputs[0], place.inputs[2])
streak = noise_ramp(n, l, place.outputs[0], 1, 8, [(.5, '#000000'), (.6, '#0A5CFF'), (.68, '#00C8FF'), (.75, '#8A2BFF'), (.84, '#E8F4FF')])
glow = n.new('ShaderNodeEmission'); l.new(streak.outputs['Color'], glow.inputs['Color']); power = glow.inputs['Strength']
# Dims as the camera slows, so the logo reads over it.
for frame, value in ((1, 1.7), (230, 1.7), (285, .4), (350, .4)):
power.default_value = value; power.keyframe_insert('default_value', frame=frame)
l.new(glow.outputs[0], out.inputs['Surface']); tube.data.materials.append(m)
m, n, l = material('hoop'); bsdf = n['Principled BSDF']; bsdf.inputs['Metallic'].default_value = 1; bsdf.inputs['Roughness'].default_value = .18; bsdf.inputs['Base Color'].default_value = hexrgb('#C9D6EA')
bsdf.inputs['Emission Color'].default_value = hexrgb('#37DFFF'); bsdf.inputs['Emission Strength'].default_value = .25
for i in range(30):
y = 12 + i * 26
bpy.ops.mesh.primitive_torus_add(major_segments=96, minor_segments=12, major_radius=14.5, minor_radius=.3 + (i % 3 == 0) * .22, location=(0, y, 0), rotation=(math.pi / 2, 0, 0)); hoop = bpy.context.active_object
bpy.ops.object.shade_smooth(); hoop.data.materials.append(m)
hoop.scale = (1, 1 - .12 * ((i % 2) * 2 - 1) * .4, 1)
return tube
if SCENE == 'orbit-1':
world_tint = ('#061A3C', '#0E3A6E')
stars_world()
@@ -227,6 +342,32 @@ elif SCENE == 'paradox':
stars_world()
hole, _ = black_hole()
camera_path([(1, (14, -150, 12), (0, 0, 0)), (260, (-19, -66, 8), (-14, 0, 1)), (350, (-19, -66, 8), (-14, 0, 1))], lens=38)
elif SCENE == 'orbit-terra':
world_tint = ('#020612', '#06122A')
stars_world()
# The sun comes up behind the world's edge, as the camera sweeps down to it.
sun((-.75, .62, -.1), 5, '#FFF2DC', 1)
earth()
flare((60, -40, 12), 2.2, '#FFE9C4', 60)
camera_path([(1, (-26, -8, 26), (0, 0, 0)), (260, (-20, -29, 3), (-8.6, 0, 3.2)), (350, (-20, -29, 3), (-8.6, 0, 3.2))], lens=40)
elif SCENE == 'orbit-odyssey':
world_tint = ('#020409', '#050A18')
stars_world()
# Skims a moonscape as the Earth rises over the horizon.
sun((-.8, .35, -.32), 5, '#FFFFFF', 1)
moon_ground()
bpy.ops.object.select_all(action='DESELECT')
planet_body = earth()
for name in ('earth', 'clouds', 'air'):
bpy.data.objects[name].location = (26, 150, 30); bpy.data.objects[name].scale = (1.5, 1.5, 1.5)
camera_path([(1, (-6, -62, 6), (0, 40, 3)), (260, (-2, -20, 7), (3, 60, 17)), (350, (-2, -20, 7), (3, 60, 17))], lens=30)
elif SCENE == 'vortex':
world_tint = ('#020409', '#060A18')
scene.world = bpy.data.worlds.new('dark'); scene.world.use_nodes = True; scene.world.node_tree.nodes['Background'].inputs['Color'].default_value = (0, 0, 0, 1)
tunnel()
sun((.2, 1, -.2), 1.5, '#BFE3FF')
# Fast down the tube, easing to a stop.
camera_path([(1, (0, -60, 0), (0, 200, 0)), (290, (0, 560, 0), (0, 800, 0)), (350, (0, 575, 0), (0, 800, 0))], lens=24)
else:
raise SystemExit('unknown scene')