blenderproc.python.loader.HavenMaterialLoader module

class blenderproc.python.loader.HavenMaterialLoader.HavenMaterialLoader[source]

Bases: object

This class loads all textures obtained from https://texturehaven.com, use ‘blenderproc download haven’ to download all the textures to your pc.

All textures here support Physically based rendering (PBR), which makes the textures more realistic.

There is a preload option, in which you only load empty materials, without any loaded textures, these are than later filled, when an object really uses them. This saves on loading times.

static create_material(new_mat, base_image_path, ambient_occlusion_image_path, specular_image_path, roughness_image_path, alpha_image_path, normal_image_path, displacement_image_path, bump_image_path)[source]

Create a material for the haven datatset, the combination used here is calibrated to the haven dataset format.

Parameters:
  • new_mat (Material) – The new material, which will get all the given textures
  • base_image_path (str) – The path to the color image
  • ambient_occlusion_image_path (str) – The path to the ambient occlusion image
  • specular_image_path (str) – The path to the specular image
  • roughness_image_path (str) – The path to the roughness image
  • alpha_image_path (str) – The path to the alpha image (when this was written there was no alpha image provided in the haven dataset)
  • normal_image_path (str) – The path to the normal image
  • displacement_image_path (str) – The path to the displacement image
  • bump_image_path (str) – The path to the bump image
blenderproc.python.loader.HavenMaterialLoader.identify_base_color_image_path(texture_map_paths)[source]

Finds the path to the base color image in a list of texture map paths. We do this by looking for any of the “base color” identifiers in each path. We also make sure to account for different capitalizations of the identifier.

Parameters:texture_map_paths (list of strings) – paths to check
Returns:path to the base color image and the specific identifier
Return type:tuple of 2 strings
blenderproc.python.loader.HavenMaterialLoader.identify_texture_maps(texture_folder_path)[source]

Finds the paths of the different textures maps in a texture folder.

Parameters:texture_folder_path (Union[str, Path]) – path to the texture folder
Return type:Optional[Dict[str, str]]
Returns:dictionary that maps texture map types to their path when found, else it maps to an empty string
blenderproc.python.loader.HavenMaterialLoader.load_haven_mat(folder_path='resources/haven', used_assets=None, preload=False, fill_used_empty_materials=False, add_cp=None, return_random_element=False)[source]

Loads all specified haven textures from the given directory.

Parameters:
  • folder_path (Union[str, Path]) – The path to the downloaded haven.
  • used_assets (Optional[List[str]]) – A list of all asset names, you want to use. The asset-name must not be typed in completely, only the beginning the name starts with. By default all assets will be loaded, specified by an empty list or None.
  • preload (bool) – If set true, only the material names are loaded and not the complete material.
  • fill_used_empty_materials (bool) – If set true, the preloaded materials, which are used are now loaded completely.
  • add_cp (Optional[Dict[str, Any]]) – A dictionary of materials and the respective properties.
  • return_random_element (bool) – If this is True only a single Material is loaded and returned, if you want to sample many materials load them all with the preload option, use them and then fill the used empty materials instead of calling this function multiple times.
:return a list of all loaded materials, if preload is active these materials do not contain any textures yet
and have to be filled before rendering (by calling this function again, there is no need to save the prior returned list) or if return_random_element is True only a single Material is returned
Return type:Union[List[Material], Material]