Qualified name of material inside MDL file

I’m trying to familiarize with MDL code, so I’m using “execution_cuda” example from mdl sdk examples.

I want to change the example material and use a material I choose. So I’m trying to use a gold_yellow material that is inside a gold.mdl from nvidia mdl materials.

gold.mdl is as follows:

/*****************************************************************************
*     Copyright 1986, 2017 NVIDIA Corporation. All rights reserved.
******************************************************************************

 MDL MATERIALS ARE PROVIDED PURSUANT TO AN END USER LICENSE  AGREEMENT,
 WHICH WAS ACCEPTED IN ORDER TO GAIN ACCESS TO THIS FILE.  IN PARTICULAR, 
 THE MDL MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF 
 COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL NVIDIA
 CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
 ANY GENERAL, SPECIAL,  INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, 
 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 
 THE USE OR INABILITY TO USE THE MDL MATERIALS OR FROM OTHER DEALINGS IN 
 THE MDL MATERIALS.
*/

mdl 1.2;

import anno::*;
import ::nvidia::core_definitions::flex_material;
import ::state::normal;

const string COPYRIGHT = 
" Copyright 1986, 2017 NVIDIA Corporation. All rights reserved.\n"
" MDL MATERIALS ARE PROVIDED PURSUANT TO AN END USER LICENSE  AGREEMENT,\n"
" WHICH WAS ACCEPTED IN ORDER TO GAIN ACCESS TO THIS FILE.  IN PARTICULAR,\n" 
" THE MDL MATERIALS ARE PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n"
" EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF\n"
" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF\n" 
" COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL NVIDIA\n"
" CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING ANY\n"
" GENERAL, SPECIAL,  INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, WHETHER IN\n"
" AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF THE USE OR\n"
" INABILITY TO USE THE MDL MATERIALS OR FROM OTHER DEALINGS IN THE MDL MATERIALS.\n";

export material gold_white(
    color base_color =  color ( 1.f , 0.9828275f , 0.9322785f)
    [[
        anno::display_name("Color"),
        anno::description("Choose the color of the metal."),
        anno::in_group("Appearance")
    ]],
    float reflection_roughness =  0.05f
    [[
        anno::display_name("Reflection Roughness"),
        anno::description("Higher roughness values lead to bigger highlights and blurrier reflections."),
        anno::in_group("Appearance")
    ]],
    float anisotropy =  0.f
    [[
        anno::display_name("Anisotropy"),
        anno::description("Higher values will stretch highlights."),
        anno::in_group("Appearance"),
        anno::hard_range(0.0,1.0)
    ]],
    float anisotropy_rotation =  0.f
    [[
        anno::display_name("Anisotropy Rotation"),
        anno::description("Changes the orientation of anisotropy."),
        anno::in_group("Appearance"),
        anno::hard_range(0.0,1.0)
    ]],
    float3 bump = state::normal()
    [[
        anno::display_name("Bump"),
        anno::description("Attach bump or normal maps here"),
        anno::in_group("Appearance")
    ]])
[[
    anno::display_name("Gold - White"),
    anno::description("Design - Metal - Gold - White"),
    anno::author("NVIDIA vMaterials"),
    anno::copyright_notice(COPYRIGHT)
]]= 
::nvidia::core_definitions::flex_material(
    base_color:  base_color,
    diffuse_roughness:  0.f,
    is_metal:  true,
    reflectivity:  1.f,
    reflection_roughness:  reflection_roughness,
    anisotropy:  anisotropy,
    anisotropy_rotation:  anisotropy_rotation,
    transparency:  0.f,
    transmission_color:  color ( 1.f , 1.f , 1.f),
    volume_color:  color ( 1.f , 1.f , 1.f),
    transmission_roughness:  0.f,
    base_thickness:  0.1f,
    ior:  0.47f,
    thin_walled:  false,
    normal: bump);

    
    
    
    
    
    
    
export material gold_yellow(
    color base_color =  color ( 0.9489647f , 0.6940823f , 0.3203804f)
    [[
        anno::display_name("Color"),
        anno::description("Choose the color of the metal."),
        anno::in_group("Appearance")
    ]],
    float reflection_roughness =  0.05f
    [[
        anno::display_name("Reflection Roughness"),
        anno::description("Higher roughness values lead to bigger highlights and blurrier reflections."),
        anno::hard_range(0.0,1.0),
        anno::in_group("Appearance")
    ]],
    float anisotropy =  0.f
    [[
        anno::display_name("Anisotropy"),
        anno::description("Higher values will stretch highlights."),
        anno::hard_range(0.0,1.0),
        anno::in_group("Appearance")
    ]],
    float anisotropy_rotation =  0.f
    [[
        anno::display_name("Anisotropy Rotation"),
        anno::description("Changes the orientation of anisotropy."),
        anno::hard_range(0.0,1.0),
        anno::in_group("Appearance")
    ]],
    float3 bump = state::normal()
    [[
        anno::display_name("Bump"),
        anno::description("Attach bump or normal maps here"),
        anno::in_group("Appearance")
    ]])
[[
    anno::display_name("Gold - Yellow"),
    anno::description("Design - Metal - Gold - Yellow"),
    anno::author("NVIDIA vMaterials"),
    anno::copyright_notice(COPYRIGHT)
]]= 
::nvidia::core_definitions::flex_material(
    base_color:  base_color,
    diffuse_roughness:  0.f,
    is_metal:  true,
    reflectivity:  1.f,
    reflection_roughness:  reflection_roughness,
    anisotropy:  anisotropy,
    anisotropy_rotation:  anisotropy_rotation,
    transparency:  0.f,
    transmission_color:  color ( 1.f , 1.f , 1.f),
    volume_color:  color ( 1.f , 1.f , 1.f),
    transmission_roughness:  0.f,
    base_thickness:  0.1f,
    ior:  2.5f,
    thin_walled:  false,
    normal:  bump);

and I try to run the program like this:

execution_cuda.exe --mdl_path “E:\MDL\materials\gold.mdl” “::mdl::gold::gold_yellow”

and I get error here:

                    mdl_impexp_api->load_module(transaction.get(), module_name.c_str(), context.get());
                    if (!print_messages(context.get()))
                        exit_failure("Loading module '%s' failed.", module_name.c_str());

as It never find the module. I can’t find what the qualified name should be, I tried lots of combinations like:
::gold::gold_yellow
::gold_yellow::gold_yellow
::mdl::gold_yellow
::gold.mdl::gold_yellow

But i can’t figure out the right one, as I don’t see inside gold.mdl any module definition.

Thanks in advance.

Assuming gold.mdl is in E:\MDL\materials, thats what should be given as – mdl_path.

–mdl_path “E:\MDL\materials"

MDL has a package and module system, like other program languages like python or Java. You tell the sdk/ example where to look for packages with --mdl_path and directories within that location are mdl packages, mdl files in that location are modules.

you specify then the mdl material as

::<module>::<material>

where <module> is the name of the file without extension and <material> is the material within the mdl file.
ie it should be

::gold::gold_yellow

note that gold.mdl itself references another material from an mdl module

import ::nvidia::core_definitions::flex_material;

here we have the material “flex_material” from the mdl module defined through the file “core_definitions.mdl” part of the package/subdirectory “nvidia”
which is part of the MDL SDK tape. You need to have a searchpath set to the location containing the nvidia package too (or have all your mdl modules and packages in the same search root)

Thank you, I had some include problems as you noted. Now I have it working and I can continue my research.