-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblender_render.py
More file actions
73 lines (57 loc) · 1.94 KB
/
blender_render.py
File metadata and controls
73 lines (57 loc) · 1.94 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
import bpy
import sys
import os
scene = bpy.context.scene
eevee = scene.eevee
# Parse arguments passed after "--"
argv = sys.argv
argv = argv[argv.index("--") + 1:] if "--" in argv else []
# Ensure skin and output path are provided
if len(argv) < 2:
print("❌ Usage: blender --python blender_render.py -- <skin_path> <output_path>")
sys.exit(1)
eevee.taa_samples = 0
eevee.taa_render_samples = 5
eevee.volumetric_shadow_samples = 1
eevee.use_shadows = True
try:
eevee.use_shadows = (argv[2].lower() == 'true')
except IndexError:
pass
eevee.use_volumetric_shadows = True
eevee.use_shadow_jitter_viewport = True
eevee.use_taa_reprojection = True
eevee.shadow_resolution_scale = 1
eevee.shadow_ray_count = 1
eevee.shadow_step_count = 1
scene.render.image_settings.file_format = 'PNG'
scene.render.image_settings.color_depth = '16'
# Get the absolute script directory
script_dir = os.path.dirname(os.path.realpath(__file__))
# Get full paths
skin_path = os.path.abspath(os.path.join(script_dir, argv[0]))
# Set Output Path
bpy.context.scene.render.filepath = os.path.abspath(os.path.join(script_dir, argv[1]))
# Replace target image
target_name = "skin" # or "Skinsaa" if you're sure of the name
for image in bpy.data.images:
if target_name.lower() in image.name.lower():
print(f"✅ Replacing: {image.name}")
if image.packed_file:
print("📦 Unpacking packed image...")
try:
image.unpack()
except Exception as e:
print(f"⚠️ Failed to unpack: {e}")
image.filepath = skin_path
image.filepath_raw = skin_path
image.source = 'FILE'
try:
image.reload()
except Exception as e:
print(f"❌ Reload failed: {e}")
break
# Render
print("🎬 Rendering...")
bpy.ops.render.render(write_still=True)
print(f"✅ Render saved")