📜 ⬆️ ⬇️

Addon for generating materials Cycles Blender

Good afternoon, dear habravchane. Some time ago I made the “Shader Generator” plugin - an addon that implements the idea of ​​parametric generation and editing of shaders (materials) of the built-in Cycles render.



Why is it needed


With the help of the plug-in, the user, having minimal modeling skills, can create and customize realistic materials himself. Each material and texture can be used repeatedly and transferred from the scene to the scene. Presets can be saved, deleted, added.


')

How it works


The principle of operation of the addon is to import into the working scene of the tree all the nodes necessary for generating the shader, combined into a universal group (Node Group). Further editing takes place through the traditional controls in the material properties panel. The advantages of this approach lie in the intuitive way for the user who did not have experience with the nodal architecture of Cycles shaders. A distinctive feature of the addon is the original system of saving user material presets to the hard disk, using JSON.

The node group containing all the nodes that determine the final view of the shader is located in a separate .blend file, in the folder with the addon. This allows not only to reduce the amount of code at times, but also to make changes and additions to the shader as quickly as possible, without programming.

How does it work






Five categories of materials are pre-installed: metal, glass, translucent, stone, snow

Some screenshots of the interface




The resulting materials


Here, it should be noted that I am far from a modeler and I do not yet know how to set up a Cycles render in the best way.





Python


Addon structure is typical for Blender.
There are several classes that implement operators that are called by the user from the graphical interface. These classes inherit from bpy.types.Operator and have a typical structure from the properties-descriptions of the operator and most often one execute method that executes the inherent functionality. In several statements, the invoke method is also declared, which is called before execute and allows the user to specify the settings of the statement before execution.
The graphic part of the add-on is implemented using the MatGenPanel class, which inherits from bpy.types.Panel. As in the case of operators, properties with a description of the panel for the internal mechanisms of Blender were first declared. Then follows the context check method poll, which allows you to limit the visibility of the panel under certain conditions. In our case, this condition is the rendering mode in Cycles.
The draw method draws graphical interface elements.
Finally, the global register and unregister functions add all declared classes to the internal Blender space via API helper methods.

Thank you for reading to the end, I hope this article was not boring to death. It is possible that this material may be of practical use to someone.

The addon can be downloaded from the link: www.dropbox.com/s/96d6iod25yhmhg5/matgen_last.7z

Source: https://habr.com/ru/post/227543/


All Articles