yuki-koyama / blender-cli-rendering

Blender Python scripts for rendering images directly from command-line interface
GNU General Public License v3.0
733 stars 107 forks source link

Windows support #35

Closed chuong closed 2 years ago

chuong commented 2 years ago

Thanks for great examples of how to render using Blender from the terminal. I tried this on Windows 10 and it failed with path errors:

PS C:\Users\chuong\Documents\blender-cli-rendering> & "C:\Program Files\Blender Foundation\Blender 2.91\blender.exe" --background --python .\07_texturing.py --render-frame 1 -- ./07_texturing.png 100 4
Blender 2.91.0 (hash 0f45cab862b8 built 2020-11-25 09:02:56)
Read prefs: C:\Users\ngu10t\AppData\Roaming\Blender Foundation\Blender\2.91\config\userpref.blend
found bundled python: C:\Program Files\Blender Foundation\Blender 2.91\2.91\python
C:\Users\chuong\Documents\blender-cli-rendering
Error: Cannot read './assets/cc0textures.com/[2K]Leather05/Leather05_col.jpg': No such file or directory
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\chuong\Documents\blender-cli-rendering\.\07_texturing.py", line 115, in <module>
    focus_target = set_scene_objects()
  File "C:\Users\chuong\Documents\blender-cli-rendering\.\07_texturing.py", line 63, in set_scene_objects
    add_named_material("Leather05")
  File "C:\Users\chuong\Documents\blender-cli-rendering\.\07_texturing.py", line 58, in add_named_material
    displacement_scale=displacement_scale)
  File "C:\Users\chuong\Documents\blender-cli-rendering\utils\material.py", line 147, in build_pbr_textured_nodes
    texture_node = create_texture_node(node_tree, color_texture_path, True)
  File "C:\Users\chuong\Documents\blender-cli-rendering\utils\material.py", line 11, in create_texture_node
    texture_node.image = bpy.data.images.load(path)
RuntimeError: Error: Cannot read './assets/cc0textures.com/[2K]Leather05/Leather05_col.jpg': No such file or directory

Error: Cannot render, no camera
Fra:0 Mem:7.48M (Peak 7.54M) | Time:00:00.00 | Sce:  Ve:0 Fa:0 La:0

Blender quit

I suspect there are 2 problems: 1) Windows is not happy with "...[2K]..." in the paths, 2) the relative path is not used correctly.

yuki-koyama commented 2 years ago

Thank you for reporting this issue!! Unfortunately, I don't have access to Windows currently, so I cannot resolve this issue immediately. (Meanwhile, pull requests are welcome of course)