Skip to content

Material Types & Presets

Panopti offers several material types and presets for Mesh like objects through the ThreeJS material system. We encourage users to refer to ThreeJS documentation where appropriate.

import panopti
from panopti.materials import (
    MeshStandardMaterial,
    MeshPhysicalMaterial,
    MeshToonMaterial,
    MeshBasicMaterial,
    MeshNormalMaterial,
    MeshDepthMaterial,
)
from panopti.materials import  MaterialPresets

viewer = panopti.connect(server_url='http://localhost:8080', viewer_id='client')

# ... load mesh here ...

# Creating a standard material:
mat = MeshStandardMaterial(
    color=(1, 0, 0),
    roughness=0.35, 
    metalness=0.05,
    side='double'
)

# Or you can go for a material preset, e.g.
mat = MaterialPresets.plastic

# Create mesh with `material=mat`
viewer.add_mesh(
    name=f'MyMesh',
    vertices=verts,
    faces=faces,
    material=mat
)

viewer.hold()
Interaction of color and vertex_colors / face_colors

When adding mesh-like objects to your scene, be aware that ThreeJS will blend the material's color with vertex_colors or face_colors if they are specified. To avoid this, make sure you're using a purely white color color = (1.0, 1.0, 1.0). For example:

mat = MaterialPresets.plastic
mat.color = (1.0, 1.0, 1.0)
viewer.add_mesh(
    name=f'MyMesh',
    vertices=verts,
    faces=faces,
    vertex_colors=my_vertex_colors,
    material=mat
)

For this reason, MaterialPresets uses white as the default color for all presets.

Material Types

BaseMaterial panopti.materials.base.BaseMaterial
BaseMaterial

Base class for all materials types with common properties. For details on the parameters listed below, refer to: https://threejs.org/docs/#api/en/materials/Material

Supported parameters:

- flat_shading: bool
- color: RGB array [r,g,b] or hex string
- opacity: float between 0 and 1
- transparent: bool
- alpha_test: float between 0 and 1
- side: str, "front", "back", "double"
- wireframe: bool
- wireframe_linewidth: float
- depth_test: bool
- depth_write: bool
- tone_mapped: bool

MeshStandardMaterial panopti.materials.MeshStandardMaterial
MeshStandardMaterial

Bases: BaseMaterial

Physically-based standard material with metallic-roughness workflow. For details on the parameters listed below, refer to: https://threejs.org/docs/#api/en/materials/MeshStandardMaterial

Supported parameters:

- roughness: float between 0 and 1
- metalness: float between 0 and 1
- emissive: RGB array [r,g,b] or hex string
- emissive_intensity: float between 0 and 1

MeshPhysicalMaterial panopti.materials.MeshPhysicalMaterial
MeshPhysicalMaterial

Bases: BaseMaterial

Extended physically-based material with additional properties for realistic rendering. For details on the parameters listed below, refer to: https://threejs.org/docs/#api/en/materials/MeshPhysicalMaterial

Supported parameters:

- roughness
- metalness
- emissive
- emissive_intensity
- reflectivity
- sheen
- sheen_roughness
- sheen_color
- specular_intensity
- specular_color
- ior
- anisotropy
- anisotropy_rotation
- iridescence
- iridescence_ior
- iridescence_thickness_range
- clearcoat
- clearcoat_roughness
- transmission
- thickness
- attenuation_distance
- attenuation_color

MeshToonMaterial panopti.materials.MeshToonMaterial
MeshToonMaterial

Bases: BaseMaterial

Material for cel-shaded rendering. For details on the parameters listed below, refer to: https://threejs.org/docs/#api/en/materials/MeshToonMaterial

Supported parameters:

- emissive: RGB array [r,g,b] or hex string
- emissive_intensity: float between 0 and 1

MeshNormalMaterial panopti.materials.MeshNormalMaterial
MeshNormalMaterial

Bases: BaseMaterial

Material for visualizing normal vectors - useful for debugging. See: https://threejs.org/docs/#api/en/materials/MeshNormalMaterial

MeshDepthMaterial panopti.materials.MeshDepthMaterial
MeshDepthMaterial

Bases: BaseMaterial

Material for depth-based rendering - renders depth as grayscale. For details on the parameters listed below, refer to: https://threejs.org/docs/#api/en/materials/MeshDepthMaterial

Supported parameters:

- depth_packing: str, "basic" or "rgba"


Material Presets

We offer several customizable material presets that are applicable in most scenarios:

Material Presets

Example:

from panopti.materials import MaterialPresets

mat_plastic = MaterialPresets.plastic   # type: MeshStandardMaterial
mat_glossy  = MaterialPresets.glossy    # type: MeshStandardMaterial
mat_chalk   = MaterialPresets.chalk     # type: MeshStandardMaterial
mat_marble  = MaterialPresets.marble    # type: MeshStandardMaterial
mat_metal   = MaterialPresets.metal     # type: MeshPhysicalMaterial
mat_flat    = MaterialPresets.flat      # type: MeshBasicMaterial
mat_normals = MaterialPresets.normals   # type: MeshNormalMaterial

# Customize their attributes to your liking, e.g. 
# make the material blue and half transparent:
mat_plastic.color = "#42a9f8"
mat_plastic.opacity = 0.5
mat_plastic.transparent = True
...

Tips

Color-sensitive experiments
Color-sensitive experiments

In cases where color data should be displayed exactly as-is, you can disable shading and tonemapping. Consider using the following material setup:

from panopti.materials import MeshBasicMaterial

color_safe_material = MeshBasicMaterial(
    flat_shading=True,
    tone_mapped=False
)

viewer.add_mesh(
    name=f'MyMesh',
    vertices=verts,
    faces=faces,
    material=color_safe_material
)