surface wgsTreeRGB(float Kd = 1; string objectName = "leafShape"; string alphaMap = ""; color barkcolor = color(0.4, 0.2, 0), leafcolor0 = color(0.396,0.592,0.314), leafcolor1 = color(0.243,0.408,0.220), leafcolor2 = color(0.301,0.382,0.203), leafcolor3 = color(0.100,0.242,0.193), leafcolor4 = color(0.141,0.282,0.173), leafcolorElse = color(0.353,0.506,0.090); ) { /* --- Setup Variables --- */ color surfcolor = color(0.2,0.2,0.2); normal n = normalize(N); normal nf = faceforward(n, I); uniform string shapename; //color surfcolorHSV = ctransform( "hsv" ; surfcolor); //surfcolor = color(0.5,1,1); //if poly has name attr, refer to it as shapename if(attribute("identifier:name", shapename)) { //look for any micropolys with a name and number ;) string pattern = concat(objectName, "[0-9]*$"); //if pattern exists in shapename, //it must be a poly that we want as a leaf: if(match(pattern, shapename)) { //apply aplha to all polys if we have one if (alphaMap != "") Oi = Os * float texture(alphaMap); else Oi = Os; //Look at the trailing digit //if we have a "#" at end of poly: if(match("0$", shapename)) surfcolor = leafcolor0; else if(match("1$", shapename)) surfcolor = leafcolor1; else if(match("2$", shapename)) surfcolor = leafcolor2; else if(match("3$", shapename)) surfcolor = leafcolor3; else if(match("4$", shapename)) surfcolor = leafcolor4; else surfcolor = leafcolorElse; } else {// colorize everything else differently surfcolor = barkcolor; Oi = Os; } } //Oi = Os; color diffusecolor = Kd * diffuse(nf); Ci = Oi * Cs * surfcolor * diffusecolor; }