trimesh.visual.material module

material.py

Store visual materials as objects.

Classes

Material(*args, **kwargs)

PBRMaterial([name, emissiveFactor, …])

Create a material for physically based rendering as

SimpleMaterial([image, diffuse, ambient, …])

Hold a single image texture.

class trimesh.visual.material.Material(*args, **kwargs)

Bases: object

Attributes

main_color

property main_color
class trimesh.visual.material.PBRMaterial(name=None, emissiveFactor=None, emissiveTexture=None, normalTexture=None, occlusionTexture=None, baseColorTexture=None, baseColorFactor=None, metallicFactor=None, roughnessFactor=None, metallicRoughnessTexture=None, doubleSided=False, alphaMode='OPAQUE', alphaCutoff=0.5)

Bases: trimesh.visual.material.Material

Create a material for physically based rendering as specified by GLTF 2.0: https://git.io/fhkPZ

Parameters with Texture in them must be PIL.Image objects

Attributes

main_color

Methods

to_color(uv)

Get the rough color at a list of specified UV coordinates.

property main_color
to_color(uv)

Get the rough color at a list of specified UV coordinates.

Parameters

uv ((n, 2) float) – UV coordinates on the material

Returns

Return type

colors

class trimesh.visual.material.SimpleMaterial(image=None, diffuse=None, ambient=None, specular=None, glossiness=None, **kwargs)

Bases: trimesh.visual.material.Material

Hold a single image texture.

Attributes

glossiness

main_color

Return the most prominent color.

Methods

to_color(uv)

to_obj([tex_name, mtl_name])

Convert the current material to an OBJ format material.

to_pbr()

Convert the current simple material to a PBR material.

property glossiness
property main_color

Return the most prominent color.

to_color(uv)
to_obj(tex_name=None, mtl_name=None)

Convert the current material to an OBJ format material.

Parameters

name (str or None) – Name to apply to the material

Returns

  • tex_name (str) – Name of material

  • mtl_name (str) – Name of mtl file in files

  • files (dict) – Data as {file name : bytes}

to_pbr()

Convert the current simple material to a PBR material.

Returns

pbr – Contains material information in PBR format.

Return type

PBRMaterial