NVIDIA MDL SDK is an open-source toolkit designed to integrate physically-based materials into rendering applications through NVIDIA's Material Definition Language (MDL). The SDK provides essential tools for developers to create, manage, and optimize material definitions efficiently. Key features include a module system for reusing materials across projects, an internal database for managing material instances, transactions for building complex call graphs, and optimized compilation of materials. It also supports distilling MDL materials into renderer-specific formats and baking textures for improved performance in game engines. Additionally, the SDK offers multiple code generation backends—such as CUDA PTX, LLVM IR, HLSL, and GLSL—to ensure compatibility with various rendering systems. Ideal for software developers working on 2D or 3D graphics applications, the SDK enables high-quality material integration, enhancing rendering efficiency and visual fidelity.
README
An introduction to the NVIDIA MDL SDK
The NVIDIA® Material Definition Language (MDL) SDK is an open source
set of tools that enable the integration of physically-based materials
into rendering applications.
Software developers responsible for integrating MDL into applications with
2D or 3D graphics capabilities.
Prerequisite skills:
A working knowledge of C++
Familiarity with fundamental 3D graphics concepts
What is MDL?
Material definition language
NVIDIA Material Definition Language (MDL) is a domain-specific programming
language that you use to define physically-based materials and lights for
rendering. It is designed for the definition of the highest quality materials,
fast rendering, and serves as an industry standard for material exchange.
MDL materials
Materials consist of two parts -- A material definition and functions:
The material definition is declarative and based on a robust material model.
Example: The following code snippet is a simple declarative material
definition. In the example, the material generic_diffuse_material defines
a single material parameter diffuse_color. This parameter is used to
define the color for the diffuse reflection BSDF diffuse_reflection_bsdf.
export material diffuse( color diffuse_color = color(0.7))
= material(
surface: material_surface (
scattering: df::diffuse_reflection_bsdf (
tint: diffuse_color
)
)
);
The functions, which are written in a procedural programming language,
compute parameter values for the material model.
Example: In the following code snippet, the tiles function computes
the color for a tile at a particular texture coordinate to define a
checkerboard. The parameters define the number of tiles in one direction
and the two colors for the black and white tiles. The computation uses
math functions from the MDL standard math library.
export color tiles( int no_tiles,
color black = color(0.1),
color white = color(0.8))
{
float3 uvw = step(0.5, frac( no_tiles/2 * state::texture_coordinate(0)));
float black_or_white = frac((uvw.x + uvw.y)*0.5)*2.0;
return lerp( black, white, black_or_white);
}
The following code snippet uses the tiles function to define a
checkerboard material with eight times eight tiles per uv unit square.
Related information: For detailed information about MDL, the underlying
concepts, and creating MDL materials, see the
MDL documentation.
What is the MDL SDK?
The following sections describe the purpose of the MDL SDK, an example
workflow supported by the SDK, and a link to the installation instructions.
Purpose
The MDL SDK is a toolkit delivered as an open source C++ library. It is
designed to support a wide range of material workflows in new or existing
applications.
Example usage
The following figure illustrates an example workflow for material creation:
The callouts in the figure are described below. Each callout describes
how a specific SDK component supports this material workflow:
MDL modules:
You use the module mechanism to package materials and functions for re-use.
An MDL module contains one or more material and function definitions. When
you load a module it is parsed and validated by the MDL compiler and its
content is stored in an internal database.
Internal database:
The internal database provides access to all material and function definitions.
Transactions and call graphs:
You create, edit, and store material instances and function calls using
transactions. The results are stored in the internal database. From
database entities, you can connect functions to material parameters and
build call graphs that express complex materials.
Compiled materials:
You can compile these graphs into a compact optimized representation, which
is referred to as a compiled material. The compilation step includes
inlining of call expressions, constant folding and the elimination of
common subexpressions.
Distilling and texture baking:
Distilling is a process for mapping or simplifying compiled MDL materials
to more limited material models used by specific renderers.
Texture baking:
Baking textures ensures optimal rendering performance for game engines.
Backends:
A compiled material is the basis for code generation.
The SDK provides the following backends for code generation:
CUDA PTX
LLVM 12 IR
HLSL and GLSL
Native code generation for the CPU
The SDK also provides:
Example programs:
To help you get started using the MDL SDK, working example programs are
provided. See "Getting started using the SDK"
for an introduction to these example programs.
Documentation:
A detailed MDL specification, as well as conceptual, user, and reference
API documentation is included with the MDL SDK. You can also access this
documentation set from the
NVIDIA Ray Tracing Documentation
website.
Installing the SDK
Installations for the MDL SDK are provided for Linux, Windows, and macOS.
See "Building the MDL SDK from Source" for system requirements
and installation instructions.
Getting started using the SDK
To help you get up to speed quickly, the MDL SDK provides many example
programs that you can use as a starting point for the integration of MDL
into your application. The example programs are organized under
"The basics", which covers concepts and implementation
details that all software developers need to understand, followed by
concepts and implementation details concerning the
integration of MDL into a renderer.
The basics
The example programs listed in this section take you through the following
steps:
Distilling and baking enable you to optimize MDL materials for game engines and renderers with limited capabilities.
The following examples provide an introduction to the MDL distilling mechanism and how to use it.
Example for Integrating the MDL Encapsulated Format
shows how to export and load materials or functions using the MDL
encapsulated format. Note: MDLE enables you to inline all external MDL dependencies.
All textures and resources are stored in the package.