/**************************************************************************** * based on woodblockprint (info below), but modified to show * Different features: tapered tips * ************************************************ * * The original shader was: * * woodblockprint.sl -- surface shader for carved wood block printing * * (c) Copyright 1998 by Fleeting Image Animation, Inc. * All rights reserved. * * Permission is hereby granted, without written agreement and without * license or royalty fees, to use, copy, modify, and distribute this * software and for any purpose, provided that the above copyright * notice appear in all copies of this software. * * Author: Scott F. Johnston * * Reference: * _Advanced RenderMan: Creating CGI for Motion Picture_, * by Anthony A. Apodaca and Larry Gritz, Morgan Kaufmann, 1999. * ****************************************************************************/ surface woodblockprint ( float freq = 2; float duty = 0.50; float normal_dropoff = 1.0; float dpscale = 0.1; color stripe_color = 0;) { vector dp = dpscale * vtransform("screen", dPdu); setzcomp(dp, 0); /* Note: couldn't get the following to do what I'd expect, so ended up using the formulation below, which seemed to work, but I'm no doubt not understanding... */ /* float lendp = mix(clamp(length(dp),0,1),length(dPdu), normal_dropoff);*/ float lendp = (1-normal_dropoff*(1-clamp(length(dp),0,1))) * length(dPdu); float logdp = log(freq * lendp, 2); float ilogdp = floor(logdp); float stripes = pow(2,ilogdp); float sawtooth = mod(u * stripes, 1); float triangle = abs(2.0 * sawtooth - 1.0); float transition = logdp - ilogdp; float transtriangle = abs((1 + transition) * triangle - transition); /* float square = filterstep(duty * (1+transition/2), transtriangle);*/ float square = filterstep(duty, transtriangle); Ci = mix(Cs, stripe_color, square); }