Material Definition Language
Overview
NVIDIA Material Definition Language (MDL) enables users to define the reflective, transmissive, emissive and volumetric properties of objects. It consists of two major parts:
- A declarative material definition based on a powerful material model, and
- A procedural programming language to define functions that can compute values for the parameters of the material model.
Additional Information
The building blocks needed for part one, like elemental distribution functions, their modifiers and combiners, as well as the MDL file format .mdl and organization in modules and packages is explained in the NVIDIA Material Definition Language: Language Specification document [MDLSpecification]. The NVIDIA Material Definition Language: Technical Introduction document [MDLIntroduction] gives an introduction.
Part two has currently limited support in the NVIDIA Iray render modes; only environment functions are fully programmable and all others are restricted to a set of predefined functions and combinations of those, plus constant-folding in the MDL compiler. The available predefined functions and where and how they can be used is explained in the Module base.mdl documentation.
The release tape contains some example MDL materials located in the directory mdl/material_examples, which showcase some of the capabilities of the material definition language and the texturing functionality exposed through the module base.mdl.
Integration in Iray
MDL materials and functions are used in the following places in Iray:
- MDL modules can be imported into the scene database through the
mi::neuraylib::IImport_api methods. The special variable
${shader} can be used as prefix in URIs to resolve the relative
suffix against the shader search paths. For example, the URI
${shader}/base.mdl imports the base module
from the shader search paths.
The import creates database elements of the following classes to represent
the corresponding MDL elements:
Note: The MDL importer supports relative URIs only.
- A material definition can be cloned, albeit creating a new material with new default values in a module using the mi::IMdl_material_definition::create_preset() method. The new default value can be function calls and thus whole material graphs can be created and stored with this method.
- MDL modules can be exported from the scene database through the mi::neuraylib::IExport_api methods.
- A material definition can be instantiated with argument values for its material parameters, which results in a mi::IMdl_material_instance database element. Parameters can continue to be updated on material instances.
- A function definition can be provided with argument values for its parameters, which results in a mi::IMdl_function_call database element. Parameters can continue to be updated on the function call. Function calls can be used in arguments to other function calls and material instances.
- The material attribute can be used on geometric objects to apply a full MDL material to the object and on lights to apply the emission characteristics of a MDL material to the light. The material attribute references a MDL material instance represented by the mi::IMdl_material_instance in the Iray API.
- A function call can be used to define the environment lookup function.
- A function call can be used to define the virtual backplate texture.
- The Iray API provides two wrappers mi::Mdl_definition_wrapper and mi::Mdl_argument_editor. The first wrapper simplifies usage of the interfaces mi::IMdl_material_definition and mi::IMdl_function_definition. The second wrapper simplifies usage of the interfaces mi::IMdl_material_instance and mi::IMdl_function_call.