pypbr.material.BasecolorMetallicMaterial
- class pypbr.material.BasecolorMetallicMaterial(albedo: Image | ndarray | FloatTensor | None = None, albedo_is_srgb: bool = True, normal: Image | ndarray | FloatTensor | None = None, roughness: Image | ndarray | FloatTensor | None = None, metallic: Image | ndarray | FloatTensor | None = None, **kwargs)[source]
Bases:
MaterialBase
A class representing a PBR material using basecolor and metallic maps.
- __init__(albedo: Image | ndarray | FloatTensor | None = None, albedo_is_srgb: bool = True, normal: Image | ndarray | FloatTensor | None = None, roughness: Image | ndarray | FloatTensor | None = None, metallic: Image | ndarray | FloatTensor | None = None, **kwargs)[source]
Initialize the Material with optional texture maps.
- Parameters:
albedo – The albedo map.
albedo_is_srgb – Flag indicating if albedo is in sRGB space.
normal – The normal map.
roughness – The roughness map.
metallic – The metallic map.
**kwargs – Additional texture maps.
Methods
__init__
([albedo, albedo_is_srgb, normal, ...])Initialize the Material with optional texture maps.
adjust_normal_strength
(strength_factor)Adjust the strength of the normal map.
apply_transform
(transform)Apply a transformation to all texture maps.
compute_height_from_normal
([scale])Compute the height map from the normal map using Poisson reconstruction.
compute_normal_from_height
([scale])Compute the normal map from the height map.
crop
(top, left, height, width)Crop all texture maps to the specified region.
flip_horizontal
()Flip all texture maps horizontally.
flip_vertical
()Flip all texture maps vertically.
invert_normal
()Invert the Y component of the normal map.
resize
(size[, antialias])Resize all texture maps to the specified size.
roll
(shift)Roll all texture maps along the specified shift dimensions.
rotate
(angle[, expand, padding_mode])Rotate all texture maps by a given angle.
save_to_folder
(folder_path)Save the material maps to a folder.
tile
(num_tiles)Tile all texture maps by repeating them.
to
(device)Moves all tensors in the material to the specified device.
to_diffuse_specular_material
([albedo_is_srgb])Convert the material from basecolor-metallic workflow to diffuse-specular workflow.
to_linear
()Convert the albedo map to linear space if it's in sRGB.
to_numpy
()Convert all texture maps to NumPy arrays.
to_pil
([maps_mode])Convert all texture maps to PIL Images.
to_srgb
()Convert the albedo map to sRGB space if it's in linear space.
Attributes
linear_albedo
Get the albedo map in linear space.
normal_rgb
Get the normal map in RGB space.
size
Get the size of the texture maps.
- to_diffuse_specular_material(albedo_is_srgb: bool = False)[source]
Convert the material from basecolor-metallic workflow to diffuse-specular workflow.
- Parameters:
albedo_is_srgb – Flag indicating if the albedo map should be returned in sRGB space.
- Returns:
A new material instance in the diffuse-specular workflow.
- Return type: