RepoNVIDIANVIDIApublished Aug 8, 2018seen 1w

NVIDIA/MDL-SDK

C++

Open original ↗

Captured source

source ↗
published Aug 8, 2018seen 1wcaptured 1whttp 200method plain

NVIDIA/MDL-SDK

Description: NVIDIA Material Definition Language SDK

Language: C++

License: BSD-3-Clause

Stars: 527

Forks: 84

Open issues: 0

Created: 2018-08-08T23:13:22Z

Pushed: 2026-06-16T12:00:18Z

Default branch: master

Fork: no

Archived: no

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.

Preface

This README introduces the MDL SDK. It describes the target [audience](#audience), the [purpose](#purpose) of the SDK, an [example workflow](#example-usage) and [running example programs](#getting-started-using-the-sdk) that illustrate the implementation of core MDL concepts.

*Related information:*

  • For installation instructions, see ["Building the MDL SDK from Source"](INSTALL.md)
  • For a brief introduction to MDL, see ["What is MDL"](#what-is-mdl)

Audience

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.

![*Figure 1. MDL example material renderings*](doc/images/mdl_material_examples.jpg)

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.

export material checker() = diffuse( tiles( 8));

Refer to Material Definition Language Handbook for more details on the MDL language.

*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:

![*Figure 2. Example of a material workflow supported by the MDL SDK*](doc/images/mdl_sdk_workflow.png)

The callouts in the figure are described below. Each callout describes how a specific SDK component supports this material workflow:

1. 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.

2. Internal database: The internal database provides access to all material and function definitions.

3. 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.

4. 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.

5. Distilling and texture baking: Distilling is a process for mapping or simplifying compiled MDL materials to more limited material models used by specific renderers.

6. Texture baking: Baking textures ensures optimal rendering performance for game engines.

7. 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"](#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"](INSTALL.md) 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...

Excerpt shown — open the source for the full document.

Notability

notability 5.0/10

NVIDIA SDK release, 527 stars.