shader FaceColor
[[
int rfm_nodeid = 8,
string rfm_classification = "rendernode/RenderMan/pattern",
string help = "Applies colors to faces depeding on their direction."
]]
(
color xcolor = color(0.3,1,1)
[[
string label = "X Direction Color",
]],
color ycolor = color(1,0.5,1)
[[
string label = "Y Direction Color",
]],
color zcolor = color(1,1,0.8)
[[
string label = "Z Direction Color",
]],
color base_color = 1
[[
string label = "Base Color",
]],
string coordsys_name = "object"
[[
string label = "Space Name",
]],
output color resultRGB = 0)
{
vector vecx = vector(1.0,0,0);
vector vecy = vector(0,1.0,0);
vector vecz = vector(0,0,1.0);
vector Nn = normalize(N);
if(coordsys_name == "")
Nn = transform("object", Nn);
else
Nn = transform(coordsys_name, Nn);
float d = abs( dot(Nn, vecx) );
color c = mix(base_color, xcolor, d);
d = abs( dot(Nn, vecy) );
c = mix(c, ycolor, d);
d = abs( dot(Nn, vecz) );
resultRGB = mix(c, zcolor, d);
}