| name | blender-pipeline |
| description | Blender 헤드리스 게임 에셋 파이프라인. 3D 모델 제작/가공/변환/렌더링을 Blender Python API(bpy)로 자동화.
트리거: 3D 모델링, 에셋 변환, 스프라이트 시트, 리깅, Mixamo, FBX/glTF 변환, 프로시저럴 에셋 생성 관련 요청.
|
Blender Headless Game Asset Pipeline
게임 개발에 필요한 3D 에셋 제작/가공을 Blender Python API(bpy)로 자동화하는 스킬.
설치
Linux (MiniPC / 서버)
sudo snap install blender --classic
sudo apt install blender
wget https://download.blender.org/release/Blender4.4/blender-4.4.0-linux-x64.tar.xz
tar xf blender-4.4.0-linux-x64.tar.xz
sudo ln -s $(pwd)/blender-4.4.0-linux-x64/blender /usr/local/bin/blender
macOS
brew install --cask blender
설치 확인
blender --version
blender -b --python-expr "import bpy; print('bpy OK:', bpy.app.version_string)"
헤드리스 실행 패턴
기본 구조
blender -b --python script.py
blender -b scene.blend --python script.py
blender -b --python script.py -- --arg1 value1 --arg2 value2
blender --factory-startup -b --python script.py
blender -b --addons "rigify,io_scene_gltf2" --python script.py
인자 순서 중요!
blender -b scene.blend -o /tmp/output -F PNG -f 1
blender -b -o /tmp/output scene.blend -f 1
GPU 렌더링 (headless)
import bpy
prefs = bpy.context.preferences.addons['cycles'].preferences
prefs.compute_device_type = 'CUDA'
prefs.get_devices()
for device in prefs.devices:
device.use = True
bpy.context.scene.cycles.device = 'GPU'
blender -b scene.blend -E CYCLES -P gpu_setup.py -f 1 -- --cycles-device CUDA
스크립트 사용법
1. 포맷 변환 (convert_format.py)
blender -b --python scripts/convert_format.py -- \
--input model.fbx --output model.glb --format GLB
blender -b --python scripts/convert_format.py -- \
--input model.obj --output model.fbx --format FBX
blender -b --python scripts/convert_format.py -- \
--input model.gltf --output model.obj --format OBJ
blender -b --python scripts/convert_format.py -- \
--input-dir ./models/ --output-dir ./converted/ \
--input-ext .fbx --format GLB
2. 스프라이트 시트 렌더링 (render_sprite_sheet.py)
blender -b character.blend --python scripts/render_sprite_sheet.py -- \
--angles 8 --size 128 --output sprites/character.png
blender -b character.blend --python scripts/render_sprite_sheet.py -- \
--angles 8 --size 256 --camera-angle 30 --output sprites/iso_char.png
blender -b character.blend --python scripts/render_sprite_sheet.py -- \
--angles 4 --size 64 --animated --output sprites/anim_sheet.png
3. 프로시저럴 소품 생성 (procedural_props.py)
blender -b --python scripts/procedural_props.py -- \
--type tree --style low-poly --seed 42 --output props/tree.glb
blender -b --python scripts/procedural_props.py -- \
--type rock --style low-poly --count 5 --output props/rocks.glb
blender -b --python scripts/procedural_props.py -- \
--type crate --style wooden --output props/crate.glb
blender -b --python scripts/procedural_props.py -- \
--type building --floors 3 --style medieval --output props/building.glb
4. 간단한 리깅 (simple_rig.py)
blender -b character.blend --python scripts/simple_rig.py -- \
--target CharacterMesh --type rigify --output rigged_character.blend
blender -b character.blend --python scripts/simple_rig.py -- \
--target CharacterMesh --type simple --bones spine,arm_l,arm_r,leg_l,leg_r \
--output rigged_simple.blend
5. Mixamo 임포트 (mixamo_import.py)
blender -b --python scripts/mixamo_import.py -- \
--input mixamo_character.fbx --output character.glb --fix-scale --fix-rotation
blender -b --python scripts/mixamo_import.py -- \
--input-dir ./mixamo_anims/ --merge-animations \
--output character_animated.glb
blender -b --python scripts/mixamo_import.py -- \
--input-dir ./mixamo_anims/ --nla-tracks \
--output character_nla.blend
워크플로우
워크플로우 1: Mixamo → Blender → 게임엔진
1. Mixamo에서 캐릭터 리깅 + 애니메이션 다운로드 (FBX)
2. mixamo_import.py로 Blender에 임포트 (스케일/회전 보정)
3. 필요시 애니메이션 NLA 트랙 정리
4. convert_format.py로 glTF/GLB 변환
5. 게임엔진(Godot/Unity)에서 임포트
워크플로우 2: 프로시저럴 에셋 → 스프라이트 시트
1. procedural_props.py로 3D 에셋 생성
2. 또는 기존 .blend 파일의 모델 사용
3. render_sprite_sheet.py로 다방향 스프라이트 시트 생성
4. 2D 게임에서 스프라이트 시트 사용
워크플로우 3: 에셋 배치 파이프라인
#!/bin/bash
INPUT_DIR="./raw_models"
OUTPUT_DIR="./game_assets"
blender -b --python scripts/convert_format.py -- \
--input-dir "$INPUT_DIR" --output-dir "$OUTPUT_DIR/models" \
--input-ext .fbx --format GLB
for blend in "$OUTPUT_DIR"/models/*.glb; do
name=$(basename "$blend" .glb)
blender -b --python scripts/render_sprite_sheet.py -- \
--import "$blend" --angles 8 --size 128 \
--output "$OUTPUT_DIR/sprites/${name}_sheet.png"
done
MiniPC에서 실행 (nodes.run)
Clawdbot에서 MiniPC로 실행
# nodes.run으로 Blender 스크립트 실행
nodes.run(node="MiniPC", command=[
"blender", "-b", "--factory-startup",
"--python", "/path/to/script.py",
"--", "--arg1", "value1"
])
MiniPC에 Blender 설치
sudo snap install blender --classic
wget https://download.blender.org/release/Blender4.4/blender-4.4.0-linux-x64.tar.xz
tar xf blender-4.4.0-linux-x64.tar.xz
echo 'export PATH="$HOME/blender-4.4.0-linux-x64:$PATH"' >> ~/.bashrc
파일 전송
cd /output/dir && python3 -m http.server 9877
curl -O http://<MINIPC_IP>:9877/output_file.glb
제한사항 / 주의사항
렌더링 엔진
| 엔진 | Headless 지원 | GPU 필요 | 비고 |
|---|
| Cycles | ✅ 완전 지원 | 선택 | CPU/GPU 모두 가능. 기본 선택. |
| EEVEE | ⚠️ Linux만 | 필수 | Linux 3.4+ GPU 필수. macOS/Windows headless 불가. |
| Workbench | ⚠️ Linux만 | 필수 | EEVEE와 같은 제한. |
알려진 제한
성능 팁
--factory-startup: 불필요한 사용자 설정 로드 방지
--threads N: CPU 스레드 수 지정 (0 = 전체)
- 로우폴리 에셋은 Cycles보다 Workbench가 빠름
- 배치 작업은 xargs/parallel로 병렬화 가능
레퍼런스