Materials

Materials are shared resources that define how triangular meshes are rendered. Point clouds on the other hand don't expose materials whatsoever.

Materials are used to specify

  • which textures to apply,
  • whether to make objects transparent,
  • how lighting interacts with the surface.

Materials are automatically created during model conversion and are accessible at runtime. You can also create custom materials from code and replace existing ones. This scenario makes especially sense if you want to share the same material across many meshes. Since modifications of a material are visible on every mesh that references it, this method can be used to easily apply changes.

Note

Some use cases, such as highlighting a picked object can be done by modifying materials, but are much easier achieved through the HierarchicalStateOverrideComponent.

Material types

Azure Remote Rendering has two distinct material types:

  • PBR materials are used for surfaces that should be rendered as physically correct, as possible. Realistic lighting is computed for these materials using physically based rendering (PBR). To get the most out of this material type, it's important to provide high-quality input data, such as roughness and normal maps.

  • Color materials are used for cases where no extra lighting is desired. These materials are always full bright and are easier to set up. Color materials are used for data that should either have no lighting at all, or already incorporates static lighting, such as models obtained through photogrammetry.

Mesh vs. MeshComponent material assignment

Triangular Meshes have one or more submeshes. Each submesh references one material. You can change the material to use either directly on the mesh, or you can override which material to use for a submesh on a MeshComponent.

When you modify a material directly on the mesh resource, this change affects all instances of that mesh. Changing it on the MeshComponent, however, only affects that one mesh instance. Which method is more appropriate depends on the desired behavior, but modifying a MeshComponent is the more common approach.

Material de-duplication

During conversion multiple materials with the same properties and textures are automatically de-duplicated into a single material. You can disable this feature in the conversion settings, but we recommend leaving it on for best performance.

Material classes

All materials provided by the API derive from the base class Material. Their type can be queried through Material.MaterialSubType or by casting them directly:

void SetMaterialColorToGreen(Material material)
{
    if (material.MaterialSubType == MaterialType.Color)
    {
        ColorMaterial colorMaterial = material as ColorMaterial;
        colorMaterial.AlbedoColor = new Color4(0, 1, 0, 1);
        return;
    }

    PbrMaterial pbrMat = material as PbrMaterial;
    if (pbrMat != null)
    {
        pbrMat.AlbedoColor = new Color4(0, 1, 0, 1);
        return;
    }
}
void SetMaterialColorToGreen(ApiHandle<Material> material)
{
    if (material->GetMaterialSubType() == MaterialType::Color)
    {
        ApiHandle<ColorMaterial> colorMaterial = material.as<ColorMaterial>();
        colorMaterial->SetAlbedoColor({ 0, 1, 0, 1 });
        return;
    }

    if (material->GetMaterialSubType() == MaterialType::Pbr)
    {
        ApiHandle<PbrMaterial> pbrMat = material.as<PbrMaterial>();
        pbrMat->SetAlbedoColor({ 0, 1, 0, 1 });
        return;
    }
}

API documentation

Next steps