RfM Reyes
HyperShade SSSMaterial Node


return to main index

Links:
    RSL function SSSMaterials
    HyperShade node cutrSSSMaterials



Introduction

The tutorial Cutter: HyperShade Node Scripts gives a brief description of Cutter's ability to convert a RSL function, implemented in a .h file, to a script (also implemented as a .h file) that when sourced by RfM at start-up will add a custom node to HyperShade. This tutorial demonstrates how a sub-surface scattering utility node for use with RMSGPSurface can be written and integrated into RfM.

The RMSGPSurface shader has a subsurface scattering sub-panel - figure 1.



Figure 1


The parameters Albedo Tint and DMFP Color are the primary inputs that control the look of the sss. Although there are a number of useful presets,



Figure 2


none of them enable the materials listed in Pixar's Translucency and Subsurface Scattering document to be conveniently applied to Albedo Tint and DMFP Color.

This tutorial demonstrates how a simple utility node called cutrSSSMaterials can be added to HyperShade for the purpose of easily setting a variety of scattering values. The node and its user interface are shown below.



Figure 3


Figure 4


The RSL Function

The original RSL function, listing 1, consists of a list of if-else if statements. The ui-hint embedded within the comment following the declaration "float material;" tells Cutter to define a dropdown menu of names when it converts the RSL function to a hypershade node description.


Listing 1 (SSSMaterials.h)


void SSSMaterials(float material; 
/* [apple chicken1 chicken2 cream ketchup marble potato skimmilk skin1 skin2 wholemilk 1 2 3 4 5 6 7 8 9 10 11] */
                    output varying color albedo; 
                    output varying color dmfp) {
if(material == 1)       { albedo = color(0.846,0.841,0.528); dmfp = color(6.96,6.40,1.90); }
else if(material == 2)  { albedo = color(0.314,0.156,0.126); dmfp = color(11.61,3.88,1.75); }
else if(material == 3)  { albedo = color(0.321,0.160,0.108); dmfp = color(9.44,3.35,1.79); }
else if(material == 4)  { albedo = color(0.976,0.900,0.725); dmfp = color(15.03,4.66,2.54); }
else if(material == 5)  { albedo = color(0.164,0.006,0.002); dmfp = color(4.76,0.58,0.39); }
else if(material == 6)  { albedo = color(0.830,0.791,0.753); dmfp = color(8.51,5.57,3.95); }
else if(material == 7)  { albedo = color(0.764,0.613,0.213); dmfp = color(14.27,7.23,2.04); }
else if(material == 8)  { albedo = color(0.815,0.813,0.682); dmfp = color(18.42,10.44,3.50); }
else if(material == 9)  { albedo = color(0.436,0.227,0.131); dmfp = color(3.67,1.37,0.68); }
else if(material == 10) { albedo = color(0.623,0.433,0.343); dmfp = color(4.82,1.69,1.09); }    
else                    { albedo = color(0.908,0.881,0.759); dmfp = color(10.90,6.58,2.51); }
  
}

Before converting a function to a node it is best to check if it will compile. For example, compiling the simple shader shown next will indicate whether or not the function is free of syntax errors.


Listing 2 (foo.sl)


#include "SSSMaterials.h"
  
surface foo()
{
  
}


Generating the HyperShade Node Script

To generate the node script select the text of the RSL function, right mouse click (or control + left mouse click) and choose "Export as HyperShade Node".



Figure 5


Cutter will hilite the rfm_nodeid line as a reminder that its value must not clash with an id of an existing node.



Figure 6


Save the script in the directory designated for storing hypershape node files and modify the "RenderMan_for_Maya.ini file" so that the node is installed when RfM starts up. Instructions for both of these operations can be found in the tutorial Cutter: HyperShade Node Scripts.


Using the Custom Node

In hypershade, middle mouse drag from the cutrSSSMaterials node to an instance of the RMSGPSurface node and choose "Other...".



Figure 7


In the connection editor connect the outputs of cutrSSSMaterial to the inputs of RMSGPSurface.



Figure 8


Set the appropriate mix of diffuse and SSS lighting (Diffuse Mix), select a material from the cutrSSSMaterial dropdown menu and render.



Figure 9





© 2002- Malcolm Kesson. All rights reserved.