ddg.visualization.blender.material module
- ddg.visualization.blender.material.set_material(bobj, material, protect=True)[source]
Assigns given material or material with given name to the object. A new material is created if it did not exist before!
- Parameters:
- bobj: bpy.types.Object
Blender object the material is assigned to.
- material: str or bpy.types.Material
Name of the material or actual material object
- protect: bool (default=True)
If True, the material is protected from being deleted when unused. Is only applied if the material did not exist before!
- ddg.visualization.blender.material.protect_material(material)[source]
Protects given material from being deleted after reloading the file if not in use.
- Parameters:
- mat_name: str or bpy.types.Material
Name of the material or actual material object. Must exist.
- ddg.visualization.blender.material.material(name='DDG Material', color=(1, 1, 1), specular=1, roughness=0.5, alpha=1)[source]
Create a Principled BSDF material.
- Parameters:
- namestr, (default=”DDG Material”)
The name of the material.
- color3-tuple, (default=(1,1,1))
The color in RGB base.
- specularint, (default=1)
The specular value in [0,1]
- roughnessint, (default=0.5)
The roughness value in [0,1]
- alphaint, (default=1)
The alpha value in [0,1]
- Returns:
- bpy.types.Material
- ddg.visualization.blender.material.clear(materials=None, only_unused=False)[source]
Delete all given materials.
- Parameters:
- materialsIterable of bpy.types.Material (default=None)
Materials to be deleted. If argument is not provided or None all materials will be deleted.
- only_unusedbool (default=False)
Removes all unused material. If an Iterable of materials is given as first parameter only those are effected, otherwise all materials.
- Returns:
- None
- ddg.visualization.blender.material.set_transparency(mat, alpha=0.5, blend_method='HASHED')[source]
Setup a BSDF material for transparent rendering.
The oppacity then corresponds to the ‘alpha’ value of the material. It can be set using
set_value. The default alpha value is 0.5, which corresponds to 50% opacity.- Parameters:
- mat: bpy.tyes.Material with a BSDF node.
Material to make transparent.
- alpha: float between 0 and 1 (default=0.5)
Opacity of the material. 0 is transparent, 1 is opaque.
- blend_method: valid string for bpy.types.Material.blend_method (default=”HASHED”)
Method used by real-time renderers, i.e. Eevee, to blend the transparent material with its background.
- Returns:
- bpy.types.Material
See also
ddg.visualization.blender.material.transparent_material