pypbr.material.DiffuseSpecularMaterial
- class pypbr.material.DiffuseSpecularMaterial(albedo: Image | ndarray | FloatTensor | None = None, albedo_is_srgb: bool = True, normal: Image | ndarray | FloatTensor | None = None, roughness: Image | ndarray | FloatTensor | None = None, specular: Image | ndarray | FloatTensor | None = None, specular_is_srgb: bool = True, **kwargs)[source]
Bases:
MaterialBase
A class representing a PBR material using diffuse and specular 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, specular: Image | ndarray | FloatTensor | None = None, specular_is_srgb: bool = True, **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.
specular – The specular map.
specular_is_srgb – Flag indicating if specular is in sRGB space.
**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_basecolor_metallic_material
([albedo_is_srgb])Convert the material from diffuse-specular workflow to basecolor-metallic workflow.
Convert the albedo and specular maps 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 and specular maps to sRGB space if it's in linear space.
Attributes
linear_albedo
Get the albedo map in linear space.
Get the specular map in linear space.
normal_rgb
Get the normal map in RGB space.
size
Get the size of the texture maps.
- property linear_specular
Get the specular map in linear space.
- Returns:
The albedo map in linear space.
- Return type:
torch.FloatTensor
- to_basecolor_metallic_material(albedo_is_srgb: bool = False)[source]
Convert the material from diffuse-specular workflow to basecolor-metallic workflow.
- Parameters:
albedo_is_srgb – Flag indicating if the albedo map should be returned in sRGB space.
- Returns:
A new material instance in the basecolor-metallic workflow.
- Return type:
- to_linear()[source]
Convert the albedo and specular maps to linear space if it’s in sRGB.
- Returns:
Returns self for method chaining.
- Return type:
- to_srgb()[source]
Convert the albedo and specular maps to sRGB space if it’s in linear space.
- Returns:
Returns self for method chaining.
- Return type: