Scene Generated
This commit is contained in:
@@ -15,6 +15,18 @@ from mathutils import Matrix
|
||||
ROBOT_JSON_FILE = r"C:\Users\kech\SynologyDrive\2026-AppServer-AppRobot\appRobotRendering\data\robot\robot.json"
|
||||
OUTPUT_FILE = r"C:\Users\kech\SynologyDrive\2026-AppServer-AppRobot\appRobotRendering\data\simulation\debug\render.png"
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
# Holt dynamisch den Pfad zum aktuellen Benutzerverzeichnis (z.B. C:\Users\Name)
|
||||
USER_HOME = Path.home()
|
||||
|
||||
# Kombiniert den Benutzerpfad mit dem spezifischen Ordnerpfad und konvertiert direkt zu str
|
||||
ROBOT_JSON_FILE = str(USER_HOME / "SynologyDrive" / "2026-AppServer-AppRobot" / "appRobotRendering" / "data" / "robot" / "robot.json")
|
||||
OUTPUT_FILE = str(USER_HOME / "SynologyDrive" / "2026-AppServer-AppRobot" / "appRobotRendering" / "data" / "simulation" / "debug" / "render.png")
|
||||
|
||||
print("Using robot JSON file:", ROBOT_JSON_FILE)
|
||||
print("Using output file:", OUTPUT_FILE)
|
||||
|
||||
# ============================================================
|
||||
# DEFAULT MATERIALS
|
||||
# ============================================================
|
||||
@@ -83,6 +95,8 @@ links_def = robot.get("links", {})
|
||||
if not isinstance(links_def, dict):
|
||||
raise ValueError("robot.json must contain a top-level 'links' object")
|
||||
|
||||
|
||||
|
||||
# ============================================================
|
||||
# HELPERS
|
||||
# ============================================================
|
||||
@@ -345,8 +359,11 @@ bg.inputs[1].default_value = float(rendering_info.get("backgroundStrength", 0.20
|
||||
|
||||
scene.render.engine = "CYCLES"
|
||||
scene.view_settings.exposure = float(rendering_info.get("exposure", -1.5))
|
||||
scene.cycles.samples = 16
|
||||
scene.cycles.samples = 32
|
||||
scene.cycles.preview_samples = 32
|
||||
scene.cycles.use_adaptive_sampling = True
|
||||
scene.cycles.adaptive_threshold = 0.02
|
||||
scene.cycles.use_denoising = True
|
||||
scene.render.resolution_x = RENDER_WIDTH
|
||||
scene.render.resolution_y = RENDER_HEIGHT
|
||||
scene.render.resolution_percentage = 100
|
||||
@@ -931,6 +948,52 @@ create_axis_arrow("AxisX", (1, 0, 0), (1, 0, 0))
|
||||
create_axis_arrow("AxisY", (0, 1, 0), (0, 1, 0))
|
||||
create_axis_arrow("AxisZ", (0, 0, 1), (0, 0, 1))
|
||||
|
||||
|
||||
# ============================================================
|
||||
# AUTO GPU DETECTION (robust, plattformübergreifend)
|
||||
# ============================================================
|
||||
|
||||
def enable_best_device(scene):
|
||||
prefs = bpy.context.preferences
|
||||
cycles_prefs = prefs.addons['cycles'].preferences
|
||||
|
||||
# Prioritäten (schnell → weniger schnell)
|
||||
backends = ['OPTIX', 'CUDA', 'HIP', 'METAL', 'ONEAPI']
|
||||
|
||||
selected_backend = None
|
||||
|
||||
for backend in backends:
|
||||
try:
|
||||
cycles_prefs.compute_device_type = backend
|
||||
cycles_prefs.get_devices()
|
||||
|
||||
devices = cycles_prefs.devices
|
||||
|
||||
# Prüfen, ob eine GPU dabei ist
|
||||
gpu_devices = [d for d in devices if d.type != 'CPU']
|
||||
|
||||
if gpu_devices:
|
||||
selected_backend = backend
|
||||
|
||||
# Aktiviere alle Geräte (GPU + optional CPU fallback)
|
||||
for d in devices:
|
||||
d.use = True
|
||||
|
||||
break
|
||||
except Exception:
|
||||
continue
|
||||
|
||||
if selected_backend:
|
||||
print(f"[Render] Using GPU via {selected_backend}")
|
||||
scene.cycles.device = 'GPU'
|
||||
else:
|
||||
print("[Render] No GPU found, falling back to CPU")
|
||||
scene.cycles.device = 'CPU'
|
||||
|
||||
|
||||
enable_best_device(scene)
|
||||
|
||||
|
||||
# ============================================================
|
||||
# RENDER
|
||||
# ============================================================
|
||||
|
||||
Reference in New Issue
Block a user