yuki-koyama / blender-cli-rendering Goto Github PK
View Code? Open in Web Editor NEWBlender Python scripts for rendering images directly from command-line interface
License: GNU General Public License v3.0
Blender Python scripts for rendering images directly from command-line interface
License: GNU General Public License v3.0
Hi, thanks for sharing this codebase! I'm trying your mocap script (10_mocap.py
) by following this command:
Line 30 in dd283eb
Yet the results I got seems pretty weird,
I'm rather new to blender and cannot quite debug it on my end. I imagine it might be caused by wrong ambient value of the scene. What is your idea?
It prevents Blender hanging on startup.
Hi, script number 7 (as well as 8,9,10 and 12) fail with this error:
Blender 2.80 (sub 75)
Traceback (most recent call last):
File "/home/david/coding/blender-cli-rendering/./07_texturing.py", line 66, in <module>
focus_target = set_scene_objects()
File "/home/david/coding/blender-cli-rendering/./07_texturing.py", line 14, in set_scene_objects
loader.build_pbr_textured_nodes_from_name("Leather05")
File "/home/david/coding/blender-cli-rendering/external/cc0assetsloader/__init__.py", line 144, in build_pbr_textured_nodes_from_name
scale=scale)
File "/home/david/coding/blender-cli-rendering/external/cc0assetsloader/__init__.py", line 124, in build_pbr_textured_nodes
nodelayout.arrange_nodes(node_tree, use_current_layout_as_initial_guess=False)
AttributeError: module 'nodelayout' has no attribute 'arrange_nodes'
Do I need to install something to make it work?
CC0AssetsLoader, which is currently included as a git submodule, has some large-size assets. This means that every time cloning this repository requires a huge download. Also, CC0AssetsLoader implicitly uses Git LFS, which may confuse some users.
One of the next target features may be toon shading; especially I want to reproduce cell-look shading used in Japanese anime.
Blender 2.80 will be officially released very soon.
Hi, thanks for sharing these scripts! I am a complete newbie to Blender and I really appreciate them.
I tried those scripts with the new Blender 4.0 and it seems this version introduced some major changes in the API which broke them.
Error: Python: Traceback (most recent call last):
File "/test/blender-cli-rendering/10_mocap.py", line 137, in <module>
utils.build_scene_composition(scene)
File "/test/blender-cli-rendering/utils/composition.py", line 184, in build_scene_composition
vignette_node = create_vignette_node(scene.node_tree)
File "/test/blender-cli-rendering/utils/composition.py", line 165, in create_vignette_node
vignette_node_group = add_vignette_node_group()
File "/test/blender-cli-rendering/utils/composition.py", line 118, in add_vignette_node_group
group.inputs.new("NodeSocketColor", "Image")
AttributeError: 'CompositorNodeTree' object has no attribute 'inputs'
Error: Cannot render, no camera
Would it be possible to have a version compatible with Blender 4.0?
I guess I no longer use 2.79 even in headless environments. I think it's time to remove support of 2.79 for easier code maintenance.
This suggestion #28 (comment) sounds very helpful as a quick fix until we can resolve this issue #25.
the scripts have not been tested with 2.83 LTS
The current utils.set_cycles_renderer
takes non-cycles parameters as inputs, which is not very meaningful. This should be fixed.
cc0assetsloader does not work for 2.81 currently (yuki-koyama/cc0assetsloader#1), and so some of the scripts in this repository do not work for 2.81 accordingly.
I will work on updating cc0assetsloader in a few days, so this issue should be fixed soon.
utils.py
now contains many general-purpose utility functions that may be useful in other script/plug-in development. It would be nice if they are provided as a python package or module.
Though the scripts are mainly written for Blender 2.79, it would be better if it works with Blender 2.8 as well. Blender 2.8 produces the following error:
AttributeError: bpy_prop_collection: attribute "active" not found
API Changes:
https://en.blender.org/index.php/Dev:2.8/Source/LayersCollections/API-Changes
Hello @yuki-koyama, do you have any idea of converting the repo to a python library so folks can easily integrate it into their code base? Thank you!
I'm interested in using FreeStyle for NPR and visualization. I hope I can add FreeStyle API utilities to this repository soon.
Some old codes violate this coding guideline: https://github.com/yuki-koyama/blender-cli-rendering/blob/master/CODE_STYLE.md, which should be fixed to avoid inconsistency
In your readme, you consider that this package is a “derivative work” of Blender, so therefore has to be subject to the same licence. Certainly the Blender Foundation also seems to think the same of users of its APIs, but I should point out that this goes against just about every discussion of the subject in other open-source projects.
For the best-known example, you may have heard of the Oracle vs Google case. The US Supreme Court verdict on that made it quite clear that Oracle could not stop Google from using the Java APIs (even if it actually dodged the question of copyrightability of APIs).
For another example, the Linux kernel docs explicitly say that userland code can make use of APIs that interface to the kernel without implications for their licensing. (Kernel modules, on the other hand, are considered “derivative works”.)
The basic point is that compatibility with APIs is essential for providing basic purely technical functionality, and so cannot be restricted by copyright for that reason.
I’m not asking you to change the licensing of your project, merely pointing out that it is not as constrained--should not be as constrained!--as you might think.
The current scripts implicitly assume that they are called from the top directory of this repository. Instead, it should use the following code to obtain the absolute path of the directory:
os.path.dirname(os.path.abspath(__file__))
The newest LTS (2.93) should be supported.
Follow PEP 8 rules as much as possible
I found a useful tutorial: https://b3d.interplanety.org/en/render-from-console-only-on-the-specified-gpu-devices-2/
This is useful for big GPU machines which may be shared by multiple people, specifying the devices is useful. Btw does Blender respect CUDA_VISIBLE_DEVICES / NVIDIA_VISIBLE_DEVICES?
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.
Adding type hints should be beneficial:
https://www.python.org/dev/peps/pep-0483/
11_mesh_vizualization.py has the feature transparent background but the rendered image isn't transparent, even after changing the format to PNG to support alpha channel. When running the code with UI, I see that it does get the transparent background when I change the view of the rendering to View Layer -> combined. But the image being saved is using the Composite option instead of view layer. Is there anyway to enable saving the combined view layer? or any workaround. Thank you very much!
At the moment to use this as a dependency in a project it's necessary to use importlib or some other workaround to import modules since python is not a fan of hypens in module names. Renaming may be a simple solution
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.