Material System
Opened this issue · 0 comments
Currently the material attribute of a shape is defined as a user defined string. Materials could be enhanced by creating a data structure that would contain two types of information:
- Physical Properties Attributes like: density, strength, stiffness
- Physically Based Rendering (PBR) Attributes that impact the appearance of a material when rendered, such as: ambient, diffuse, specular, and emmissive colors, shininess, transparency, etc.
Material properties would then be defined for a wide range of materials such as ABS, 2024 T3 Aluminum, Delrin, 316 Stainless Steel, etc. so the user could just assign a material to their part.
The physical properties could be used when calculating part mass or stiffness while the PBR parameters would be used when rendering the material though a viewer or when exporting to file formats that support such information such as glTF or 3MF.
The OCCT XDE (eXtended Data Exchange) document (used when generating many of the export file formats) only supports storing a material label so additional information would need to be added by directly enhancing the exporters. For example, the export_gltf
function would need to edit the generated JSON file as follows:
-
Modify/Add to the Materials Array: Add a new object to the materials array in the JSON structure, as shown in the example above. If the materials array does not exist, you will need to create it. Each object within the materials array represents a different material.
-
Define Material Properties: Within the material object, define the properties of your material, such as name, pbrMetallicRoughness, and any additional properties like textures or normal maps if needed. The pbrMetallicRoughness object is where you define the base color, metallicity, and roughness of the material.
-
Assign the Material to Mesh Primitives: Each mesh in the glTF file contains primitives, which are the actual geometry data. To apply your material to a mesh, you need to set the material index in the primitives to match the index of your material in the materials array. For example, if your new material is the first object in the materials array, its index is 0, and you would set "material": 0 in the mesh primitive(s) you want to apply it to.
A comprehensive material system would enable users to display and analyze their parts as real world objects.