Single Server Rendering
This guide demonstrates how to automate multi-camera rendering from a single .blend
file using Blender’s bpy
module on Brender Cloud.
Example Files
- Download Sample File
- Sample Script Code (see below)
Core Script
import bpy
import os
def render_cameras():
# Get output path from environment variable
output_folder = os.getenv('BC_OUTPUT_FOLDER', '/default/output/path')
# Find all cameras in scene
cameras = [obj for obj in bpy.data.objects if obj.type == 'CAMERA']
if not cameras:
print("No cameras found in scene")
return
scene = bpy.context.scene
for camera in cameras:
# Set active camera
scene.camera = camera
# Configure output path
scene.render.filepath = os.path.join(
output_folder,
f"{camera.name}"
)
print(f"Rendering {camera.name} => {scene.render.filepath}")
bpy.ops.render.render(animation=False, write_still=True)
if __name__ == "__main__":
render_cameras()
Key Components Explained
1. Camera Discovery
cameras = [obj for obj in bpy.data.objects if obj.type == 'CAMERA']
Finds all camera objects in the current Blender scene.
2. Output Configuration
scene.render.filepath = os.path.join(output_folder, f"{camera.name}_frame_####")
Uses BC_OUTPUT_FOLDER
environment variable to set render destination paths.
⚠️
Use always BC_OUTPUT_FOLDER for proper path handling. Your render output may be lost if you use a hardcoded path.
3. Render Execution
bpy.ops.render.render(animation=False, write_still=True)
Renders single frame for each camera with final quality settings.
Environment Variables
Default Variables
Variable | Description | Example Usage |
---|---|---|
BC_OUTPUT_FOLDER | The output folder for the current server, where rendered frames and other files are saved. | bpy.context.scene.render.filepath = os.path.join(os.getenv('BC_OUTPUT_FOLDER'), 'frame_####') |
BC_SERVER_INDEX | The index of the current server within a server array; useful for distributing tasks. | Set automatically during execution. |
BC_SERVER_ARRAY_SIZE | Total number of servers in use; this variable is only available when more than one server is active. | Used to coordinate parallel tasks across servers. |
Custom Variables
Add custom key-value pairs via the Add Env button in job configuration:
Variable | Description | Example Usage |
---|---|---|
MY_CUSTOM_VAR | Custom environment variable | os.getenv('MY_CUSTOM_VAR', 'default_value') |
Usage Steps
Upload Script
- Navigate to Scripts Dashboard
- Upload
multi_camera_render.py
Test Script
- Click on script name to access detail view
- Click Test Script to run a test render
- If successful, proceed to job configuration
Configure Job
- Navigate to New Render
- Upload your
.blend
file or.zip
containing.blend
and assets - Select
multi_camera_render.py
from the script dropdown - Choose 1 server for rendering (for multi-server rendering, see Multi-Server Rendering)
Launch Render
- Monitor progress via Render Job Details > Click on job ID cell to view details and logs
Expected Output
# BC_OUTPUT_FOLDER: /app/bc_output/
/app/bc_output/
├── cam_001.png
├── cam_002.png
└── cam_003.png
This script pattern works for 1-10 cameras. For larger quantities (>20 cameras), consider multi-server rendering.
Download Output
- Navigate to Render Job Details > Click on job ID cell
- Click Download to retrieve rendered frames (.zip)
- Zip file contains all frames rendered by the script
Last updated on