Atom - 2012-06-17

Hi All,

I am trying to leverage the RSL match function inside a shader but it seems to always return 0.0.

For instance I am adding an identifier to the RIB.

Attribute "identifier" "name" [ "Cube" ]

In my shader I want to detect the name of the object. If the object has "hide" as part of the name, it will return 0.0 for Oi. essentially hiding the object from display, but still allowing it to contribute to raytrace and occlusion shadows.

surface pixie_matte (
    uniform float Ka = 1; 
    uniform float Kd = 1;
    normal Nf = faceforward (normalize(N),I);
    Oi = Os;

    //Expect an attribute.
    string name;
    string force_name;
    if(attribute("identifier:name", name) == 1)
        // Indicates that we have detected an expected attribute.
        force_name = "MyObject.hide";
        if(match("hide$", force_name)) 
            //Alternate processing based upon attribute value.
            Oi = 0;
        } else {
            //Default processing.
            Oi = Os;
    //Calculate final result.
    Ci = Cs * (Ka * ambient() + Kd * diffuse(Nf));
    //Oi = Os;  
    Ci *= Oi;

I can print the variable name and I see the name of my object so I know my code is getting to the inner IF. But even if I force the name, as shown, the match never works.