Functions

libmipflooding.flood_image() numpy.ndarray | None

Mip-flooded texture

Generates a mip-flooded image by generating and compositing coverage-scaled mip maps, and then compositing the unmodified original image on top.

Parameters:

image: numpy.ndarray

,:

ndarray[ndim=3], types uint8 / uint16 / float

coverage_mask: numpy.ndarray | None = None

,:

None; ndarray[ndim=1 or 2], type uint8, linear. If None, uses last channel of image as coverage mask.

max_threads: int = 0

,:

0; Number of threads, 0 = auto (half of available threads, which amounts to number of hardware cores for machines with SMT/HyperThreading)

coverage_threshold: float = 0.999

,:

0.999; Threshold for mask binarization

convert_srgb: bool = False

,:

False; Perform sRGB transformations (to linear and back) for correct scaling of sRGB textures

is_normal_map: bool = False

,:

False; Normalize output pixels (for normal maps / encoded vectors)

channel_mask: int = 0

,:

0; Bit mask for processing a subset of channels, 0 = all channels

scale_alpha_unweighted: bool = False

,:

False; Perform unweighted scaling on last channel? False = preserve coverage

preserve_mask_channel: bool = True

:

When no mask is provided, preserve original alpha channel in output?

Returns:

ndarray[ndim=3] of same type as input, or None on failure

libmipflooding.generate_mips() list | None

Coverage-weighted mip maps

Generates coverage-weighted mip maps and returns them as a list of NumPy arrays, matching the input type (output does not include input image / mip 0).

Parameters:

image: numpy.ndarray

,:

ndarray[ndim=3], types uint8 / uint16 / float, expects 0..1 range for float

coverage_mask: numpy.ndarray | None = None

,:

None; ndarray[ndim=1 or 2], type uint8, linear. If None, uses last channel of image as coverage mask.

max_threads: int = 0

,:

0; Number of threads, 0 = auto (half of available threads, which amounts to number of hardware cores for machines with SMT/HyperThreading)

coverage_threshold: float = 0.999

,:

0.999; Threshold for mask binarization

convert_srgb: bool = False

,:

False; Perform sRGB transformations (to linear and back) for correct scaling of sRGB textures

is_normal_map: bool = False

,:

False; Normalize output pixels (for normal maps / encoded vectors)

channel_mask: int = 0

,:

0; Bit mask for processing a subset of channels, 0 = all channels

scale_alpha_unweighted: bool = False

,:

False; Perform unweighted scaling on last channel? False = preserve coverage

composite_mips: bool = True

,:

True; Composite mips from bottom to top to fill holes? Set this and scale_alpha_unweighted to False for alpha coverage preservation

output_float: bool = False

:

Output mips as float

Returns:

list of ndarray[dtype=float]’s, or None on failure

libmipflooding.get_channel_mask() int

Returns a channel bit mask

Parameters:

channel_mask: list

,:

List of bools or ints, 1/true = process, 0/false = ignore

channel_stride: int = 0

:

(optional) number of channels in image data, 0 = infer from list length

Returns:

integer bit mask

libmipflooding.get_mip_count() int

Returns the number of mip levels for given resolution

Parameters:

width: int

,:

width in px

height: int

:

height in px

Returns:

number of mip levels