A rigged character that renders overnight with no human in the loop sounds like a flex. Mostly it is a series of small, boring failures that only show up when nobody is watching the viewport: a black material, a walk cycle that plays 25% too fast, a pose that silently collapses because one vertex group is empty.

This is the pipeline I run for a small character line — five scripts, one command each, blender -b from start to finish. Then the four things that keep breaking it, with the code I actually use to keep them from breaking.

The five stages

# Stage Script What it guarantees
1 Prep 02_prep_mesh.py one mesh, origin at the hip, shoulders dense enough to deform
2 Rig + skin 03_rig_skin.py armature built from proportions, zero unweighted vertices
3 Action 04_action_test.py a 49-frame test action at a known fps, baked into the FBX
4 QC render (same script) 5 key-pose stills, headless, so I can see it without Blender open
5 Package 05_package.py .blend + animated FBX + previews in one folder

Every stage prints machine-readable QC lines and exits non-zero when a check fails, so the whole thing can run from cron or CI and I only read the log when something is red.

blender -b --python scripts/blender/02_prep_mesh.py -- --char-id char_001 --target-height 1.75 blender -b --python scripts/blender/03_rig_skin.py -- --char-id char_001 blender -b --python scripts/blender/04_action_test.py -- --char-id char_001 blender -b --python scripts/blender/05_package.py -- --char-id char_001 

Stage 1 — prep: put the origin where the rig expects it

The single most useful thing I do before rigging is move the object origin to the hip line (52% of height) and translate the vertices to compensate. Every later stage — bone placement, root motion, the test action — assumes that origin, and fixing it after rigging means redoing weights.

I also subdivide a sphere around each shoulder so the mesh has something to bend. On an AI-generated base mesh the shoulders are often 4–6 faces wide, which is fine for a static render and terrible for a punch.

import bpy, bmesh from mathutils import Vector HIP_RATIO = 0.52 height = 1.75 hip_z = HIP_RATIO * height mesh_obj = next(o for o in bpy.data.objects if o.type == "MESH") bm = bmesh.new() bm.from_mesh(mesh_obj.data) bmesh.ops.translate(bm, vec=(0.0, 0.0, -hip_z), verts=bm.verts[:]) bm.to_mesh(mesh_obj.data) mesh_obj.location = (0.0, 0.0, hip_z) # origin sits on the hip line 

Stage 2 — skinning: "unweighted vertices" is a number, not a mystery

Automatic weights leave holes. A hole is a vertex with no group, or with a group whose weight is 0. Those vertices stay behind when the mesh moves, and in a headless render you find out three hours later.

So the rig script does not trust automatic weights at all: it builds the armature from proportions, then for every vertex with no weight it finds the nearest deform bone segment and assigns 1.0 to it. After that it limits to 4 influences and renormalises.

def assign_unweighted_vertices(mesh, bone_segments, deform_ids): for v in mesh.data.vertices: has_weight = any( g.group in deform_ids and g.weight > 1e-8 for g in v.groups ) if has_weight: continue best = min(bone_segments, key=lambda s: point_segment_distance(v.co, *s[1])) mesh.vertex_groups[best[0]].add([v.index], 1.0, "REPLACE") 

After that pass the QC line reads QC unweighted_verts=0 max_influences=4. If the number is not 0, the run fails. That one line has saved me more broken renders than any amount of staring at the viewport.

Stage 3 — the action: set fps before you key anything

Frame rate is a scene property, and it is silent. Set keys at frames 1–49 with the scene at 30 fps and export with bake_anim=True, and you get a clip that is 1.63 s instead of 2 s: the same poses, played 25% fast, with no error anywhere.

My rule: fps = 24, fps_base = 1.0, set before the first keyframe, and written into the run's JSON report so the number travels with the asset.

scene = bpy.context.scene scene.render.fps = 24 scene.render.fps_base = 1.0 # 24.0, not 23.976 scene.frame_start, scene.frame_end = 1, 49 for pb in arm.pose.bones: pb.rotation_mode = "XYZ" # Euler: readable keys, no quaternion flips 

The exporter needs to bake too, or every consumer re-samples the curves differently:

bpy.ops.export_scene.fbx( filepath=out_path, use_selection=False, add_leaf_bones=False, bake_anim=True, bake_anim_use_all_bones=True, bake_anim_force_startend_keying=True, path_mode="COPY", ) 

bake_anim_force_startend_keying=True is the one people forget. Without it the last frame of the hold gets dropped when the curve is flattened, and the clip ends one frame early in Unity but not in Blender.

Stage 4 — QC render: EEVEE needs a GL context it may not have

This is the failure that taught me to stop assuming a workstation. On a headless box with no GPU — a CI container, a VPS, a Windows session with no display — BLENDER_EEVEE_NEXT can fail outright because it wants an OpenGL context, and blender -b does not always provide one.

The fix is not "install a GPU". It is: try EEVEE, and fall back to something that only needs the CPU.

def setup_engine(scene, engine, samples): if engine == "CYCLES": scene.render.engine = "CYCLES" scene.cycles.device = "CPU" # no GPU required scene.cycles.samples = samples scene.cycles.use_denoising = True elif engine == "WORKBENCH": scene.render.engine = "BLENDER_WORKBENCH" scene.display.shading.light = "STUDIO" else: for engine_id in ("BLENDER_EEVEE_NEXT", "BLENDER_EEVEE"): try: scene.render.engine = engine_id break except TypeError: continue 

That loop matters on 4.0/4.1 too: the engine id changed from BLENDER_EEVEE to BLENDER_EEVEE_NEXT in 4.2, and assigning the wrong one raises TypeError — not a warning. Two engine ids, one try/except, and the same script runs on 3.6 through 4.5.

I render 800×1000 stills of the five key poses. Not for the client — for me: it is the only way to see that a hand went through a hip without opening the UI.

Stage 5 — package: prove the export, don't trust it

The last stage writes .blend, an animated FBX, and the previews, then re-imports the FBX into an empty scene and asserts three things: one armature, the expected bone count, and an action with a non-zero frame range.

bpy.ops.wm.read_factory_settings(use_empty=True) bpy.ops.import_scene.fbx(filepath=fbx_out) arm = next(o for o in bpy.data.objects if o.type == "ARMATURE") assert len(arm.data.bones) == expected_bones, f"bones={len(arm.data.bones)}" assert arm.animation_data and arm.animation_data.action, "no action survived export" print("QC reimport ok bones=%d action=%s" % (len(arm.data.bones), arm.animation_data.action.name)) 

An FBX that fails re-import is not an asset, it is a file. This check costs about a second and catches wrong bone hierarchies, dropped actions, and exports that silently wrote 0 bytes.

The four things that break

1. EEVEE with no GL context. Covered above: try both engine ids, fall back to Cycles CPU or Workbench. Workbench is ugly but it renders on anything.

2. Frame rate drift on baked actions. scene.render.fps + fps_base set before keying, bake_anim_force_startend_keying=True on export, and assert on the re-imported action's frame range. Otherwise the data is fine and the timing is wrong — the worst kind of bug, because nothing errors.

3. Relative texture paths. An FBX stores //Textures/Skin_basecolor.png, and Blender resolves // against the current .blend, not against the FBX you just imported. Run your script from a different directory and every material renders black — no warning, no missing-file dialog in batch mode. Resolve to an absolute path immediately after import, then disable relative paths before saving:

from pathlib import Path import bpy src_dir = Path(r"D:/project/char_001/source") for img in bpy.data.images: if img.source != "FILE" or not img.filepath: continue p = Path(img.filepath) if p.name and (src_dir / p.name).exists(): # flat texture folder p = src_dir / p.name img.filepath = str(p.resolve()) img.reload() # fail loudly if it's gone bpy.context.preferences.filepaths.use_relative_paths = False 

If a texture really is missing, img.reload() raises and the run stops — which is what you want, because the alternative is a black render that looks like a lighting problem.

4. 512×512 textures on a 4K screen. This one is a product decision, not a bug. A 512² map wrapped around a full body means every screen pixel is magnifying the texture. In a 1080×1920 vertical clip the character is maybe 900 px tall, so you get ~1.8 screen pixels per texel — 2× magnification, and after video compression on a phone nobody can tell. In a full-body 4K still the character is ~2000 px tall, so the same map is stretched ~4× per axis: soft eyes, blurry fabric, visible UV seams at the seams and around the eyes.

I keep two export profiles in the pipeline: social (1024², EEVEE, 800×1000 previews) and closeup (2048–4096², Cycles CPU, 1600×2000 previews). Same mesh, same rig, different texture set and render budget. Deciding this once per asset — instead of shipping 4K textures into a 15-second vertical clip — is the difference between a preview pass that finishes while you make coffee and one you schedule overnight.

What I'd check first on a new asset

If you take one thing from this: make every stage assert something a machine can check, and print it. unweighted_verts=0, max_influences=4, fps=24, action range 1-49, reimport bones=<expected>. A pipeline that only "works" because you looked at the render is not a pipeline, it's a habit.

If you want the version of these scripts that already handles the argument parsing, JSON reports and exit codes: I packaged the five audit/render/export scripts I use — rename & normalise, mesh audit, weight audit, preview renders, normalised FBX export — plus a demo .blend with deliberate defects and the full transcript of every command, as a $19 download: Blender Headless Pipeline. Everything in this post is enough to build your own; the pack just saves you the plumbing.

There's also a free guide on the same store about turning this kind of pipeline into actual work — AI, jobs and the 3D pipeline.