In this example we will demonstrate how you can write your own shader node using the RenderMan Shading Language that is fully working within Softimage Render Tree, without the need of any SDK or compilation tools. This simple shader will be based on a lambertian model with AOV channels for "ambient", "raw diffuse" and albedo. You will also be able to choose the shading color (image connection will be possible). If you are too impatient, you see a video that shows how this shader is created and debugged live in Softimage's render view.
To fully understand this tutorial, you will need some scripting knowledge (in this case Python) and some basic knowledge of the Softimage SDK. But you do not need any compiler or developer's SDK installed, everything you need is in the 3Delight for Softimage package.
Create the Softimage Render Tree node:
The very first thing to do, is to register your own shader. In order to do that, you have to create a new python file. This file should contain the following lines of code:
This will register a shader called "Lambertian" inside the Softimage Render Tree. When this is done, you need to setup your interface in order to give options to both the end user and the renderer. In our case we will use two RGB color values: one for the ambient color (default is black) and one for the main diffusion color (default is a 50% grey).
To do that you need to add the following lines of code to the previous file:
With this done, you are all set for the Softimage part, and now you can have a fully working custom shader node inside Softimage. Note that this shader will only work with 3Delight. The result will look like this:
3Delight for Softimage will search for the function named
lambertian_1_0 inside the SL file called
lambertian.sl. At this point, if you try to render this, you will receive the following message:
This means 3Delight for Softimage was able to acknowledge this new shader but, unfortunately, it wasn’t able to find the shader itself in order to provide you with the appropriate result – this is normal since we didn't write the shader just yet.
Creating the RenderMan shader
Now that we have provided Softimage with an interface for our shader, we have to write the actual shader code. For more information on the RendeMan Shading Language used by 3Delight, please read the 3Delight User's Manual (chapter called “The Shading Language”). The first think you have to do is to create a file named
lambertian.sl using your favorite text editor. This file need to be located inside your c:/tmp folder (we could assign any directory in the python script above).
Add the following lines of code inside your file:
When the file is properly located, you just have to press render again and 3Delight will compile and render your scene using your new shader. This will automatically be compatible with the Path Tracing (including IPR) and REYES algorithms. The end result of this shader will provide you with the following result:
The available render channel of this example are:
- Main (Ambiant + Diffuse)
- Albedo (Color input)
- Raw_Diffuse (Diffuse / Albedo)
- Diffuse (Diffuse x Albedo)
An important advantage of 3Delight for Softimage is it make it easy to troubleshoot and maintain your shader code since you do not have to compile your code against a version of the renderer. 3Delight for Softimage will compile it at run time along with the rest of the Render Tree node in order to provide the appropriate result. This allows easy debugging and optimisation of shaders.
This video demonstrates how you can develop the shader we just presented and and debug it live inside Softimage's render view.