-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmulti_camera_render.py
More file actions
101 lines (75 loc) · 3.42 KB
/
Copy pathmulti_camera_render.py
File metadata and controls
101 lines (75 loc) · 3.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
"""DAZ Studio Script Server example: render from every camera in the scene in one pass.
PURPOSE
-------
This script is a demonstration of what the DAZ Studio Script Server makes
possible. It iterates all cameras in the live DAZ Studio scene and renders
from each one in turn, saving the output as <camera_label>.png in a chosen
directory.
It is an *example*, not a production multi-pass render manager. A full
pipeline would also handle render layers, lighting rigs per camera, and
output EXR compositing. The goal here is to show that Python can enumerate
scene cameras and drive the render engine to cover multiple angles in a
single script run — useful for storyboarding, product shots, or coverage
renders.
WHAT IT DEMONSTRATES
--------------------
- Listing all cameras in the live scene (DazScene.cameras)
- Filtering cameras by label via --cameras
- Setting render resolution and triggering a render for each camera
- Sanitising camera labels into safe filenames for output
ENVIRONMENT SETUP
-----------------
1. DAZ Studio must be running with the DazScriptServer plugin loaded and its
HTTP server active (default: 127.0.0.1:18811). You can verify it is
responding with:
curl http://127.0.0.1:18811/health
2. Install the Python dependencies in a virtual environment:
python -m venv .venv
.venv\\Scripts\\activate # Windows
# source .venv/bin/activate # macOS / Linux
pip install requests
3. Install or develop-install the dazpy SDK (from the repo root):
pip install -e .
4. Open a scene in DAZ Studio with one or more cameras, then run:
python docs/examples/rendering/multi_camera_render.py
Usage:
python multi_camera_render.py
python multi_camera_render.py --out C:/renders --width 1920 --height 1080
python multi_camera_render.py --cameras "Front" "Side" "Hero Shot"
"""
import argparse
import os
import re
from dazpy import DazScene, DazRenderSettings
def safe_filename(label: str) -> str:
return re.sub(r'[^\w\-]', '_', label).strip('_') or "camera"
if __name__ == "__main__":
parser = argparse.ArgumentParser(
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
)
parser.add_argument("--out", default="y:/tmp/multicam", help="Output directory")
parser.add_argument("--width", type=int, default=1920)
parser.add_argument("--height", type=int, default=1080)
parser.add_argument("--cameras", nargs="+", metavar="LABEL",
help="Render only these cameras (by label). Default: all cameras.")
args = parser.parse_args()
os.makedirs(args.out, exist_ok=True)
scene = DazScene()
render = DazRenderSettings()
cameras = scene.cameras()
if not cameras:
raise SystemExit("No cameras found in the scene.")
if args.cameras:
cameras = [c for c in cameras if c.label in args.cameras]
if not cameras:
raise SystemExit(f"None of the specified cameras found. Available: "
f"{[c.label for c in scene.cameras()]}")
render.set_resolution(args.width, args.height)
print(f"Rendering {len(cameras)} camera(s) → {args.out}")
for cam in cameras:
label = cam.label or cam.name
out_path = os.path.join(args.out, f"{safe_filename(label)}.png")
render.output_path = out_path
render.render(camera_name=cam.name)
print(f" {label} → {out_path}")
print("Done.")