Material
Material is an important component for every object in the scene. Our DSL also supports sampling new materials for each object for domain randomization.
Since the material is the core asset of the database, we only explore its index in the database and do not allow users to access the raw data.
Domain randomization - Material Sampler
MINERVAS provides replace_material
method, which will provides following functionality:
REPLACE_ALL
: Given aModel
to randomly replace the material corresponding to each part (each part is sampled separately from the preset material library).REPLACE_BY_CATEGORY
: Given aModel
and the desired material category, and randomly replace the material of each part to the material of the corresponding material category. (Each part is sampled separately from the desired category of the preset material library)REPLACE_TO_GIVEN_LIST
: Given aModel
and the specified material id list, and randomly replace the material of each part to the material in the list.
Function parameters
First name | Required or not | Type | Description |
---|---|---|---|
id | Yes | String | Identifies the Model to be modified |
type | Yes | REPLACE_ALL | REPLACE_BY_CATEGORY | REPLACE_TO_GIVEN_LIST | replacement type |
category | Required when type=REPLACE_BY_CATEGORY | String | Category name to be replaced. Candidate material types currently: WOOD(0L),METAL(1),STONE(2). |
ids | Required when type=REPLACE_TO_GIVEN_LIST | List of String | ID list to be replaced |
Example
class MaterialSampler(EntityProcessor):
def process(self):
for instance in self.shader.world.instances:
# floor category_id: 1227
# sofa category_id: 1068
# carpet category_id: 1080
if instance.label in [1227, 1068, 1080]:
self.shader.world.replace_material(
id=instance.id,
type='REPLACE_ALL',
)