blenderproc.material package¶
Module contents¶
-
blenderproc.material.
add_alpha
(nodes, links, alpha_image_path, principled_bsdf)¶ Adds alpha to the principled bsdf node.
Parameters: - nodes (
Nodes
) – Nodes from the current material - links (
NodeLinks
) – Links from the current material - alpha_image_path (
str
) – Path to the metal image - principled_bsdf (
Node
) – Principled BSDF node of the current material
Returns: bpy.types.Node: The newly constructed texture node
- nodes (
-
blenderproc.material.
add_alpha_channel_to_textures
(blurry_edges)¶ Adds transparency to all textures, which contain an .png image as an image input
Parameters: blurry_edges – If True, the edges of the alpha channel might be blurry, this causes errors if the alpha channel should only be 0 or 1 Be careful, when you replace the original texture with something else (Segmentation, …), the necessary texture node gets lost. By copying it into a new material as done in the SegMapRenderer, you can keep the transparency even for those nodes.
-
blenderproc.material.
add_alpha_texture_node
(used_material, new_material)¶ Adds to a predefined new_material a texture node from an existing material (used_material) This is necessary to connect it later on in the add_alpha_channel_to_textures
Parameters: - used_material – existing material, which might contain a texture node with a .png texture
- new_material – a new material, which will get a copy of this texture node
Returns: the modified new_material, if no texture node was found, the original new_material
-
blenderproc.material.
add_ambient_occlusion
(nodes, links, ambient_occlusion_image_path, principled_bsdf, base_color)¶ Adds ambient occlusion to the principled bsdf node.
Parameters: - nodes (
Nodes
) – Nodes from the current material - links (
NodeLinks
) – Links from the current material - ambient_occlusion_image_path – Path to the ambient occlusion image
- principled_bsdf (
Node
) – Principled BSDF node of the current material - base_color (
Node
) – Base color node of the current material
Returns: bpy.types.Node: The newly constructed texture node
- nodes (
-
blenderproc.material.
add_base_color
(nodes, links, base_image_path, principled_bsdf)¶ Adds base color to the principled bsdf node.
Parameters: - nodes (
Nodes
) – Nodes from the current material - links (
NodeLinks
) – Links from the current material - base_image_path – Path to the base image
- principled_bsdf (
Node
) – Principled BSDF node of the current material
Returns: bpy.types.Node: The newly constructed texture node
- nodes (
-
blenderproc.material.
add_bump
(nodes, links, bump_image_path, principled_bsdf)¶ Adds bump to the principled bsdf node.
Parameters: - nodes (
Nodes
) – Nodes from the current material - links (
NodeLinks
) – Links from the current material - bump_image_path (
str
) – Path to the metal image - principled_bsdf (
Node
) – Principled BSDF node of the current material
Returns: bpy.types.Node: The newly constructed texture node
- nodes (
-
blenderproc.material.
add_displacement
(nodes, links, displacement_image_path, output_node)¶ Adds bump to the principled bsdf node.
Parameters: - nodes (
Nodes
) – Nodes from the current material - links (
NodeLinks
) – Links from the current material - displacement_image_path (
str
) – Path to the metal image - output_node (
Node
) – Output node of the current material
Returns: bpy.types.Node: The newly constructed texture node
- nodes (
-
blenderproc.material.
add_dust
(material, strength, texture_nodes=None, texture_scale=0.1)¶ Adds a dust film to the material, where the strength determines how much dust is used.
This will be added right before the output of the material.
Parameters: - material (
Material
) – Used material - strength (
float
) – This determines the strength of the dust, 0 means no dust 1.0 means full dust. Values above 1.0 are possible, but create a thick film out of dust, which hides the material completely. - texture_nodes (
Optional
[List
[Texture
]]) – If a specific dust texture should be used, this can be specified. If this is empty a random noise texture is generated. - texture_scale (
float
) – This scale is used to scale down the used noise texture (even for the case where a random noise texture is used).
- material (
-
blenderproc.material.
add_metal
(nodes, links, metalness_image_path, principled_bsdf)¶ Adds metal to the principled bsdf node.
Parameters: - nodes (
Nodes
) – Nodes from the current material - links (
NodeLinks
) – Links from the current material - metalness_image_path (
str
) – Path to the metal image - principled_bsdf (
Node
) – Principled BSDF node of the current material
Returns: bpy.types.Node: The newly constructed texture node
- nodes (
-
blenderproc.material.
add_normal
(nodes, links, normal_image_path, principled_bsdf, invert_y_channel)¶ Adds normal to the principled bsdf node.
Parameters: Returns: bpy.types.Node: The newly constructed texture node
-
blenderproc.material.
add_roughness
(nodes, links, roughness_image_path, principled_bsdf)¶ Adds roughness to the principled bsdf node.
Parameters: - nodes (
Nodes
) – Nodes from the current material - links (
NodeLinks
) – Links from the current material - roughness_image_path (
str
) – Path to the metal image - principled_bsdf (
Node
) – Principled BSDF node of the current material
Returns: bpy.types.Node: The newly constructed texture node
- nodes (
-
blenderproc.material.
add_specular
(nodes, links, specular_image_path, principled_bsdf)¶ Adds specular to the principled bsdf node.
Parameters: - nodes (
Nodes
) – Nodes from the current material - links (
NodeLinks
) – Links from the current material - specular_image_path (
str
) – Path to the metal image - principled_bsdf (
Node
) – Principled BSDF node of the current material
Returns: bpy.types.Node: The newly constructed texture node
- nodes (
-
blenderproc.material.
change_to_texture_less_render
(use_alpha_channel)¶ Changes the materials, which do not contain a emission shader to a white slightly glossy texture
Parameters: use_alpha_channel – If true, the alpha channel stored in .png textures is used.
-
blenderproc.material.
collect_all
()¶ Returns all existing materials.
Return type: List
[Optional
[Material
]]Returns: A list of all materials.
-
blenderproc.material.
connect_uv_maps
(nodes, links, collection_of_texture_nodes)¶ Connect all given texture nodes to a newly constructed UV node.
Parameters: - nodes (
Nodes
) – Nodes from the current material - links (
NodeLinks
) – Links from the current material - collection_of_texture_nodes (
list
) – List of :class: bpy.type.Node of type :class: ShaderNodeTexImage
- nodes (
-
blenderproc.material.
convert_to_materials
(blender_materials)¶ Converts the given list of blender materials to bproc.Material(s)
Parameters: blender_materials ( List
[Optional
[Material
]]) – List of materials.Return type: List
[Optional
[Material
]]Returns: The list of materials.
-
blenderproc.material.
create
(name)¶ Creates a new empty material.
Parameters: name ( str
) – The name of the new material.Return type: Material
Returns: The new material.
-
blenderproc.material.
create_image_node
(nodes, image, non_color_mode=False, x_location=0, y_location=0)¶ Creates a texture image node inside of a material.
Parameters: - nodes (
Nodes
) – Nodes from the current material - image (
Union
[str
,Image
]) – Either the path to the image which should be loaded or the bpy.types.Image - non_color_mode – If this True, the color mode of the image will be “Non-Color”
- x_location – X Location in the node tree
- y_location – Y Location in the node tree
Returns: bpy.type.Node: Return the newly constructed image node
- nodes (
-
blenderproc.material.
create_material_from_texture
(texture, material_name)¶ Creates a material based on a given texture, the texture can either be a path to a texture file on disc or a already loaded bpy.types.Image.
Parameters: Return type: Returns: the newly created material, which uses the texture as Base Color
-
blenderproc.material.
create_new_cc_material
(material_name, add_custom_properties)¶ Creates a new material, which gets the given custom properties and the material name.
Parameters: Return type: Material
Returns: bpy.types.Material: Return the newly created material
-
blenderproc.material.
create_procedural_texture
(pattern_name=None)¶ Creates a new procedural texture based on a specified pattern.
Parameters: pattern_name ( Optional
[str
]) – The name of the pattern. Available: [“CLOUDS”, “DISTORTED_NOISE”, “MAGIC”, “MARBLE”, “MUSGRAVE”, “NOISE”, “STUCCI”, “VORONOI”, “WOOD”] If None is given, a random pattern is used.Return type: Texture
Returns: The created texture
-
blenderproc.material.
find_cc_material_by_name
(material_name, custom_properties)¶ Finds from all loaded materials the cc material, which has the given material_name and the given custom_properties.
Parameters: Return type: Material
Returns: bpy.types.Material: Return the searched material, if not found returns None
-
blenderproc.material.
is_material_used
(material)¶ Checks if the given material is used on any object.
Parameters: material ( Material
) – Material, which should be checkedReturns: True if the material is used