/* * polkadot(): surface shader for applying a polka dot pattern * (with some help from checker() in The RenderMan Companion) */ surface polkadot (float Kd = 0.5, Ka = 0.1, dotradius = 0.25, dotSfrequency = 10, /* how many dots this way */ dotTfrequency = 10; /* how many dots that way */ color dotcolor = color(1, 0.5, 0), /* orange */ basecolor = color(0.25, 0.25, 0.75) /* blue */ ) { float smod = mod(s*dotSfrequency, 1), tmod = mod(t*dotTfrequency, 1); /* dot shall be centered at (0.5,0.5) in [0,1]X[0,1] */ if (sqrt((smod-0.5)*(smod-0.5)+(tmod-0.5)*(tmod-0.5)) <= dotradius) Ci = dotcolor; else Ci = basecolor; Oi = Os; Ci = Oi*Ci*(Ka*ambient()+Kd*diffuse(faceforward(normalize(N),I))); }