io
pypbr.io
This module provides input/output utility functions for loading and saving material maps from and to folders, used in Physically Based Rendering (PBR) workflows. It handles image formats and naming conventions for various material properties such as albedo, normal maps, roughness, height, metallic, and specular maps.
- Functions:
load_material_from_folder: Loads material maps from a folder based on file naming conventions.
save_material_to_folder: Saves material maps to a specified folder in the desired format.
- pypbr.io.load_material_from_folder(folder_path: str, map_names: Dict[str, List[str]] | None = None, preferred_workflow: str | None = None, is_srgb: bool = True) MaterialBase [source]
Load material maps from a folder using naming conventions.
- Parameters:
folder_path (str) – Path to the folder containing material maps.
map_names (Optional[Dict[str, List[str]]]) – Optional dictionary specifying map types and their possible filenames.
preferred_workflow (Optional[str]) – Preferred workflow (‘metallic’ or ‘specular’). If not specified, the workflow is determined based on available maps.
is_srgb (bool) – Whether the albedo and specular maps are in sRGB color space.
- Returns:
An instance of a Material subclass with loaded maps.
- Return type:
- pypbr.io.save_material_to_folder(material: MaterialBase, folder_path: str, map_names: Dict[str, str] | None = None, format: str = 'png')[source]
Save material maps to a folder using naming conventions.
- Parameters:
material (MaterialBase) – The material to save.
folder_path (str) – Path to the folder where maps will be saved.
map_names (Optional[Dict[str, str]]) – Optional dictionary specifying filenames for each map type.
format (str) – The image format to save the maps (e.g., ‘png’, ‘jpg’).
- pypbr.io.select_material_class(loaded_maps: Dict[str, Image], preferred_workflow: str | None = None) Type[MaterialBase] [source]
Select the appropriate Material subclass based on the loaded maps.
- Parameters:
loaded_maps (Dict[str, Image.Image]) – Dictionary of loaded maps.
preferred_workflow (Optional[str]) – Preferred workflow (‘metallic’ or ‘specular’).
- Returns:
The Material subclass to instantiate.
- Return type:
Type[MaterialBase]