Whats New - Version 8.3.1

Mar 17 2021


return to main index



Arnold MTD Files & C++ Source

Immediately after a C++ source code file has been successully compiled, Cutter parses declarations found in the node_parameters { } block and generates a .mtd file. For example, this shader,

/*
Determines which color to use on the front / rear facing normals.
*/
#include <ai.h>
#include <cstring>
  
AI_SHADER_NODE_EXPORT_METHODS(SampleMethods);
 
namespace {
    enum paramIndex { k_rear_color, k_front_color, k_swap};
    };

node_parameters {
    AiParameterRGB("color_rear", 0.7f, 0.7f, 0);
    AiParameterRGB("color_front", 0.7f, 0, 0);
    AiParameterBool("swap", 0);
    }
    
shader_evaluate {
    AtRGB color_rear = AiShaderEvalParamRGB(k_rear_color);
    AtRGB color_front = AiShaderEvalParamRGB(k_front_color);
    bool  swap = AiShaderEvalParamBool(k_swap);
    
    // We are shading a front face...
        if(sg->N == sg->Nf)
            sg->out.RGB() = (swap) ? color_rear : color_front;
        else
            sg->out.RGB() = (swap) ? color_front: color_rear;
        }
    
node_loader {
    if (i > 0)
        return false; 
    node->methods        = SampleMethods;
    node->output_type    = AI_TYPE_RGB;
    node->name           = "mkSideMask";
    node->node_type      = AI_NODE_SHADER;
    strcpy(node->version, AI_VERSION);
    return true;
    }
    
// The remaining macros can be left "empty"
node_initialize { }
node_update { }
node_finish { }
 

when compiled would generate a file named mkSideMask.mtd - saved in the same directory as mkSideMask.cpp.

# This file is automatically updated by Cutter when a shader is compiled.
# Only edit this file immediately before publishing the shader. Make a
# backup of your edited .mtd file before recompiling the shader
# otherwise your edits will be over-written by Cutter.
  
[node mkSideMask]
    maya.id              INT        28
    maya.name            STRING    "mkSideMask"
    maya.classification  STRING    "Utility"
    [attr color_rear]
        maya.name        STRING    "color_rear"
#        desc            STRING    ""
    [attr color_front]
        maya.name        STRING    "color_front"
#        desc            STRING    ""
    [attr swap]
        maya.name        STRING    "swap"
#        desc            STRING    ""
    [attr param_name]
        maya.name        STRING    "param_name"
#        desc            STRING    ""
#        min                INT        0
#        max                INT        10
#        softmin            INT        0
#        softmax            INT        10

The mtd file for a shader can be quickly opened by right-mouse clicking within the shader CPP document.




Figure 1










© 2002- Malcolm Kesson. All rights reserved.