Vol. 1 · No. 338Blender 3.6 / 4.2 / 4.5 / 5.0 / 5.2 / 5.3Cycles · EEVEE
JANCTION
Render · Blender on RTX PRO 6000 · Tokyo
0.1 JPYper GPU-secondFirst 100 JPYfree, no card

Case No. 14  Abstract

Hundreds of scattered spheres at f/2.0

A seeded random scatter, five colours and a range of sizes. Rerun it and get the same image.

● Abstract · CyclesRTX PRO 6000 · Tokyo
Hundreds of scattered spheres with shallow depth of field
Cycles1920 × 1080Samples 128PNG still
Fig. — Hundreds of scattered spheres with shallow depth of field. A real render from the production GPU.
The short answer

This abstract still of hundreds of matte spheres scattered in a box was rendered on a JANCTION GPU with shallow depth of field at f/2.0. The scatter uses a fixed random seed, so every render of the script produces the same layout. It took 14.0 GPU seconds on the production GPU, 1.4 JPY at 0.1 JPY per GPU-second.

What is in the frame

Pastel spheres of different sizes filling the frame, sharp in the middle and soft at the front and back. It is a common style for key visuals and wallpapers.

How the scene is built

A fixed seed makes the scatter deterministic, so the preview and the final show exactly the same arrangement. Five colours and a size range are the only parameters.

Adapt it

Change the seed for a new arrangement or the palette for a new brand. The deterministic seed matters when an agent iterates: it changes one thing at a time and the rest stays put.

1.4 JPY for this render. The free welcome credit of a new key covers about 71 of them, with no card.

Render this example with your AI

ChatGPT · Claude · Grok · Perplexity

Use JANCTION Render (MCP server https://render.janction.jp/mcp) to render this example: render_preview(scene_url="https://render.janction.jp/samples/ex14_scatter_spheres.py"). Then suggest how to change the colors, shapes and camera for my own subject. Ask me before the final render.

Each link opens the app with the text below filled in (if it is not, copy and paste it). If JANCTION Render is not connected in that app yet, add https://render.janction.jp/mcp as a connector first.

Blender warnings

  • environment preset 'studio' replaced the scene's world (HDRI lighting)

The script (bpy, runs as is)

ex14_scatter_spheres.py. It builds the scene, the camera and the frame range; resolution, samples, denoising and the GPU are set by the service.

"""JANCTION Render example 14: hundreds of matte spheres scattered in a box with shallow depth of field (one still).

Reproduce: render_final(scene_url="https://render.janction.jp/samples/ex14_scatter_spheres.py",
                        width=1920, height=1080, samples=128, environment="studio")
A deterministic random scatter (fixed seed), five colours, sizes drawn from a range, camera at f/2.0.
"""
import math
import random

import bpy
from mathutils import Vector

for ob in list(bpy.data.objects):
    bpy.data.objects.remove(ob, do_unlink=True)
scene = bpy.context.scene
scene.frame_start = 1
scene.frame_end = 1
scene.render.fps = 24
random.seed(14)


def material(name, color, roughness=0.5, metallic=0.0, **inputs):
    mat = bpy.data.materials.new(name)
    mat.use_nodes = True
    bsdf = mat.node_tree.nodes["Principled BSDF"]
    bsdf.inputs["Base Color"].default_value = (*color, 1.0)
    bsdf.inputs["Roughness"].default_value = roughness
    bsdf.inputs["Metallic"].default_value = metallic
    for key, value in inputs.items():
        bsdf.inputs[key].default_value = value
    return mat


def smooth(ob):
    for p in ob.data.polygons:
        p.use_smooth = True
    return ob


def add(op, name, mat=None, **kw):
    getattr(bpy.ops.mesh, op)(**kw)
    ob = bpy.context.object
    ob.name = name
    if mat is not None:
        ob.data.materials.append(mat)
    return ob


def text(body, name, mat, location, size=1.0, extrude=0.02, rotation=(math.pi / 2, 0, 0), align="CENTER"):
    cu = bpy.data.curves.new(name, type="FONT")
    cu.body = body
    cu.size = size
    cu.extrude = extrude
    cu.align_x = align
    ob = bpy.data.objects.new(name, cu)
    scene.collection.objects.link(ob)
    ob.location = location
    ob.rotation_euler = rotation
    ob.data.materials.append(mat)
    return ob


def look_at(ob, target):
    ob.rotation_euler = (Vector(target) - ob.location).to_track_quat("-Z", "Y").to_euler()


def camera(location, target, lens=50.0, name="Camera", active=True, fstop=None, focus=None):
    data = bpy.data.cameras.new(name)
    data.lens = lens
    if fstop is not None:
        data.dof.use_dof = True
        data.dof.aperture_fstop = fstop
        data.dof.focus_distance = focus if focus is not None else (Vector(target) - Vector(location)).length
    cam = bpy.data.objects.new(name, data)
    scene.collection.objects.link(cam)
    cam.location = location
    look_at(cam, target)
    if active:
        scene.camera = cam
    return cam


def light(name, kind, location, energy, target=None, size=1.0, color=(1.0, 1.0, 1.0)):
    data = bpy.data.lights.new(name, kind)
    data.energy = energy
    data.color = color
    if kind == "AREA":
        data.size = size
    ob = bpy.data.objects.new(name, data)
    scene.collection.objects.link(ob)
    ob.location = location
    if target is not None:
        look_at(ob, target)
    return ob


def world(color=(0.02, 0.02, 0.03), strength=1.0):
    w = bpy.data.worlds.new("World")
    w.use_nodes = True
    bg = w.node_tree.nodes["Background"]
    bg.inputs[0].default_value = (*color, 1.0)
    bg.inputs[1].default_value = strength
    scene.world = w
    return w

palette = [(0.95, 0.3, 0.25), (0.98, 0.75, 0.2), (0.25, 0.6, 0.95), (0.3, 0.8, 0.5), (0.95, 0.95, 0.92)]
mats = [material(f"Col{i}", c, roughness=0.55) for i, c in enumerate(palette)]
floor = material("Floor", (0.85, 0.85, 0.83), roughness=0.4)
add("primitive_plane_add", "Floor", floor, size=40)
placed = []
tries = 0
while len(placed) < 320 and tries < 5000:
    tries += 1
    r = 0.12 + random.random() ** 2 * 0.5
    p = Vector((random.uniform(-6, 6), random.uniform(-3, 9), r + random.random() * 2.2))
    if all((p - q).length > r + rq + 0.02 for q, rq in placed):
        placed.append((p, r))
for i, (p, r) in enumerate(placed):
    s = add("primitive_ico_sphere_add", f"Sphere{i}", random.choice(mats), radius=r, subdivisions=3, location=p)
    smooth(s)
camera((0.0, -9.5, 2.6), (0.0, 0.5, 1.0), lens=50, fstop=2.0, focus=9.0)

Questions about this case

Why use a fixed random seed in a Blender script?

So the preview and the final render show the same layout, and a change you make is the only thing that differs between runs.

Does a preview cost money?

Previews use the welcome credit first, then stay free up to 2 GPU-minutes per key per day.

More from the Journal