SEM Directional Lighting Code

// fake directional lighting
// using parallel "light".

shader SEM_Direction(
   vector direction = vector(0,1,0),
   color facecolor = 1,
   color rearcolor = 0.2,
   float strength = 2,
   string coordname = "world",
   output color resultRGB = 0)
{
normal n = normalize(N);
vector vec = transform(coordname, direction);

float dp = clamp(dot(n, vec), 0, 1);
resultRGB = mix(rearcolor, facecolor, pow(dp, strength));


}