Skip to content

Commit

Permalink
Add script for automated procgen with Blender
Browse files Browse the repository at this point in the history
Signed-off-by: Andrej Orsula <[email protected]>
  • Loading branch information
AndrejOrsula committed Oct 29, 2024
1 parent afad43d commit 521b0fb
Show file tree
Hide file tree
Showing 3 changed files with 1,317 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ To use a procedural pipeline inside Blender GUI, follow these steps:

#### Generate Assets using Standalone Scripts

Procedural assets can also be generated using standalone scripts that require close integration with Blender's Python API `bpy`. You can either write your own script that performs the steps outlined above or use the [procgen_assets.py](https://github.com/AndrejOrsula/space_robotics_bench/blob/main/scripts/blender/procgen_assets.py) as a starting point.
Procedural assets can also be generated using standalone scripts that require close integration with Blender's Python API `bpy`. You can either write your own script that performs the steps outlined above or use the [`procgen_assets.py`](scripts/blender/procgen_assets.py) as a starting point. This script provides an automated pipeline for generating procedural 3D models with baked textures into one of many supported formats (ABC, FBX, GLTF, OBJ, PLY, SDF, STL, USD).

## Attributions

Expand Down
23 changes: 23 additions & 0 deletions scripts/blender/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env -S blender --python-exit-code 1 --python
"""
Script for setting up Blender preferences.
- Use Cycles with CUDA GPU
- Enable Node Wrangler addon
"""

import bpy

# Use Cycles with GPU
bpy.context.preferences.addons["cycles"].preferences.compute_device_type = "CUDA"
bpy.context.preferences.addons["cycles"].preferences.get_devices()
for device in bpy.context.preferences.addons["cycles"].preferences.devices:
device.use = device.type == "CUDA"
bpy.context.scene.render.engine = "CYCLES"
bpy.context.scene.cycles.device = "GPU"

# Enable Node Wrangler
bpy.ops.preferences.addon_enable(module="node_wrangler")

# Save preferences
bpy.ops.wm.save_userpref()
Loading

0 comments on commit 521b0fb

Please sign in to comment.