This is probably the most simple shader you can start playing with. It only outputs what you set in its color parameter.

#include <ai.h>


enum SimpleParams { p_color };

   AiParameterRGB("color", 0.7f, 0.7f, 0.7f);




   sg->out.RGB = AiShaderEvalParamRGB(p_color);

   if (i > 0)
      return false;

   node->methods     = SimpleMethods;
   node->output_type = AI_TYPE_RGB;
   node->name        = "simple";
   node->node_type   = AI_NODE_SHADER;
   strcpy(node->version, AI_VERSION);
   return true;


Short Description

node_initialize is called only once for each instance of the shader, at the beginning of the first render.

node_update is called once per render call (so, multiple times during progressive rendering or IPR) for each instance of the shader. And this includes the first render.

Summing up, for N calls to AiRender(), you have one call to node_initialize, then N calls to node_update. These numbers are not related to the number of threads at all.

node_finish is called once for each instance of the shader when an AiEnd() is called.

Compiling on Windows

Use the dummy project here.

Compiling on Linux

You'll need to compile each shader's source into an object file:

g++ -o shader1.os -c -fPIC -D_LINUX -I$ARNOLD_PATH/include shader1.cpp


Keep in mind that you need a node_loader entry point as explained here.

Next, you need to generate a shared library:

g++ -o -shared shader1.os -L$ARNOLD_PATH/bin -lai


Or if you want multiple shaders inside the library:

g++ -o -shared shader1.os shader2.os shader3.os ... loader.os -L$ARNOLD_PATH/bin -lai

Loading the shader

Your shader library is now ready to use by any application that can load Arnold plugins, you'll just have to copy it somewhere it can be found by the application.

If you are using kick, you can specify the path with the -l option:

kick -l /path/to/plugins scene.ass


Note that there is no need to specify plugin filenames, kick will load all plugins that it can find in the plugins directory.

  • No labels