Arnold C++ Shader Writing
Getting Started



return to main index


Links:

    Cutter & Arnold C++ Shader Writing



Step 1: Setting the ARNOLD_PATH Environment Variable

https://area.autodesk.com/tutorials/creating-a-shader/
https://docs.arnoldrenderer.com/display/AFMUG/Creating+a+shader#CreatingaShader-1.1.1InstallingaC++Compiler

$ARNOLD_PATH/bin/kick -l /Users/malcolmkesson/Documents/WebSite/FUNDZA_COM/arnold_dev/shader_intro/simpleShader -info simpleShader
$ARNOLD_PATH/bin/kick -l ./simpleShader -info simpleShader
gcc -I$ARNOLD_PATH/include -L$ARNOLD_PATH/bin -lai -dynamiclib simpleShader.cpp -o simpleShader

node:         simpleShader
type:         shader
output:       RGB
parameters:   2
filename:     ./simpleShader
version:      5.4.0.0

Type          Name                              Default
------------  --------------------------------  --------------------------------
RGB           constantColor                     0.7, 0.7, 0.7
STRING        name
https://docs.arnoldrenderer.com/display/A5AFMUG/Getting+Started+With+Kick

    maya/
        |_ 2018/Maya.env <<-- edited
        |_ projects/
                   |_ Arnold_osl      <<-- created
                   |_ Arnold_osl/src  <<-- created

The source code of your shaders will be kept in the src directory while the compiled shaders will be stored in the Arnold_osl directory.


Step 2: Install the Latest Version of Arnold for Maya

2.1   Download and install the latest version of Arnold for Maya.


OSX and Linux Only

The oslc and oslinfo files may not be executable!
Open a terminal, cd to the bin directory and make a listing. For example,

mt-mkesson:~ malcolm$ cd /Applications/solidangle/mtoa/2018/bin
mt-mkesson:bin malcolm$ ls -l
total 357400
-rwxr-xr-x  1 root  admin  13695680 Oct 18 10:48 maketx
-rwxrwxrwx  1 root  admin   3460576 Oct 18 10:48 oslc
-rwxrwxrwx  1 root  admin   1152800 Oct 18 10:48 oslinfo

If oslc and oslinfo do not have rwxrwxrwx permissions execute the following commands.

    sudo -s
    enter your password
    chmod 777 oslc
    chmod 777 oslinfo


Step 3: Setting Up Cutter

3.1   Make sure you are using Cutter version 7.8.1 or higher.
3.2   Open the Osl prefs panel (Edit->Show Preferences->Languages->Osl).



Figure 1


Make sure the solidangle bin path, the source and the shaders have been set correctly. Select the SolidAngle Arnold button. This will ensure the keyboard shortcut Alt + e, Control + e or Apple + c will compile a shader when editing a .osl document.
3.3   Click the Save Osl button.



Step 4: Compiling a Shader

4.1   From the Templates menu choose Osl->uv2color.osl.



Figure 2


4.2   Save it as uv2color.osl in the maya/projects/Arnold_osl/src directory.
4.3   Use the keyboard shortcut Alt + e, Control + e or Apple + e to compile the shader.
4.4   Make sure the shader has been compiled to the correct directory.



Figure 3


If compilation has been successful the maya/projects/Arnold_osl directory will contain two files, uv2color.oso (the compiled shader) and uv2color.mtd (an Arnold metadata file).


Step 5: Using a Shader

4.1   Launch Maya 2018, open Hypershade and look for uv2color in the Arnold/Utility directory.



Figure 4









© 2002- Malcolm Kesson. All rights reserved.