Blender Material BSDF Class and default Materials#

Main Class#

class BlenderMaterialBSDF(base_color=None, metallic=None, roughness=None, IOR=None, alpha=None, normal=None, weight=None, subsurface_weight=None, subsurface_radius=None, subsurface_scale=None, subsurface_IOR=None, subsurface_anisotropy=None, specular_IOR_level=None, specular_tint=None, anisotropic=None, anisotropic_rotation=None, tangent=None, transmission_weight=None, coat_weight=None, coat_roughness=None, coat_IOR=None, coat_tint=None, coat_normal=None, sheen_weight=None, sheen_roughness=None, sheen_tint=None, emission_color=None, emission_strength=None, thin_film_thickness=None, thin_film_IOR=None)[source]#

Bases: object

Represents a material with detailed physical and visual properties for Blender’s BSDF Principled shader. The class used the Blender’s Principled BSDF shader as a base for the material. The parameters are based on the Blender’s documentation.

Note

If a pattern will be used for the associated mesh, the base color can be ignored. The pattern will be used as the base color of the material. If the pattern and a base color are both set, the pattern will be multiplied by the given base color.

Parameters:
  • base_color (array_like, optional) – The base color of the material, with RGBA values. Default to None.

  • metallic (float, optional) – The metallic value of the material. Default to None.

  • roughness (float, optional) – The roughness value of the material. Default to None.

  • IOR (float, optional) – The index of refraction of the material. Default to None.

  • alpha (float, optional) – The alpha value of the material. Default to None.

  • normal (array_like, optional) – The normal of the material with XYZ values. Default to None.

  • weight (float, optional) – The weight of the material. Default to None.

  • subsurface_weight (float, optional) – The subsurface weight of the material. Default to None.

  • subsurface_radius (array_like, optional) – The subsurface radius of the material. Default to None.

  • subsurface_scale (float, optional) – The subsurface scale of the material. Default to None.

  • subsurface_IOR (float, optional) – The subsurface index of refraction of the material. Default to None.

  • subsurface_anisotropy (float, optional) – The subsurface anisotropy of the material. Default to None.

  • specular_IOR_level (float, optional) – The specular index of refraction level of the material. Default to None.

  • specular_tint (array_like, optional) – The specular tint of the material with RGBA values. Default to None.

  • anisotropic (float, optional) – The anisotropic value of the material. Default to None.

  • anisotropic_rotation (float, optional) – The anisotropic rotation of the material. Default to None.

  • tangent (array_like, optional) – The tangent of the material with XYZ values. Default to None.

  • transmission_weight (float, optional) – The transmission weight of the material. Default to None.

  • coat_weight (float, optional) – The coat weight of the material. Default to None.

  • coat_roughness (float, optional) – The coat roughness of the material. Default to None.

  • coat_IOR (float, optional) – The coat index of refraction of the material. Default to None.

  • coat_tint (array_like, optional) – The coat tint of the material with RGBA values. Default to None.

  • coat_normal (array_like, optional) – The coat normal of the material with XYZ values. Default to None.

  • sheen_weight (float, optional) – The sheen weight of the material. Default to None.

  • sheen_roughness (float, optional) – The sheen roughness of the material. Default to None.

  • sheen_tint (array_like, optional) – The sheen tint of the material with RGBA values. Default to None.

  • emission_color (array_like, optional) – The emission color of the material with RGBA values. Default to None.

  • emission_strength (float, optional) – The emission strength of the material. Default to None.

  • thin_film_thickness (float, optional) – The thin film thickness of the material. Default to None.

  • thin_film_IOR (float, optional) – The thin film index of refraction of the material. Default to None.

property IOR: Number | None#
property alpha: Number | None#
property anisotropic: Number | None#
property anisotropic_rotation: Number | None#
property base_color: ndarray | None#
property coat_IOR: Number | None#
property coat_normal: ndarray | None#
property coat_roughness: Number | None#
property coat_tint: ndarray | None#
property coat_weight: Number | None#
property emission_color: ndarray | None#
property emission_strength: Number | None#
classmethod from_dict(data)[source]#

Create a BlenderMaterialBSDF instance from a dictionary.

The structure of the dictionary should be as provided by the to_dict() method. The other fields of the dictionary are ignored.

from pysdic.blender import BlenderMaterialBSDF

mat_dict = {
    "type": "BlenderMaterialBSDF",
    "description": "Description of the material",
    "base_color": [0.5, 0.5, 0.5, 1.0],
    "metallic": 0.5,
    "roughness": 0.5,
}

# Create a BlenderMaterialBSDF instance from the dictionary
material = BlenderMaterialBSDF.from_dict(mat_dict)

See also

Parameters:

data (dict) – A dictionary containing the material’s data.

Returns:

The BlenderMaterialBSDF instance.

Return type:

BlenderMaterialBSDF

Raises:
  • ValueError – If the data is not a dictionary.

  • KeyError – If required keys are missing from the dictionary.

classmethod from_json(filepath)[source]#

Create a BlenderMaterialBSDF instance from a JSON file.

The structure of the JSON file follows the to_dict() method.

from pysdic.blender import BlenderMaterialBSDF

# Load the mesh from a JSON file
material = BlenderMaterialBSDF.from_json("path/to/mesh.json")

See also

Parameters:

filepath (str) – The path to the JSON file.

Returns:

A BlenderMaterialBSDF instance.

Return type:

BlenderMaterialBSDF

Raises:

FileNotFoundError – If the filepath is not a valid path.

classmethod get_details()[source]#

Get detailed descriptions of each parameter in the BlenderMaterialBSDF class.

Returns:

str: A detailed description of all parameters and their roles in Blender materials.

Return type:

str

property metallic: Number | None#
property normal: ndarray | None#
property roughness: Number | None#
property sheen_roughness: Number | None#
property sheen_tint: ndarray | None#
property sheen_weight: Number | None#
property specular_IOR_level: Number | None#
property specular_tint: ndarray | None#
property subsurface_IOR: Number | None#
property subsurface_anisotropy: Number | None#
property subsurface_radius: ndarray | None#
property subsurface_scale: Number | None#
property subsurface_weight: Number | None#
property tangent: ndarray | None#
property thin_film_IOR: Number | None#
property thin_film_thickness: Number | None#
to_dict(description='')[source]#

Export the BlenderMaterialBSDF’s data to a dictionary.

The structure of the dictionary is as follows:

{
    "type": "BlenderMaterialBSDF",
    "description": "Description of the material",
    "base_color": [0.5, 0.5, 0.5, 1.0],
    "metallic": 0.5,
    "roughness": 0.5,
    "IOR": 1.5,
    "...": ...,
}
Parameters:

description (str, optional) – A description of the material, by default “”.

Returns:

A dictionary containing the BlenderMaterialBSDF’s data.

Return type:

dict

Raises:

ValueError – If the description is not a string.

to_json(filepath, description='')[source]#

Export the BlenderMaterialBSDF’s data to a JSON file.

The structure of the JSON file follows the :meth:BlenderMaterialBSDF.to_dict` method.

Parameters:
  • filepath (str) – The path to the JSON file.

  • description (str, optional) – A description of the material, by default “”.

Raises:

FileNotFoundError – If the filepath is not a valid path.

Return type:

None

property transmission_weight: Number | None#
property weight: Number | None#

Default Materials#

get_mirror_material()[source]#

Returns a mirror material for use in Blender.

This material is a perfect mirror with no roughness and a refractive index of 1.50.

{
    "base_color": (1.0, 1.0, 1.0, 1.0), # White color
    "roughness": 0.0, # No roughness
    "metallic": 1.0, # Fully metallic
    "IOR": 1.5, # Refractive index between 1.45 and 1.55
    "transmission_weight": 0.0, # No transmission
    "alpha": 1.0, # Fully opaque
}
Returns:

A BlenderMaterialBSDF object representing a mirror material.

Return type:

BlenderMaterialBSDF

get_steel_material()[source]#

Returns a steel-like material.

Polished steel is metallic, slightly rough, and has a neutral gray tint.

{
    "base_color": (0.55, 0.55, 0.55, 1.0), # Neutral gray
    "roughness": 0.2, # Slightly rough
    "metallic": 1.0, # Fully metallic
    "IOR": 2.5, # Approximate for steel
    "transmission_weight": 0.0, # No transmission
    "alpha": 1.0, # Fully opaque
}
Returns:

A BlenderMaterialBSDF object representing polished steel.

Return type:

BlenderMaterialBSDF

get_titanium_material()[source]#

Returns a titanium-like material.

Titanium has a slightly bluish-gray hue and is less reflective than polished steel.

{
    "base_color": (0.5, 0.52, 0.6, 1.0), # Slight bluish-gray
    "roughness": 0.25, # Slightly rough
    "metallic": 1.0, # Fully metallic
    "IOR": 2.5, # Close approximation
    "transmission_weight": 0.0, # No transmission
    "alpha": 1.0, # Fully opaque
}
Returns:

A BlenderMaterialBSDF object representing titanium.

Return type:

BlenderMaterialBSDF

get_iron_material()[source]#

Returns an iron-like material.

Iron is dark gray and typically more rough than polished steel.

{
    "base_color": (0.3, 0.3, 0.3, 1.0), # Dark gray
    "roughness": 0.35, # More rough than polished steel
    "metallic": 1.0, # Fully metallic
    "IOR": 2.9, # Iron has a higher refractive index
    "transmission_weight": 0.0, # No transmission
    "alpha": 1.0, # Fully opaque
}
Returns:

A BlenderMaterialBSDF object representing iron.

Return type:

BlenderMaterialBSDF

get_copper_material()[source]#

Returns a copper-like material.

Copper has a distinctive reddish-orange color, is highly reflective, and fully metallic.

{
    "base_color": (0.955, 0.637, 0.538, 1.0), # Reddish-orange typical of copper
    "roughness": 0.2, # Slight surface roughness
    "metallic": 1.0, # Fully metallic
    "IOR": 2.7, # Approximate value for copper
    "transmission_weight": 0.0, # No transmission
    "alpha": 1.0, # Fully opaque
}
Returns:

A BlenderMaterialBSDF object representing copper.

Return type:

BlenderMaterialBSDF