/* simple_occlusion * * by Andrew Osiow * from the RenderMan App. Notes #35 */ normal shadingnormal(normal N) { normal Ns = normalize(N); uniform float sides = 2; uniform float raydepth; attribute("Sides", sides); rayinfo("depth", raydepth); if (sides == 2 || raydepth > 0) Ns = faceforward(Ns, I, Ns); return Ns; } surface simple_occlusion(float samples = 64, maxvariation = 0.02) { normal Ns = shadingnormal(N); // normalize N and flip it if backfacing // Compute occlusion float occ = occlusion(P, Ns, samples, "maxvariation", maxvariation); // Set Ci and Oi Ci = (1 - occ) * Cs * Os; Oi = Os; }