/************************************************************ * file: brushcirc.sl * author: Peter Stuart * date: 11/17/2002 * $Id: brushcirc.sl,v 1.4 2003/05/10 14:36:45 ophi Exp $ * description: This shader uses the Ashikhmin-Shirley anisotropic * BRDF model to generate brushed steel with circles. Layers can be * added if there aren't enough circles. * * ---- surface parameters ---------- * freq: number of circles in s and t directions * layers: number layers * radvar: variance for the radius * transvar: variance for the center of the circle * seed: controls random elements * nu, nv: specularity along principle and secondary axes. * Kd, Ks: diffuse and specular scale ************************************************************/ #include "rmannotes.sl" #include "ashshirModel.h" #include "shapes.h" #include "xforms.h" /* ---- macro to help seed random numbers ------ * it serves two purposes: * - allows easy searching to ensure non-repeating numbers * - automatically uses seed */ #define RN(x) (seed+(x)+0.5) surface brushcirc(float freq=10, layers=1; float radvar=1, transvar=1, seed=1234; float nu=0, nv=1000, Kd=0.5, Ks=0.5; float refl=0.5; uniform string envname=""; uniform float envsamp=1) { color layer_color, layer_opac, surface_color; float ss, tt; float r, theta; vector udir; float col, row; float true_col = whichtile(s, freq); float true_row = whichtile(t, freq); surface_color = Cs; /* loop over surrounding cells to get circles of neighbors */ uniform float i,j,k; for (k=0; k 0) layer_color += Cs*refl*EnvIllumAshShir(faceforward(normalize(N),I), normalize(-I), normalize(udir), Kd, Ks, nu, nv, envsamp, envname); layer_opac = draw_circle(point(cx, cy, 0), radius, 0.1, ss, tt); surface_color = blend(surface_color, layer_color, layer_opac); } } } Ci = surface_color; }