Create Material

Rhino Grasshopper

This mMaterial component implements parameters that are not found in the standard GH Material component and is designed to work with a companion Bake Geometry component. It can easily be extended to support more properties defined for the Material class. Nine parameters are currently supported:

  • DiffuseColor
  • AmbientColor
  • EmissionColor
  • ReflectionColor
  • Reflectivity
  • ReflectionGlossiness
  • Transparency
  • IndexOfRefraction
  • Name

Encapsulating the open source Python code inside a cluster allows two significant advantages:

  1. Outputs can be renamed to match the geometry, which isn't possible on a C# or Python script component.
  2. The cluster can be edited to remove unused inputs (or outputs) to make the cluster footprint smaller on the canvas.

Why Three Outputs?

The 'M' output of mMaterial is for the 'M' input of the standard Custom Preview component. It can be passed via the Data Output and Data Input components in Rhino 6. If that's all you need, you can ignore the other two.

Baking geometry, however, requires a different data type. Instead of 'Display Material' from the 'M' output, baking needs a 'Render Material' data type, which is supplied by the 'rM' output.

Unlike 'M' (Display Material), Rhino 6 Data Output and Data Input components fail to handle 'rM' (Render Material). To circumvent this obstacle, a third output was added, 'JSON', to convert mMaterial input values to text for transmission via Data Output. Subsequent Grasshopper models use these JSON values from Data Input as input to a json_M component that replicates both 'M' and 'rM', so passing it alone enables both Custom Preview and baking geometry.

See example on the Bake To Layer page.


Grasshopper: (29.4 KB)