blenderproc.python.modules.provider.getter.Material module¶
-
class
blenderproc.python.modules.provider.getter.Material.
Material
(config)[source]¶ Bases:
blenderproc.python.modules.main.Provider.Provider
Returns a list of materials that comply with defined conditions.
Example 1: Return materials matching a name pattern.
{ "provider": "getter.Material", "conditions": { "name": "wood.*" } }
Example 2: Return all materials matching a name pattern which also have exactly two textures used.
{ "provider": "getter.Material", "conditions": { "name": "wood.*", "cf_texture_amount_eq": "2" } }
Example 3: Return all materials matching a name pattern which also have two or more textures used.
{ "provider": "getter.Material", "conditions": { "name": "wood.*", "cf_texture_amount_min": "2" } }
- Example 4: Return all materials which: {match the name pattern ‘wood.*’ AND have two or less textures used}
- OR {match the name pattern ‘tile.*’}
{ "provider": "getter.Material", "conditions": [ { "name": "wood.*", "cf_texture_amount_max": "2" }, { "name: "tile.*" } ] }
- Example 5: Return all materials which: {are cc_textures (see CCMaterialLoader) and do not have
- any alpha texture used}
{ "provider": "getter.Material", "conditions": [ { "cp_is_cc_texture": True, "cf_principled_bsdf_Alpha_eq": 1.0 } ] }
Example 6: Return all materials which: {belong to a certain list of objects and do not have any alpha texture used}
{ "provider": "getter.Material", "conditions": [ { "cf_use_materials_of_objects": { "provider": "getter.Entity", "conditions": { "type": "MESH", "name": "Suzanne" } }, "cf_principled_bsdf_Alpha_eq": 1.0 } ] }
Configuration:
Parameter Description Type conditions List of dicts/a dict of entries of format {attribute_name: attribute_value}. Entries in a dict are conditions connected with AND, if there multiple dicts are defined (i.e. ‘conditions’ is a list of dicts, each cell is connected by OR. list/dict conditions/attribute_name Name of any valid material’s attribute, custom property, or custom function. Any given attribute_value of the type string will be treated as a REGULAR EXPRESSION. ” In order to specify, what exactly one wants to look for: For attribute: key of the pair must be a valid attribute name. For custom property: key of the pair must start with cp_ prefix. For calling custom function: key of the pair must start with cf_ prefix. See table below for supported custom functions. string conditions/attribute_value Any value to set. string, list/Vector, int, bool or float index If set, after the conditions are applied only the entity with the specified index is returned. int random_samples If set, this Provider returns random_samples objects from the pool of selected ones. Define index or random_samples property, only one is allowed at a time. Default: 0. int check_empty If this is True, the returned list can not be empty, if it is empty an error will be thrown. Default: False. bool Custom functions
Parameter Description Type cf_texture_amount_{min,max,eq} Returns materials that have a certain amount of texture nodes inside of the material. Suffix ‘min’ = less nodes or equal than specified, ‘max’ = at least as many or ‘eq’ = for this exact amount of textures nodes. int cf_principled_bsdf_amount_{min,max,eq} Returns materials that have a certain amount of principled bsdf nodes inside of the material. Suffix ‘min’ = less nodes or equal than specified, ‘max’ = at least as many or ‘eq’ = for this exact amount of principled bsdf nodes. int cf_principled_bsdf_{INPUT}_{min,max,eq} Returns materials that have a certain value for a certain INPUT of the principled bsdf node. Only works if there is only one principled bsdf node. The INPUT can be any of the input values used of the principled bsdf. By using this all materials, which do not use a float value as an input are also not selected. Suffix ‘min’ = less nodes or equal than specified, ‘max’ = at least as many or ‘eq’ = for this exact amount of principled bsdf nodes. float conditions/cf_use_materials_of_objects This accepts a provider “getter.Entity”, which returns a list of mesh objects, on which the materials have to be in use. This can be used to return all materials, which are currently used on a certain object. Provider -
_get_conditions_as_string
()[source]¶ Returns the used conditions as neatly formatted string :return: str: containing the conditions
-
static
perform_and_condition_check
(and_condition, materials, used_materials_to_check=None)[source]¶ Checks for all materials in the scene if all given conditions are true, collects them in the return list.
Parameters: - and_condition – Given conditions. Type: dict.
- materials – Materials, that are already in the return list. Type: list.
- used_materials_to_check – a list of materials to perform the check on. Type: list. Default: all materials
Returns: Materials that fulfilled given conditions. Type: list.