RfM Reyes
HyperShade - RIS Savvy Inputs

return to main index


This tutorial provides sample code that demonstrates how a custom Reyes hypershade utility node that can receive inputs from either a RIS pattern node or another Reyes utility node. For simplicity the output of the node is a float - input "A" added to "B".

Figure 1

Figure 2
Rendered in RIS mode (RfM version 20)

Figure 3

Name Mangling

If "A" is connected to a RIS pattern node the value it receives can only be obtained by providing it's name to the RSL evalparam() function. The RenderMan Look File (.rlf) that declares the shaders, plugins and their parameters performs "name managling". Consequently, "A" may become "cutrCombine1_A" or "cutrCombine2_A". For example,

Surface "renderman/pattern_ris_combine/shaders/RMSDisplacement1_rfm"
        "reference float cutrCombine1_A" ["PxrWorley1:resultF"]

However, if "A" is connected to a Reyes utility node "A" is not "mangled".

The weakest part of the implementation of the node is the need for the shading artist to copy the name of the node, outlined in yellow, in the Attribute Editor to the input field - outlined in red. Unfortunately, the node cannot query its "hypershade instance name".

Listing 1 (cutrCombine.h)

#ifndef cutrCombine_h
#define cutrCombine_h
<rman id="rslt">
slim 1 extensions cutter {
    extensions fundza cutr {
        template void Combine {
            userdata {
                rfm_nodeid 1053523
                rfm_classification rendernode/RenderMan/utility
            parameter float A {
                label "A"
                subtype {slider}
                range {0 1 0.05}
                default {0}
            parameter float B {
                label "B"
                subtype {slider}
                range {0 1 0.05}
                default {0}
            parameter string instancename {
                label "Instance Name"
                default "cutrCombine1"
            parameter {output float} result {
                detail mustvary
            RSLPlugin RfMShadeops
            RSLInclude "[file join [GetEnv RfM_HYPERSHADE_DIR] cutrCombine.h]"
            RSLFunction {}
void cutrCombine(float A; 
                 float B; 
                 string instancename;
                 output varying float result ) {
float  not_used = -1;    // The value of this variable is not used.
float  A_input = A,     // Make copies of the inputs.
       B_input = B;
// When an input is connected to a RIS pattern node it is referenced
// in the scene's .rlf (RenderLookFile) by the name of the instance
// of the node. For example,
//    "reference float cutrCombine1_a" ["PxrWorley2:resultF"]
// We rely on the user to correctly specify the name of the instance. 
string A_fullname = concat(instancename, "_A");
string B_fullname = concat(instancename, "_B");
// Chech if the inputs are connected to RIS pattern nodes
if(readprimvar(A_fullname, not_used) != 0) {
    evalparam(A_fullname, A_input);
if(readprimvar(B_fullname, not_used) != 0) {
    evalparam(B_fullname, B_input);
result = A_input + B_input;

© 2002- Malcolm Kesson. All rights reserved.