/* wgsComposite AOV shader Jan 20 2010 This shader adds two outputs to a standard ambeint/diffuse/specular lightshader: 1. _depth - calculates a depth if shader is applied, meaning, if the shader is not applied, depth is occluded 2. _zmask - alpha channel for masking out objects that do not want depth. this is available but not always needed. One can easily take these two component and add them to any shader. */ surface wgsComposite(color Ka = color(0.15,0.15,0.15), /* ambient brightness */ Kd = color(0.80,0.80,0.80), /* basic brightness */ Ks = color(0.70,0.70,0.70); /* hilite brightness */ float roughness = 0.1; /* hilite spread */ color hilitecolor = 1; /* hilite color */ string texturefile = ""; output varying float _depth = 0; output varying float _zmask = 1;) { color ambientcolor, diffusecolor, speccolor,surfcolor = 1; if (texturefile != "") surfcolor = surfcolor * color texture(texturefile, s, 1-t); else surfcolor = 1; normal n = normalize(N); normal nf = faceforward(n, I); vector i = normalize(-I); Oi = Os; ambientcolor = Ka * ambient(); diffusecolor = Kd * diffuse(nf); speccolor = Ks * specular(nf, i, roughness) * hilitecolor; _depth = depth(P); _zmask = 1; Ci = Oi * Cs * surfcolor * (ambientcolor + diffusecolor + speccolor); }